GithubHelp home page GithubHelp logo

csgillespie / efficientr Goto Github PK

View Code? Open in Web Editor NEW
714.0 48.0 373.0 60.97 MB

Efficient R programming: a book

Home Page: https://csgillespie.github.io/efficientR/

License: Other

TeX 46.72% CSS 4.59% R 40.56% Makefile 1.39% Shell 1.08% C++ 1.35% Rebol 1.77% Dockerfile 2.54%
r book rstats

efficientr's People

Contributors

adamryczkowski avatar alwaysandeep avatar arnoudplantinga avatar bowerth avatar csgillespie avatar dtelad11 avatar ecosang avatar engineerchange avatar jimhester avatar johncassil avatar jonmcalder avatar kkweon avatar kwhkim avatar larspijnappel avatar manuenzi avatar markgoble avatar martenmm avatar mvkorpel avatar rekyt avatar richelbilderbeek avatar robinlovelace avatar shafayetshafee avatar thrkng avatar timcdlucas avatar tktan avatar trinker avatar tscheufen avatar wolfganglederer avatar zegui7 avatar zekiakyol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

efficientr's Issues

Install and update fail

I managed to install the package from the github repos about two weeks ago,
but now, when I try to update or reinstall, I get an error:

installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/efficientR/libs
** data
*** moving datasets to lazyload DB
Warning: file ‘05-f2.RData’ has magic number 'X'
  Use of save versions prior to 2 is deprecated
Error : bad restore file magic number (file may be corrupted) -- no data loaded
ERROR: lazydata failed for package ‘efficientR’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/efficientR’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/efficientR’
Error: Command failed (1)

"Under a proper OS, such as Linux,"

found in "7.2 Cairo type".

While I sympathize and echo the sentiment, prbly best to not directly alienate the 80% of Windows folks who are the main R users out there right in the book (which is why i leave the windows rants to twitter :-)

Totally grok this is a draft and this is a "placeholder/note" but it's also out for the world to see, now.

If you need me to test/validate anything on Macs (i also saw the mac comment), do not hesitate to ask.

LinkingTo: Rcpp

I think you need the line:
LinkingTo: Rcpp
in the DESCRIPTION file to avoid this error:
g++ -I/home/R/R-3.2.4/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c mean_c.cpp -o mean_c.o
mean_c.cpp:1:18: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
when building the package

Rendering problem in section 2.4.3 of online book format

I was reading through the book online at https://csgillespie.github.io/efficientR/ (really great stuff!) and I noticed that the second half of chapter 2 is not rendered in the same font.

It looks like the problem is with escaping the quote symbol in the warning section. Notice the text that shows up:

Specifically, if you use a path that has single backslashes (</code>), such as C:.csv, as provided by Windows

The text does render correctly on github, but the bookdown version isn't escaping it right


Below is an image screenshot:

image

Error after pressing Knit

Hi,

I´ve installed the dependencies, cloned the repo and presss Knit.

But this error message arose:

Error 5977

Error in parse(text = x) : <text>:4:25: unexpected symbol
3: person("Romain", "Francois", , "[email protected]", "aut"),
4: person("Kirill", "M"uller
^
Calls: <Anonymous> ... citation -> .read_authors_at_R_field -> eval -> parse
Ejecuci'on interrumpida

Any hints?

make pdf ...

... throws an error using R 3.2.3:

...
label: voyages-pre (with options)
List of 3
$ echo : logi FALSE
$ results: chr "hide"
$ warning: logi FALSE

Quitting from lines 2930-2941 (_main.Rmd)
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
Calls: ... withVisible -> eval -> eval -> read.delim -> read.table
In addition: Warning message:
In file(file, "rt") :
file("") only supports open = "w+" and open = "w+b": using the former

Execution halted
make: *** [pdf] Error 1

I couldn't find _main.Rmd to check the respective lines

The [@Wickham2014] reference doesn't work in bookdown's custom blocks for pdf output

The reference can be found in the beginning of chapter 3.7.1 "Function closures".

It is a manifestation of the bookdown's issue 117: Treat blocks as markdown. I read that it would be included in the v0.2 of the bookdown, so no fix will be needed. For pdf, a valid LaTeX still can be put, but for some reasons pandoc doesn't use the cite package, but use home-grew solution. So the correct walkaround will be tu put:

(\protect\hyperlink{ref-Wickham2014}{Wickham 2014})

in place of the [@Wickham2014].

Error building book on my system

I expect the problem is on my side if no one else is reporting it, but wonder if you might have any idea why I am receiving the following error when running bookdown::render_book("index.Rmd", bookdown::html_chapters()) after running devtools::install_github("csgillespie/efficientR")

Quitting from lines 17-25 (_main.Rmd) 
Error in eval(expr, envir, enclos) : object 'mychart' not found

Figure in 8.3 (CPU)

y-scale is in MHz but y-axis label says GHz.
I meant fig 8.3 in section 8.6 (CPU)

Assignment operator

I find it peculiar to prefer = over <- as an assignment operator. Sure, Yihui Xie his personal preference is mentioned, but AFAIK no coding standard recommends this.

I copied my collected references about this topic from here to the references section below. Next to this, lintr (of course, that is Hadley's coding standard as well) will complain by default at this. Why not teach beginners (or pro's) the (AFAICS) golden standard, developing their own personal style later?

Just my two cents, I think the idea of your book is awesome!

Reference

  • [1] Google's R Style Guide: Use <-, not =, for assignment
  • [2] 'R Style. An Rchaeological Commentary.' by Paul E. Johnson, February 13, 2015, 3.2 (SEA .95). Use "<-" not "=" for assignments
  • [3] 'R packages' by Hadley Wickham, O'Reilly Media, Inc., 2015, Chapter 3, paragraph 'Assignment': Use <-, not =, for assignments
  • [4] Martin Maechler, Keynote Speech at useR!, 2014, 'Good Practices in R Programming', YouTube, Rule 2: Keep R source well-readable and maintainable

Idea: mention size of each data type, and how integers take up half the space as numerics

Most R programmers don't ever think about how much space data types take, and for small data sets it's not important. But since this is a book specifically about efficient R usage, maybe it's worth mentioning ie. if you have a 100MB matrix of numbers that are in numeric form but they're actually whole numbers, then casting them to int can save you 50MB

file.path

In chapter 2, we go from using file.path

site_path = R.home(component = "home")
fname = file.path(site_path, "etc", "Rprofile.site")
file.exists(fname)

to not using file.path

if(!file.exists("~/.Rprofile")) # only create if not already there
  file.create("~/.Rprofile")    # (don't overwrite it)
file.edit("~/.Rprofile")

We should be consistent. @Robinlovelace Thoughts?

pdf won't build

@Robinlovelace The pdf version of the book won't build (and hence the web version won't get updated). I've narrowed it down to your data carpentry chapter. Would you investigate and fix.

Fails to build on Ubuntu 14.04 64bit

Here is what happened after I do make cleaner and then make pdf:

⏚ [adam:~/tmp/efficientR] master 2s ± make pdf
Rscript -e 'bookdown::render_book("index.Rmd", output_format = "bookdown::pdf_book")'


processing file: _main.Rmd
  |                                                                 |   0%
   inline R code fragments


label: unnamed-chunk-1 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code

  |                                                                 |   1%
label: unnamed-chunk-2 (with options) 
List of 2
 $ echo     : logi FALSE
 $ out.width: chr "33%"


  ordinary text without R code


label: unnamed-chunk-3 (with options) 
List of 2
 $ eval  : logi FALSE
 $ indent: chr "    "

  |.                                                                |   1%
  ordinary text without R code


label: unnamed-chunk-4 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code


label: 1-1 (with options) 
List of 3
 $ echo     : logi FALSE
 $ fig.cap  : chr "The starting position for touch typing, with the fingers over the 'home keys'. Source: [Wikipedia](https://commons.wikimedia.or"| __truncated__
 $ out.width: chr "100%"


  ordinary text without R code

  |.                                                                |   2%
label: unnamed-chunk-5

  ordinary text without R code


label: test-ice (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: 1-2 (with options) 
List of 3
 $ echo     : logi FALSE
 $ fig.cap  : chr "Profiling results of loading and plotting NASA data on icesheet retreat."
 $ out.width: chr "100%"


  ordinary text without R code


label: 1-3 (with options) 
List of 2
 $ echo   : logi FALSE
 $ fig.cap: chr "Visualisation of North Pole icesheet decline, generated using the code profiled using the profvis package."

  |..                                                               |   2%
  ordinary text without R code

  |..                                                               |   3%
label: unnamed-chunk-6 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-7 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-8 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-9 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code

  |..                                                               |   4%
label: unnamed-chunk-10 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-11 (with options) 
List of 1
 $ eval: logi FALSE

  |...                                                              |   4%
  ordinary text without R code


label: assertive.reflection (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-12 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code

  |...                                                              |   5%
label: unnamed-chunk-13 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: 2-1 (with options) 
List of 3
 $ echo     : logi FALSE
 $ fig.cap  : chr "Output from a system monitor (`gnome-system-monitor` running on Ubuntu) showing the resources consumed by running the code pres"| __truncated__
 $ out.width: chr "100%"


  ordinary text without R code


label: unnamed-chunk-14 (with options) 
List of 2
 $ eval  : logi FALSE
 $ indent: chr "    "


  ordinary text without R code


label: timings-tests (with options) 
List of 2
 $ echo: logi FALSE
 $ eval: logi FALSE

  |....                                                             |   5%
  ordinary text without R code

  |....                                                             |   6%
label: packrat (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-15 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "bash"


  ordinary text without R code


label: unnamed-chunk-16 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "bash"


  ordinary text without R code


label: unnamed-chunk-17 (with options) 
List of 2
 $ eval  : logi FALSE
 $ indent: chr "    "


  ordinary text without R code

  |....                                                             |   7%
label: unnamed-chunk-18 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-19 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |.....                                                            |   7%
label: unnamed-chunk-20 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-21 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |.....                                                            |   8%
label: unnamed-chunk-22 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: update-rprofile (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: rstudio-tip (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-23 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "bash"


  ordinary text without R code

  |......                                                           |   9%
label: startup-warn (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-24 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: file.path (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-25 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |......                                                           |  10%
label: pathological (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-26 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |.......                                                          |  10%
label: unnamed-chunk-27 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-28 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |.......                                                          |  11%
label: unnamed-chunk-29 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-30

  ordinary text without R code


label: continuetip (with options) 
List of 2
 $ style : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-31 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |........                                                         |  12%
label: unnamed-chunk-32 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-33

  ordinary text without R code


label: unnamed-chunk-34 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-35 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code

  |........                                                         |  13%
label: unnamed-chunk-36 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-37

  ordinary text without R code


label: unnamed-chunk-38 (with options) 
List of 1
 $ eval: logi FALSE

  |.........                                                        |  13%
  ordinary text without R code


label: unnamed-chunk-39 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |.........                                                        |  14%
label: unnamed-chunk-40 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-41

  ordinary text without R code


label: unnamed-chunk-42

  ordinary text without R code


label: unnamed-chunk-43

  ordinary text without R code

  |.........                                                        |  15%
label: unnamed-chunk-44 (with options) 
List of 1
 $ message: logi FALSE

The following object is masked _by_ .GlobalEnv:

    ht

  |..........                                                       |  15%
  ordinary text without R code


label: unnamed-chunk-45 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-46

  ordinary text without R code


label: unnamed-chunk-47

  ordinary text without R code

  |..........                                                       |  16%
label: unnamed-chunk-48 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-49 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: 2-2 (with options) 
List of 3
 $ fig.cap  : chr "RStudio Panels"
 $ echo     : logi FALSE
 $ out.width: chr "100%"

  |...........                                                      |  16%
  ordinary text without R code


label: unnamed-chunk-50 (with options) 
List of 2
 $ eval  : logi FALSE
 $ indent: chr "    "


  ordinary text without R code

  |...........                                                      |  17%
label: unnamed-chunk-51 (with options) 
List of 1
 $ indent: chr "    "


  ordinary text without R code


label: unnamed-chunk-52 (with options) 
List of 2
 $ echo  : logi FALSE
 $ indent: chr "    "


  ordinary text without R code


label: 2-3 (with options) 
List of 4
 $ echo     : logi FALSE
 $ fig.cap  : chr "The data viewing tab in RStudio."
 $ out.width: chr "100%"
 $ indent   : chr "    "


  ordinary text without R code


label: unnamed-chunk-53 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code

  |...........                                                      |  18%
label: autocompletion (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code

  |............                                                     |  18%
label: unnamed-chunk-54 (with options) 
List of 2
 $ eval: logi FALSE
 $ echo: num 2


  ordinary text without R code


label: unnamed-chunk-55 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-56 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code

  |............                                                     |  19%
label: unnamed-chunk-57 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-58 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: blas-bench (with options) 
List of 6
 $ fig.width : num 6
 $ fig.height: num 4
 $ echo      : logi FALSE
 $ out.width : chr "70%"
 $ fig.align : chr "center"
 $ fig.cap   : chr "Performance gains obtained changing the underlying BLAS library (tests from `benchmark\\_std()`)."

cropping _main_files/figure-latex/blas-bench-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/blas-bench-1.pdf'.

  ordinary text without R code

  |.............                                                    |  19%
label: unnamed-chunk-59 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code

  |.............                                                    |  20%
label: unnamed-chunk-60 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-61 (with options) 
List of 2
 $ eval   : logi TRUE
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-62 (with options) 
List of 1
 $ echo: num 3


  ordinary text without R code


label: bad_loop

  ordinary text without R code

  |.............                                                    |  21%
label: unnamed-chunk-63 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code

  |..............                                                   |  21%
label: unnamed-chunk-64 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-65 (with options) 
List of 2
 $ echo: logi TRUE
 $ tidy: logi FALSE


  ordinary text without R code


label: unnamed-chunk-66 (with options) 
List of 2
 $ echo: logi TRUE
 $ tidy: logi FALSE


  ordinary text without R code

  |..............                                                   |  22%
label: unnamed-chunk-67 (with options) 
List of 2
 $ eval: logi TRUE
 $ echo: logi TRUE


  ordinary text without R code


label: unnamed-chunk-68 (with options) 
List of 2
 $ tidy: logi FALSE
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-69 (with options) 
List of 1
 $ echo: num 2


  ordinary text without R code

  |...............                                                  |  22%
label: unnamed-chunk-70 (with options) 
List of 3
 $ eval: logi FALSE
 $ echo: logi TRUE
 $ tidy: logi FALSE


  ordinary text without R code

  |...............                                                  |  23%
label: unnamed-chunk-71 (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-72 (with options) 
List of 1
 $ eval: logi TRUE


  ordinary text without R code


label: unnamed-chunk-73 (with options) 
List of 1
 $ tidy: logi FALSE


  ordinary text without R code


label: unnamed-chunk-74 (with options) 
List of 1
 $ cache: logi TRUE


  ordinary text without R code

  |...............                                                  |  24%
label: unnamed-chunk-75 (with options) 
List of 1
 $ echo: logi TRUE


  ordinary text without R code


label: 3-1 (with options) 
List of 6
 $ fig.cap   : chr "Example of Monte-Carlo integration. To estimate the area under the curve throw random points at the graph and count the number "| __truncated__
 $ echo      : logi FALSE
 $ fig.width : num 6
 $ fig.height: num 4
 $ fig.align : chr "center"
 $ out.width : chr "70%"

cropping _main_files/figure-latex/3-1-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/3-1-1.pdf'.
  |................                                                 |  24%
  ordinary text without R code


label: unnamed-chunk-76

  ordinary text without R code


label: unnamed-chunk-77

  ordinary text without R code

  |................                                                 |  25%
label: unnamed-chunk-78

  ordinary text without R code


label: unnamed-chunk-79 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-80

  ordinary text without R code


label: unnamed-chunk-81 (with options) 
List of 1
 $ eval: logi FALSE

  |.................                                                |  25%
  ordinary text without R code

  |.................                                                |  26%
label: unnamed-chunk-82 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-83 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-84 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-85

  ordinary text without R code

  |.................                                                |  27%
label: unnamed-chunk-86 (with options) 
List of 2
 $ fig.keep: chr "none"
 $ echo    : num 2


  ordinary text without R code


label: unnamed-chunk-87
  |..................                                               |  27%
  ordinary text without R code


label: unnamed-chunk-88

  ordinary text without R code


label: unnamed-chunk-89 (with options) 
List of 2
 $ fig.keep: chr "none"
 $ echo    : num 6


  ordinary text without R code

  |..................                                               |  28%
label: boxplot_factor (with options) 
List of 2
 $ eval    : logi TRUE
 $ fig.keep: chr "none"


  ordinary text without R code


label: unnamed-chunk-90 (with options) 
List of 1
 $ echo: num 2


  ordinary text without R code


label: unnamed-chunk-91

  ordinary text without R code


label: unnamed-chunk-92 (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"

  |...................                                              |  28%
  ordinary text without R code

  |...................                                              |  29%
label: unnamed-chunk-93

  ordinary text without R code


label: unnamed-chunk-94 (with options) 
List of 2
 $ echo: logi FALSE
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-95 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-96 (with options) 
List of 1
 $ echo: num 2


  ordinary text without R code

  |...................                                              |  30%
label: unnamed-chunk-97

  ordinary text without R code


label: unnamed-chunk-98

  ordinary text without R code

  |....................                                             |  30%
label: unnamed-chunk-99

  ordinary text without R code


label: image_dist_s3

  ordinary text without R code

  |....................                                             |  31%
label: 3-2 (with options) 
List of 5
 $ fig.cap  : chr "S3 image method for data of class `dist`."
 $ echo     : logi FALSE
 $ fig.asp  : num 0.7
 $ fig.width: num 5
 $ fig.align: chr "center"

cropping _main_files/figure-latex/3-2-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/3-2-1.pdf'.

  ordinary text without R code


label: unnamed-chunk-100 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: apply-family (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-101 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code

  |.....................                                            |  32%
label: unnamed-chunk-102 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-103

  ordinary text without R code


label: unnamed-chunk-104

  ordinary text without R code


label: unnamed-chunk-105

  ordinary text without R code

  |.....................                                            |  33%
label: unnamed-chunk-106

  ordinary text without R code


label: 3-3 (with options) 
List of 7
 $ fig.keep  : chr "last"
 $ echo      : language 1:2
 $ fig.height: num 4
 $ fig.width : num 6
 $ fig.cap   : chr "Movie voting preferences."
 $ fig.align : chr "center"
 $ out.width : chr "70%"

cropping _main_files/figure-latex/3-3-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/3-3-1.pdf'.

  ordinary text without R code

  |......................                                           |  33%
label: unnamed-chunk-107 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-108
  |......................                                           |  34%
  ordinary text without R code


label: benchmark_memoise (with options) 
List of 3
 $ fig.keep: chr "none"
 $ cache   : logi TRUE
 $ results : chr "hide"


  ordinary text without R code


label: unnamed-chunk-109 (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-110

  ordinary text without R code


label: unnamed-chunk-111
  |......................                                           |  35%
  ordinary text without R code

  |.......................                                          |  35%
label: unnamed-chunk-112

  ordinary text without R code


label: unnamed-chunk-113

  ordinary text without R code


label: unnamed-chunk-114 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-115
  |.......................                                          |  36%
  ordinary text without R code


label: unnamed-chunk-116

  ordinary text without R code


label: unnamed-chunk-117

  ordinary text without R code


label: unnamed-chunk-118
  |........................                                         |  36%
  ordinary text without R code


label: unnamed-chunk-119
  |........................                                         |  37%
  ordinary text without R code


label: unnamed-chunk-120

  ordinary text without R code


label: unnamed-chunk-121 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-122 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-123
  |........................                                         |  38%
  ordinary text without R code


label: unnamed-chunk-124
  |.........................                                        |  38%
  ordinary text without R code


label: unnamed-chunk-125

  ordinary text without R code


label: unnamed-chunk-126

  ordinary text without R code


label: unnamed-chunk-127 (with options) 
List of 2
 $ results: chr "hide"
 $ eval   : logi FALSE

  |.........................                                        |  39%
  ordinary text without R code


label: 3-4 (with options) 
List of 7
 $ echo      : logi FALSE
 $ fig.height: num 4
 $ fig.width : num 6
 $ fig.cap   : chr "Comparsion of mean functions."
 $ eval      : logi TRUE
 $ fig.align : chr "center"
 $ out.width : chr "70%"

cropping _main_files/figure-latex/3-4-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/3-4-1.pdf'.

  ordinary text without R code


label: unnamed-chunk-128 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-129 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"

  |..........................                                       |  39%
  ordinary text without R code


label: unnamed-chunk-130 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE

  |..........................                                       |  40%
  ordinary text without R code


label: 4-1 (with options) 
List of 6
 $ echo      : logi FALSE
 $ fig.width : num 6
 $ fig.height: num 4
 $ fig.cap   : chr "Schematic illustrations of key project phases and levels of activity over time, based on @PMBoK2000."
 $ out.width : chr "70%"
 $ fig.align : chr "center"

cropping _main_files/figure-latex/4-1-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/4-1-1.pdf'.

  ordinary text without R code


label: 4-2 (with options) 
List of 4
 $ echo     : logi FALSE
 $ fig.cap  : chr "A Gantt chart created using **DiagrammeR** illustrating the steps needed to complete this book at an early stage of its develop"| __truncated__
 $ out.width: chr "80%"
 $ fig.align: chr "center"


  ordinary text without R code


label: unnamed-chunk-131 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-132 (with options) 
List of 2
 $ echo: logi FALSE
 $ eval: logi FALSE

  |..........................                                       |  41%
  ordinary text without R code


label: unnamed-chunk-133
  |...........................                                      |  41%
  ordinary text without R code


label: unnamed-chunk-134

  ordinary text without R code


label: unnamed-chunk-135 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: 4-3 (with options) 
List of 2
 $ echo     : logi FALSE
 $ out.width: chr "25%"

  |...........................                                      |  42%
  ordinary text without R code


label: 4-4 (with options) 
List of 2
 $ echo     : logi FALSE
 $ out.width: chr "25%"


  ordinary text without R code


label: rmd (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: sampleCode (with options) 
List of 1
 $ indent: chr "    "


  ordinary text without R code

  |............................                                     |  42%
label: unnamed-chunk-136
  |............................                                     |  43%
  ordinary text without R code


label: unnamed-chunk-137 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-138 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-139 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: json (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"

  |............................                                     |  44%
  ordinary text without R code


label: unnamed-chunk-140 (with options) 
List of 2
 $ results: chr "hide"
 $ warning: logi FALSE


  ordinary text without R code

  |.............................                                    |  44%
label: unnamed-chunk-141 (with options) 
List of 1
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-142 (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-143 (with options) 
List of 1
 $ echo: language -1:-2

  |.............................                                    |  45%
  ordinary text without R code


label: read-table-csv (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: 5-1 (with options) 
List of 6
 $ fig.cap  : chr "Benchmarks of **base**, **data.table** and **readr** functions for reading csv files. The facets ranging from $2$ to $200$ repr"| __truncated__
 $ echo     : logi FALSE
 $ warning  : logi FALSE
 $ message  : logi FALSE
 $ out.width: chr "90%"
 $ fig.align: chr "center"

cropping _main_files/figure-latex/5-1-1.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `_main_files/figure-latex/5-1-1.pdf'.

  ordinary text without R code


label: unnamed-chunk-144 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code

  |..............................                                   |  45%
label: unnamed-chunk-145 (with options) 
List of 1
 $ cache: logi TRUE

  |..............................                                   |  46%
  ordinary text without R code


label: unnamed-chunk-146 (with options) 
List of 1
 $ cache: logi TRUE


  ordinary text without R code


label: unnamed-chunk-147

  ordinary text without R code


label: unnamed-chunk-148 (with options) 
List of 1
 $ warning: logi FALSE


  ordinary text without R code


label: unnamed-chunk-149 (with options) 
List of 1
 $ warning: logi FALSE


 *** caught segfault ***
address 0x2b1ce00000cb, cause 'memory not mapped'

Here is my sesion info:

Session info --------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.1266)         
 language en_US                       
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-07-29                  

Packages ------------------------------------------------------------------------------------------------------
 package   * version    date       source                                  
 bookdown    0.1.3      2016-07-28 Github (rstudio/bookdown@cbe9f10)       
 devtools    1.12.0     2016-06-24 CRAN (R 3.3.1)                          
 digest      0.6.9      2016-01-08 CRAN (R 3.2.4)                          
 evaluate    0.9        2016-05-28 Github (adamryczkowski/evaluate@a6501ed)
 htmltools   0.3.5      2016-03-21 CRAN (R 3.3.0)                          
 httpuv      1.3.3      2015-08-04 CRAN (R 3.3.1)                          
 magrittr    1.5        2014-11-22 CRAN (R 3.2.0)                          
 memoise     1.0.0      2016-01-29 CRAN (R 3.3.0)                          
 mime        0.5        2016-07-07 cran (@0.5)                             
 miniUI      0.1.1      2016-01-15 cran (@0.1.1)                           
 R6          2.1.2      2016-01-26 CRAN (R 3.3.0)                          
 Rcpp        0.12.6     2016-07-19 cran (@0.12.6)                          
 rmarkdown   1.0.9001   2016-07-29 Github (rstudio/rmarkdown@f7211d5)      
 rsconnect   0.4.3      2016-05-02 cran (@0.4.3)                           
 shiny       0.13.2     2016-03-28 CRAN (R 3.3.1)                          
 stringi     1.1.1      2016-05-27 CRAN (R 3.3.0)                          
 stringr     1.0.0.9000 2016-07-28 Github (hadley/stringr@4cdeb50)         
 withr       1.0.2      2016-06-20 CRAN (R 3.3.1)                          
 xtable      1.8-2      2016-02-05 CRAN (R 3.3.1)                          
 yaml        2.1.13     2014-06-12 CRAN (R 3.3.0)    

I use recent git version: commit 9e7fa96

Author: Colin Gillespie <[email protected]>
Date:   Sun Jul 24 13:33:31 2016 +0100

    Merge pull request #114 from Robinlovelace/R-object-classes

Do you have any ideas what can I do?

Home area

Use Sys.getenv("HOME") not path.expand("~")

extra info about efficiency of `which.max` (if you are interested)

Interestingly, it turns out that which.max is always faster than which(...)[[1]], and starting with N=1000 the difference is one order of magnitude. You might want to include this info and a chart in the Appendix.

data<-matrix(NA,nrow=100,ncol=2)

ns<-exp(seq(from=log(10),to=log(10^6),length.out = 100))

n.rep<-10 #Number of times to generate a test sample. This smooths the chart.

for (i in seq_along(data))
{
  tmp<-matrix(NA,nrow=n.rep,ncol=2)
  for(j in 1:n.rep)
  {
    s<-sample(c(TRUE,FALSE),ns[[i]],TRUE,prob=c(1-0.0001,0.0001))
    tmp[j,]<-summary(microbenchmark(
      which.max(s),
      which(s)[[1]]))[['median']]
  }
  data[i,1]<-mean(tmp[,1])
  data[i,2]<-mean(tmp[,2])
  cat(paste0('.'))
}

data<-cbind(ns,data)

data<-as.data.frame(data)
names(data)<-c('N','which.max','which')

colors <- c("which"="blue","which.max"="grey")
ggplot(data,aes(x=N)) +
  geom_line(aes(y=which.max, color='which.max')) +
  geom_line(aes(y=which,color='which')) +
  scale_x_continuous(labels = comma, trans=log10_trans()) +
  scale_linetype_manual(values='colors',name='Function') +
  scale_y_continuous(labels = comma, trans=log10_trans()) +
  ylab("Execution time") + xlab("Vector size")

Chapter 6

@Robinlovelace

The first part of code doesn't run:

library("tidyr") # Need to load readr package
raw = read_csv("data/pew.csv") # read in the 'wide' dataset

Also

rawt[1:3,]
#> # A tibble: 3 x 3
#>   religion Income Count
#>      <chr>  <chr> <int>
#> 1 Agnostic  <$10k    27
#> 2  Atheist  <$10k    12
#> 3 Buddhist  <$10k    27

Is only tibble data frame when you use read_csv; this impacts the comment in the first rmdnote box.

Book build errors if repos are not set

Just tried to build the book on my new laptop and got:

Installing rio and feather
Installing packages into '/home/robin/R/x86_64-pc-linux-gnu-library/3.3'
(as 'lib' is unspecified)
Quitting from lines 6005-6038 (_main.Rmd) 
Error in contrib.url(repos, type) : 
  trying to use CRAN without setting a mirror
Calls: <Anonymous> ... eval -> eval -> install.packages -> grep -> contrib.url
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
Warning message:
Closing open result set

Not sure what the warnings are but will aim to put in a PR to fix this specific issue based on this: http://stackoverflow.com/questions/17705133/package-error-when-running-r-code-on-command-line

Problem installing dependencies

Hi,

I'm trying to build the book. When I run:

devtools::install_github("csgillespie/efficientR")

I get the following error, after being prompted if I want to install additional tools:

Downloading GitHub repo csgillespie/efficientR@master
from URL https://api.github.com/repos/csgillespie/efficientR/zipball/master
Error: running command '"C:/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD config CC' had status 1

Marcus

Perhaps let people know how long it takes to run the examples

Thanks for writing this book! Enjoying it so far!

In the example here in chapter two, it says to run these exercises:

#1: Create large dataset
X = matrix(rnorm(1e8), nrow = 1e7)
#2: Find the median of each column using a single core
r1 = lapply(X, median)
#3: Find the median of each column using many cores
r2 = parallel::mclapply(X, median) # runs in serial on Windows

However, I stopped running mine after 20 minutes, because I was still running on r1.

Maybe people have more than 16Gb of ram, and maybe there's something up with my computer, but perhaps it might be a better example doesn't take so long to run, or you mention to the users of the book "hey, this takes a while to run, expect around xx minutes".

Again, thanks for writing this book!

Listing dependencies

To avoid constantly updating of index.md, I've parsed the DESCRIPTION file to get a list of CRAN dependencies. However it is no longer displayed in a nice way. @Robinlovelace any ideas of how to display it in a friendlier way?

Add R_DEFAULT_PACKAGES to Renviron

$ R --quiet --vanilla -e "getOption('defaultPackages')"
> getOption('defaultPackages')
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"

$ Rscript --vanilla -e "getOption('defaultPackages')"
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"
$ export R_DEFAULT_PACKAGES=datasets,utils,grDevices,graphics,stats,methods
$ R --quiet --vanilla -e "getOption('defaultPackages')"
> getOption('defaultPackages')
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"

$ Rscript --vanilla -e "getOption('defaultPackages')"
[1] "datasets"  "utils"     "grDevices" "graphics"  "stats"     "methods"

failing to knit

Please tell me where I'm going wrong! thanks.
running win7,
R 3.3.1
rstudio 0.99.903
my final lines of ouput:

  ordinary text without R code

  |..................................................               |  78%
label: unnamed-chunk-247 (with options) 
List of 2
 $ cache  : logi TRUE
 $ results: chr "hide"

C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf:203: warning: overriding commands for target `.m.o'
C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf:196: warning: ignoring old commands for target `.m.o'
C:\PROGRA~2\Gow\bin\make.exe: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x4227d3)
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_2.dll" WIN=64 TCLBIN=64 OBJECTS="file2254380d77b5.o"' had status 255 

Quitting from lines 4637-4638 (_main.Rmd) 
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.
Calls: <Anonymous> ... eval -> eval -> <Anonymous> -> cppFunction -> sourceCpp
Execution halted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.