Error message when running simple 'rename' function

4.1k views Asked by At

Not sure why this simple rename function is not working. I kept having this error message: Error: All arguments to rename must be named. I searched the web, some people are having issues with the rename function while using the dplyr package. I am not using dplyr but plyr package only. Any idea how to fix this?

library(plyr)
df <- data.frame(V1=1:3, B=4:6, C=7:9)
df
SIM.data.bystudy.median <- rename(df, c("V1"="medianS")) 
# Error: All arguments to rename must be named.

The output to the sessionInfo() is this:

R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] parallel  grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] doBy_4.5-13      survival_2.38-1  stringr_0.6.2    dplyr_0.4.2      data.table_1.9.4 doParallel_1.0.8 iterators_1.0.7  foreach_1.4.2   
 [9] scales_0.2.4     reshape2_1.4.1   plyr_1.8.1       ggplot2_1.0.1    shiny_0.11.1    

loaded via a namespace (and not attached):
 [1] assertthat_0.1     chron_2.3-45       codetools_0.2-10   colorspace_1.2-6   DBI_0.3.1          digest_0.6.8       gtable_0.1.2      
 [8] htmltools_0.2.6    httpuv_1.3.2       labeling_0.3       lattice_0.20-30    lazyeval_0.1.10    magrittr_1.5       MASS_7.3-39       
[15] Matrix_1.1-5       mime_0.3           munsell_0.4.2      proto_0.3-10       R6_2.0.1           RColorBrewer_1.1-2 Rcpp_0.11.5       
[22] RJSONIO_1.3-0      splines_3.1.3      tools_3.1.3        xtable_1.7-4   
0

There are 0 answers