Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying out the reproducible example #9

Open
JT85 opened this issue Apr 15, 2015 · 15 comments
Open

Error when trying out the reproducible example #9

JT85 opened this issue Apr 15, 2015 · 15 comments

Comments

@JT85
Copy link

JT85 commented Apr 15, 2015

I've just installed the latest version of streamgraph (0.7) and get the following error.

ggplot2::movies %>%
select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
tidyr::gather(genre, value, -year) %>%
group_by(year, genre) %>%
tally(wt=value) %>%
ungroup %>%
mutate(year=as.Date(sprintf("%d-01-01", year))) -> dat 

streamgraph(dat, "genre", "n", "year")

Error in expand_(data, dots) : object '.' not found

sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
[6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] streamgraph_0.7   htmltools_0.2.6   htmlwidgets_0.3.2 dplyr_0.4.0      

loaded via a namespace (and not attached):
[1] assertthat_0.1     colorspace_1.2-4   DBI_0.3.1          dichromat_2.0-0    digest_0.6.4       ggplot2_1.0.0      grid_3.1.0         gtable_0.1.2      
 [9] labeling_0.2       lattice_0.20-29    lazyeval_0.1.10    magrittr_1.0.1     MASS_7.3-31        munsell_0.4.2      parallel_3.1.0     plyr_1.8.1        
[17] proto_0.3-10       RColorBrewer_1.0-5 Rcpp_0.11.3        reshape2_1.2.2     RJSONIO_1.0-3      scales_0.2.3       stringr_0.6.2      tidyr_0.2.0       
[25] tools_3.1.0        xts_0.9-7          zoo_1.7-10 
@hrbrmstr
Copy link
Owner

Looks like you missed a library(dplyr)

@JT85
Copy link
Author

JT85 commented Apr 15, 2015

No. Look at the sessionInfo(). It contains dplyr_0.4.0.

@hrbrmstr
Copy link
Owner

That's because streamgraph imports from it. Just tried the full first example (all library calls intact) in an R instance that did not have streamgraph installed and it worked without an issue:

devtools::install_github("hrbrmstr/streamgraph")

library(streamgraph)
library(dplyr)

ggplot2::movies %>%
  select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) -> dat

streamgraph(dat, "genre", "n", "year", interactive=TRUE) %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr")

Does:

data <- read.csv("http://bl.ocks.org/WillTurman/raw/4631136/data.csv", stringsAsFactors=FALSE)
data$date <- as.Date(data$date, format="%m/%d/%y")

streamgraph(data, interactive=TRUE) %>% sg_colors("Reds")

work? If so, it's almost certainly a missing library(dplyr) on your part.

@jpmarindiaz
Copy link

@hrbrmstr I am having some unexpected behavior with the example.
The values in the top left do not change when I move de mouse around, it shows a fixed value for each category, any ideas?

@hrbrmstr
Copy link
Owner

hrbrmstr commented Aug 7, 2015

Which example in particular (can you paste the exact code you are using)?

@jpmarindiaz
Copy link

sorry, it is not working for me at all... not even with the basic example:

library(streamgraph)
library(dplyr)

ggplot2::movies %>%
  select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) -> dat

streamgraph(dat, "genre", "n", "year", interactive=TRUE) %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr")

@hrbrmstr
Copy link
Owner

hrbrmstr commented Aug 7, 2015

can you paste the output of devtools::session_info()? It's working for a
ton of people and I just tried it from the github version on a vanilla
install.

On Thu, Aug 6, 2015 at 9:01 PM, jpmarindiaz notifications@github.com
wrote:

sorry, it is not working for me at all... not even with the basic example:

library(streamgraph)
library(dplyr)

ggplot2::movies %>%
select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
tidyr::gather(genre, value, -year) %>%
group_by(year, genre) %>%
tally(wt=value) -> dat

streamgraph(dat, "genre", "n", "year", interactive=TRUE) %>%
sg_axis_x(20, "year", "%Y") %>%
sg_fill_brewer("PuOr")


Reply to this email directly or view it on GitHub
#9 (comment).

@jpmarindiaz
Copy link

that's weird

Session info ---------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.1 (2015-06-18)
 system   x86_64, darwin13.4.0        
 ui       RStudio (0.99.467)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Bogota              

Packages -------------------------------------------------------------------------------
 package      * version    date       source                                   
 assertthat     0.1        2013-12-06 CRAN (R 3.2.0)                           
 colorspace     1.2-6      2015-03-11 CRAN (R 3.2.0)                           
 curl           0.9.1      2015-07-04 CRAN (R 3.2.0)                           
 DBI            0.3.1      2014-09-24 CRAN (R 3.2.0)                           
 devtools     * 1.8.0      2015-05-09 CRAN (R 3.2.0)                           
 digest         0.6.8      2014-12-31 CRAN (R 3.2.0)                           
 dplyr        * 0.4.2      2015-06-16 CRAN (R 3.2.0)                           
 DT           * 0.1        2015-06-09 CRAN (R 3.2.0)                           
 dygraphs     * 0.4.5      2015-06-11 CRAN (R 3.2.0)                           
 ggplot2      * 1.0.1      2015-03-17 CRAN (R 3.2.0)                           
 git2r          0.10.1     2015-05-07 CRAN (R 3.2.0)                           
 gridExtra      2.0.0      2015-07-14 CRAN (R 3.2.0)                           
 gtable         0.1.2      2012-12-05 CRAN (R 3.2.0)                           
 htmltools    * 0.2.6      2014-09-08 CRAN (R 3.2.0)                           
 htmlwidgets  * 0.5        2015-06-21 CRAN (R 3.2.0)                           
 jsonlite       0.9.16     2015-04-11 CRAN (R 3.2.0)                           
 lattice        0.20-31    2015-03-30 CRAN (R 3.2.1)                           
 lazyeval       0.1.10     2015-01-02 CRAN (R 3.2.0)                           
 leaflet      * 1.0.0.9999 2015-08-07 Github (rstudio/leaflet@451fc78)         
 magrittr       1.5        2014-11-22 CRAN (R 3.2.0)                           
 MASS           7.3-40     2015-03-21 CRAN (R 3.2.1)                           
 memoise        0.2.1      2014-04-22 CRAN (R 3.2.0)                           
 munsell        0.4.2      2013-07-11 CRAN (R 3.2.0)                           
 plyr         * 1.8.3      2015-06-12 CRAN (R 3.2.0)                           
 proto          0.3-10     2012-12-22 CRAN (R 3.2.0)                           
 R6             2.1.0      2015-07-04 CRAN (R 3.2.1)                           
 rcdimple     * 0.1        2015-07-28 Github (timelyportfolio/rcdimple@e91c020)
 RColorBrewer * 1.1-2      2014-12-07 CRAN (R 3.2.0)                           
 Rcpp           0.12.0     2015-07-25 CRAN (R 3.2.0)                           
 reshape2     * 1.4.1      2014-12-06 CRAN (R 3.2.0)                           
 rgdal        * 1.0-4      2015-06-23 CRAN (R 3.2.0)                           
 roxygen2       4.1.1      2015-04-15 CRAN (R 3.2.0)                           
 rstudioapi     0.3.1      2015-04-07 CRAN (R 3.2.0)                           
 rversions      1.0.2      2015-07-13 CRAN (R 3.2.0)                           
 scales       * 0.2.5      2015-06-12 CRAN (R 3.2.0)                           
 sp           * 1.1-1      2015-06-05 CRAN (R 3.2.0)                           
 streamgraph  * 0.7        2015-08-07 Github (hrbrmstr/streamgraph@e84109a)    
 stringi        0.5-5      2015-06-29 CRAN (R 3.2.0)                           
 stringr        1.0.0      2015-04-30 CRAN (R 3.2.0)                           
 tidyr        * 0.2.0      2014-12-05 CRAN (R 3.2.0)                           
 waffle       * 0.3.1      2015-03-23 CRAN (R 3.2.0)                           
 whisker      * 0.3-2      2013-04-28 CRAN (R 3.2.0)                           
 xml2           0.1.1      2015-06-02 CRAN (R 3.2.0)                           
 xts          * 0.9-7      2014-01-02 CRAN (R 3.2.0)                           
 yaml         * 2.1.13     2014-06-12 CRAN (R 3.2.0)                           
 zoo          * 1.7-12     2015-03-16 CRAN (R 3.2.0)  

@hrbrmstr
Copy link
Owner

hrbrmstr commented Aug 7, 2015

try devtools::install_github("hrbrmstr/streamgraph@dev"), restart R and try the example again (pls)

@jpmarindiaz
Copy link

Thanks, it is working!

But now, when I try to pass the names of the columns as variables I get an error:

library(streamgraph)
# current verison
packageVersion("streamgraph")

library(dplyr)
ggplot2::movies %>%
  select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) -> dat

streamgraph(dat, "genre", "n", "year", interactive=TRUE) %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr")
# OK

y <- names(dat)[1]
streamgraph(dat, "genre", "n", y, interactive=TRUE) %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr")
# ERROR
# Error in `[.data.frame`(data, , c(key, value, date)) :
#   undefined columns selected

@ShawnyTan
Copy link

@hrbrmstr Thanks for this fantastic resource. I got a problem when I tried this example:
`library(dplyr)
library(babynames)
library(streamgraph)

babynames %>%
filter(grepl("^Kr", name)) %>%
group_by(year, name) %>%
tally(wt=n) %>%
streamgraph("name", "n", "year")`

The error I got is
Error in [.data.frame(data, , c(key, value, date)) :
undefined columns selected

You have any idea about this? Thanks!

@hrbrmstr
Copy link
Owner

hrbrmstr commented Feb 27, 2017 via email

@ShawnyTan
Copy link

Oh it works! Thanks a lot! But I don't quite understand the error. How do I generalize this adaption to my case?

@ShawnyTan
Copy link

I got it. Just do streamgraph(dat,"X","n","Y")
Thanks!

@hrbrmstr
Copy link
Owner

aye. tally() won't overwrite n it just keeps adding n's to n column names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@hrbrmstr @jpmarindiaz @JT85 @ShawnyTan and others