Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rdply and .id argument - NULL doesn't work as described

Tags:

r

plyr

The docs for rdply in the plyr package say this about the .id argument:

 .id: name of the index column. Pass ‘NULL’ to avoid creation of
      the index column. For compatibility, omit this argument or
      pass ‘NA’ to avoid converting the index column to a factor;
      in this case, ‘".n"’ is used as colum name..

Unfortunately the described behavior does not seem to work when I pass NULL. Consider:

>rdply(20, mean(runif(20)))
   .n           V1
1   1 0.4202275122
2   2 0.5140590765
3   3 0.4201277295
4   4 0.4082553896
...

Now, I try to get rid of the index column:

> rdply(20, mean(runif(20)),.id=NULL)
Error in if (!is.na(.id)) names(labels) <- .id :
  argument is of length zero
In addition: Warning message:
In is.na(.id) : is.na() applied to non-(list or vector) of type 'NULL'

Question: How do I use the .id argument to avoid creation of the index column, as described in the documentation?

like image 232
Jesse Anderson Avatar asked Sep 08 '14 21:09

Jesse Anderson


1 Answers

Wait until this will be fixed or use name of existing column as .id :

> rdply(20, mean(runif(20)), .id="V1")
       V1
1  0.4804
2  0.6339
3  0.5460
4  0.4473
5  0.4639
6  0.4759
like image 59
Marek Avatar answered Sep 29 '22 02:09

Marek