hello swc bootcamp
play

hello SWC bootcamp Dr. Jennifer (Jenny) Bryan Department of - PowerPoint PPT Presentation

hello SWC bootcamp Dr. Jennifer (Jenny) Bryan Department of Statistics and Michael Smith Laboratories University of British Columbia write code for humans, write data for computers A place for everything and everything in its place


  1. hello SWC bootcamp Dr. Jennifer (Jenny) Bryan Department of Statistics and Michael Smith Laboratories University of British Columbia

  2. write code for humans, write data for computers

  3. A place for everything and everything in its place ≪

  4. source is real ≪

  5. source is real “ The source code is real . The objects are realizations of the source code. Source for EVERY user modified object is placed in a particular directory or directories, for later editing and retrieval.” -- from the Emacs Speaks Statistics (ESS) manual

  6. Names matter

  7. ain’t nothing like the real thing minimize the creation of excerpts and copies of your data ... it will just confuse you later

  8. reshape your data as in real life, it has a tendency to get short and fat, when you’d really prefer tall and skinny

  9. you won’t believe how important this is: what is your working directory? where is the file or executable you need? you need to be fluent with file paths

  10. tough love: get better at typing typos matter case matters th_is is different from th-is spaces in filenames are EVIL you want computer to tedious work for you, right? then you must give precise instructions

  11. a few remarks borrowed from Jonah Duckles’ intro (zero-entry R room)

  12. end sermon

  13. any questions from first tutorial re: basic use of R via RStudio, RStudio projects? you do know that R ≠ RStudio, right? we use RStudio because it makes us happier in our work, but notice that nothing we produce -- no code, no figures, nothing -- requires RStudio to be created, appreciated or reused you should master various ways of sending code from editor to Console so that saving scripts becomes your R Way of Life

  14. weak links in the chain: process, packaging and presentation

  15. I assume your toyline.R script a <- 2 looks similar to this. b <- 7 sigSq <- 0.5 n <- 400 set.seed(1234) x <- runif(n) y <- a + b * x + rnorm(n, sd = sqrt(sigSq)) (avgX <- mean(x)) write(avgX, "results/avgX.txt") pdf("figs/niftyPlot.pdf") plot(x, y) abline(a, b, col = "blue", lwd = 2) dev.off()

  16. It’s great we are saving important things a <- 2 to file with code -- versus letting them b <- 7 cruise by in the Console and/or saving sigSq <- 0.5 n <- 400 via mouse clicks -- but we can do better. set.seed(1234) x <- runif(n) y <- a + b * x + rnorm(n, sd = sqrt(sigSq)) (avgX <- mean(x)) write(avgX, "results/avgX.txt") pdf("figs/niftyPlot.pdf") plot(x, y) abline(a, b, col = "blue", lwd = 2) dev.off()

  17. You did install knitr and its dependencies, as instructed in the set-up tutorial, right? install.packages("knitr", dependencies = TRUE)

  18. You did get an RPubs account, as requested, right?

  19. Edit the script -- more like it was a <- 2 during development, when we were b <- 7 watching results and figures appear on sigSq <- 0.5 n <- 400 the screen. set.seed(1234) x <- runif(n) y <- a + b * x + rnorm(n, sd = sqrt(sigSq)) (avgX <- mean(x)) plot(x, y) abline(a, b, col = "blue", lwd = 2) sessionInfo()

  20. Compile an HTML notebook. Yes this can be accomplished outside of RStudio, using knitr functions at the command line, so we are not creating unhealthy dependency on RStudio.

  21. I just accept all these defaults.

  22. This is where you’ll need that RPubs account.

  23. Seems like a good idea to keep script name and slug same, at least as default. Expect me to give you a naming convention for future STAT 545A coursework.

  24. voilà! http://rpubs.com/jennybc/toyline

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend