hadley / ggplot2-book

ggplot2: elegant graphics for data analysis
https://ggplot2-book.org/
1.57k stars 683 forks source link

Package missing, and 'binwidth = x' error #47

Closed jpearl01 closed 9 years ago

jpearl01 commented 9 years ago

Hi guys,

A couple of things, first thanks for posting this, it's great to have a resource like this available for the latest version of ggplot2.

I ran into a couple of issues when trying to make this project on a Fedora 21 workstation machine. First, the package 'readr' was not in the list of R packages to install in the readme.md.

Next, ran into this error which I can't figure out: stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this. Quitting from lines 112-120 (toolbox.rmd) Error: arguments imply differing number of rows: 133, 102 In addition: Warning messages: 1: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect 2: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect 3: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect 4: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect Execution halted Makefile:32: recipe for target 'book/tex/toolbox.tex' failed make: *\ [book/tex/toolbox.tex] Error 1

Also, it would be pretty handy if in the readme there was also an indication that pandoc and pandoc-citeproc were pre-reqs

Thanks, ~josh

cpsievert commented 9 years ago

Thanks, I'll add readr to the package lists and a note about pandoc

As for the error, could you make sure your packages are up to date with CRAN and try again?

update.packages(checkBuilt = T, ask = F) 

After updating, it's probably best to build from scratch:

make clean
make
jpearl01 commented 9 years ago

No dice, still getting the same error after updating, make clean and make

jpearl01 commented 9 years ago

fyi it appears to specifically be with this command: depth_dist + geom_histogram(aes(y = ..density..), binwidth = 0.1) + facet_grid(cut ~ .)

Error: arguments imply differing number of rows: 133, 102 In addition: Warning messages: 1: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect 2: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect 3: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect

cpsievert commented 9 years ago

Huh, I haven't been able to replicate that error locally or on Travis, could you run the following and share the output?

library("ggplot2")
library("dplyr")
depth_dist <- ggplot(diamonds, aes(depth)) + xlim(58, 68)
depth_dist + 
  geom_histogram(aes(y = ..density..), binwidth = 0.1) +
  facet_grid(cut ~ .)
devtools::session_info()
jpearl01 commented 9 years ago

Sure:

library("ggplot2") library("dplyr")

Attaching package: ‘dplyr’

The following object is masked from ‘package:stats’:

filter

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

depth_dist <- ggplot(diamonds, aes(depth)) + xlim(58, 68) depth_dist +

  • geom_histogram(aes(y = ..density..), binwidth = 0.1) +
  • facet_grid(cut ~ .) Error: subscript out of bounds In addition: Warning message: In loop_apply(n, do.ply) : position_stack requires constant width: output may be incorrect devtools::session_info() Session info -------------------------------------------------- setting value
    version R version 3.1.3 (2015-03-09) system x86_64, linux-gnu
    ui RStudio (0.98.1103)
    language (EN)
    collate en_US.UTF-8
    tz America/New_York

Packages ------------------------------------------------------ package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.1.3) bitops 1.0-6 2013-08-17 CRAN (R 3.1.3) colorspace 1.2-6 2015-03-11 CRAN (R 3.1.3) DBI 0.3.1 2014-09-24 CRAN (R 3.1.3) devtools 1.8.0 2015-05-09 CRAN (R 3.1.3) digest 0.6.8 2014-12-31 CRAN (R 3.1.3) dplyr * 0.4.1 2015-01-14 CRAN (R 3.1.3) ggplot2 * 1.0.1 2015-03-17 CRAN (R 3.1.3) git2r 0.10.1 2015-05-07 CRAN (R 3.1.3) gtable 0.1.2 2012-12-05 CRAN (R 3.1.3) labeling 0.3 2014-08-23 CRAN (R 3.1.3) magrittr 1.5 2014-11-22 CRAN (R 3.1.3) MASS 7.3-40 2015-03-21 CRAN (R 3.1.3) memoise 0.2.1 2014-04-22 CRAN (R 3.1.3) munsell 0.4.2 2013-07-11 CRAN (R 3.1.3) plyr 1.8.2 2015-04-21 CRAN (R 3.1.3) proto 0.3-10 2012-12-22 CRAN (R 3.1.3) Rcpp 0.11.6 2015-05-01 CRAN (R 3.1.3) RCurl 1.95-4.6 2015-04-24 CRAN (R 3.1.3) reshape2 1.4.1 2014-12-06 CRAN (R 3.1.3) rversions 1.0.0 2015-04-22 CRAN (R 3.1.3) scales 0.2.4 2014-04-22 CRAN (R 3.1.3) stringi 0.4-1 2014-12-14 CRAN (R 3.1.3) stringr 1.0.0 2015-04-30 CRAN (R 3.1.3) XML 3.98-1.1 2013-06-20 CRAN (R 3.1.3) yaml 2.1.13 2014-06-12 CRAN (R 3.1.3)

cpsievert commented 9 years ago

Hmm, I'm on R 3.2.0, but that might be considered a ggplot2 bug. Could you please report to https://github.com/hadley/ggplot2 ?

BTW, if you just want to get the book to compile, you could comment out that part for now...

jpearl01 commented 9 years ago

Yeah, I had the same idea about commenting out the problematic area, but then I ran into another problem(s)... I'm not sure exactly where the real problem begins, but I think this is the first error:

! LaTeX Error: File `upquote.sty' not found

Type X to quit or to proceed, or enter a new name. (Default extension: sty)

I hit enter, and several more files pop up with the same message, and I hit enter on those as well. Then a boatload of warnings come up from LaTeX, until I get to something that says

! Undefined control sequence. l.639 \subfigure [Subplot tweaked for better display.]{ ?

Where the '?' seems to be some kind of prompt, hitting enter gets it to go away, but it happens again a few times (these are interspersed with LaTeX warnings.. and I'm unfamiliar with it, so I can't really parse if any are actually important or not..) Ultimately I get to

Output written on ggplot2-book.pdf (237 pages). Transcript written on ggplot2-book.log. Makefile:13: recipe for target 'book/text/ggplot2-book.pdf ' failed make: *\ [book/tex/ggplot2-book.pdf] Error 1

I have all the output of the whole thing in a file I could send if that would be helpful. But it generates a pdf which is pretty much blank.

I'll report the bug to ggplot2 in the meantime.

hadley commented 9 years ago

I think the fact that it can't find upquote.sty suggests that maybe you have an old tex install?

cpsievert commented 9 years ago

Another common gotcha is that hyperref needs to be 6.83a or lower -> https://github.com/hadley/ggplot2-book/blob/90987f445e6614b798f381044cad86a149d6cd85/.travis.yml#L12-L13

jpearl01 commented 9 years ago

That could be... I have only passing knowledge of LaTeX, but this is the repository's info on the one I have installed: Installed Packages Name : texlive-latex Arch : noarch Epoch : 4 Version : svn32901.0 Release : 3.1.fc21 Size : 1.1 M Repo : installed From repo : updates Summary : A TeX macro package that defines LaTeX

I'll look into the hyperref req

jpearl01 commented 9 years ago

Ok, I definitely have a later version of hyperref. Not sure how to replace that just yet, but I'll see if there is some way of downgrading...

jpearl01 commented 9 years ago

Whew, ok for future Fedora 21 users: Comment out these lines in the toolbox.rmd file:

depth_dist <- ggplot(diamonds, aes(depth)) + xlim(58, 68) depth_dist + geom_histogram(aes(y = ..density..), binwidth = 0.1) + facet_grid(cut ~ .) depth_dist + geom_histogram(aes(fill = cut), binwidth = 0.1, position = "fill") depth_dist + geom_freqpoly(aes(y = ..density.., colour = cut), binwidth = 0.1)

Make sure you have latex installed (which is in the repositories: yum install texlive-latex) Then, you have to downgrade the hyperref package in latex to 6.83a You can download that here: ftp://download.gnu.org.ua/pub/release/hyperref/ and then follow these directions to replace the hyperref already installed: http://mirror.utexas.edu/ctan/macros/latex/contrib/hyperref/README

Then if you get errors that a .sty package is missing you can find out which yum install will provide it by searching similar to this:

$ yum provides */upquote.sty

I had to install these packages:

$ sudo yum install texlive-emptypage texlive-appendix texlive-subfigure texlive-upquote

You also may need to run this when installing LatTeX (as this is how I did it, and I don't know if there are packages which were required here that I never saw errors for because I already had them)

$ sudo yum install texlive texlive-latex texlive-xetex texlive-collection-latex texlive-collection-latexrecommended texlive-xetex-def texlive-collection-xetex

After that, it finally built!