From a clean restart in RStudio, I get an error when running tidyr::gather, and I can't see what I'm doing wrong.
Restarting R session...
> library(tidyr)
> example(gather)
gather> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
gather> # From http://stackoverflow.com/questions/1181060
gather> stocks <- data_frame(
gather+ time = as.Date('2009-01-01') + 0:9,
gather+ X = rnorm(10, 0, 1),
gather+ Y = rnorm(10, 0, 2),
gather+ Z = rnorm(10, 0, 4)
gather+ )
gather> gather(stocks, stock, price, -time)
Error in melt_dataframe(data, id_idx - 1L, gather_idx - 1L, as.character(key_col), :
value of 'SET_ATTRIB' must be a pairlist or NULL, not a 'double'
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.4.3 tidyr_0.4.0
loaded via a namespace (and not attached):
[1] colorspace_1.2-6 scales_0.3.0 lazyeval_0.1.10 magrittr_1.5 R6_2.1.2 assertthat_0.1
[7] plyr_1.8.3 parallel_3.2.3 DBI_0.3.1 tools_3.2.3 gtable_0.1.2 Rcpp_0.12.3
[13] ggplot2_2.0.0 grid_3.2.3 munsell_0.4.2
Can you help me find what the error message means? Google hasn't been my friend yet, and I don't recognize this as a known issue on the tidyr github site. My system claims to be up to date.
Thanks,
Bill
UPDATE: The suggestions sounded good, so I started a new session in a directory with no .RData file. Instead of using ESS or RStudio, I started a shell in Emacs and ran R --vanilla. It still fails:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
b:\Path\to\R> R --vanilla
R --vanilla
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library('tidyr')
library('tidyr')
> example('gather')
example('gather')
gather> library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
gather> # From http://stackoverflow.com/questions/1181060
gather> stocks <- data_frame(
gather+ time = as.Date('2009-01-01') + 0:9,
gather+ X = rnorm(10, 0, 1),
gather+ Y = rnorm(10, 0, 2),
gather+ Z = rnorm(10, 0, 4)
gather+ )
gather> gather(stocks, stock, price, -time)
Error in melt_dataframe(data, id_idx - 1L, gather_idx - 1L, as.character(key_col), :
value of 'SET_ATTRIB' must be a pairlist or NULL, not a 'double'
Calls: example ... NextMethod -> gather_.data.frame -> melt_dataframe -> .Call
Execution halted
b:\Path\to\R> sessionInfo()
sessionInfo()
'sessionInfo' is not recognized as an internal or external command,
operable program or batch file.
It works just fine on a Debian system.