Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing ggplot “subscript out of bounds” error

Tags:

r

ggplot2

$ R
R version 2.12.2 (2011-02-25)
Platform: i486-pc-linux-gnu (32-bit)

> install.packages("ggplot2", dep="T")
Error in apply(available[p1, dependencies, drop = FALSE], 1L, function(x)  paste(x[!is.na(x)],  : 
  subscript out of bounds

What can I do to install ggplot2?

like image 622
GaBorgulya Avatar asked Apr 02 '11 11:04

GaBorgulya


People also ask

How do you solve a subscript out of bounds in R?

The subscript out of limits error occurs because the fourth column of the matrix does not exist. If we don't know how many columns the matrix has, we can use the ncol() function to figure it out.

What does subscript out of bounds mean in R?

One common error you may encounter in R is: Error in x[, 4] : subscript out of bounds. This error occurs when you attempt to access a column or row in a matrix that does not exist.


1 Answers

Do read the help for functions! From ?install.packages we have:

dependencies: logical indicating to also install uninstalled packages
          on which these packages depend/suggest/import (and so on
          recursively).  Not used if ‘repos = NULL’.  Can also be a
          character vector, a subset of ‘c("Depends", "Imports",
          "LinkingTo", "Suggests", "Enhances")’.

So this clearly states that you need to supply a logical value, a TRUE or a FALSE. "T" is not a logical TRUE and neither is T really. Always spell out TRUE and FALSE otherwise you could get into lots of trouble. It isn't worth the hassle to save on a few keystrokes.

As I showed in the answer to the previous Q:

R> install.packages("ggplot2", dependencies = TRUE)

works. So why did you alter what I showed you did work?

like image 102
Gavin Simpson Avatar answered Sep 20 '22 02:09

Gavin Simpson