diff --git a/02_RProgramming/Dates/DatesTimes.pdf b/02_RProgramming/Dates/Dates.pdf similarity index 62% rename from 02_RProgramming/Dates/DatesTimes.pdf rename to 02_RProgramming/Dates/Dates.pdf index 8ab0982ca..e1c135458 100644 Binary files a/02_RProgramming/Dates/DatesTimes.pdf and b/02_RProgramming/Dates/Dates.pdf differ diff --git a/02_RProgramming/Dates/index.Rmd b/02_RProgramming/Dates/index.Rmd index fff705469..d435714c4 100644 --- a/02_RProgramming/Dates/index.Rmd +++ b/02_RProgramming/Dates/index.Rmd @@ -8,7 +8,7 @@ framework : io2012 # {io2012, html5slides, shower, dzslides, ...} highlighter : highlight.js # {highlight.js, prettify, highlight} hitheme : tomorrow # url: - lib: ../../libraries + lib: ../../librariesNew assets: ../../assets widgets : [mathjax] # {mathjax, quiz, bootstrap} mode : selfcontained # {standalone, draft} @@ -92,15 +92,14 @@ p$sec ## Times in R -Finally, there is the `strptime` function in case your dates are written in a different format +Finally, there is the `strptime` function in case your dates are +written in a different format -```r -datestring <- c("January 10, 2012 10:40", "December 9, 2011 +```{r} +datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10") x <- strptime(datestring, "%B %d, %Y %H:%M") x -## [1] "2012-01-10 10:40:00" "2011-12-09 09:10:00" class(x) -## [1] "POSIXlt" "POSIXt" ``` I can _never_ remember the formatting strings. Check `?strptime` for details. diff --git a/02_RProgramming/Dates/index.html b/02_RProgramming/Dates/index.html index b0fe8124f..c3d93923d 100644 --- a/02_RProgramming/Dates/index.html +++ b/02_RProgramming/Dates/index.html @@ -8,51 +8,46 @@ - - + - - - - + + - - - - - - - + - + + +
+

Dates and Times in R

+

+

Roger D. Peng, Associate Professor of Biostatistics
Johns Hopkins Bloomberg School of Public Health

+
+
+
- - - - -
-

Dates and Times in R

-

-

Roger D. Peng, Associate Professor of Biostatistics
Johns Hopkins Bloomberg School of Public Health

-
-
- - +

Dates and Times in R

-
+

R has developed a special representation of dates and times

    @@ -66,11 +61,11 @@

    Dates and Times in R

    - +

    Dates in R

    -
    +

    Dates are represented by the Date class and can be coerced from a character string using the as.Date() function.

    x <- as.Date("1970-01-01")
    @@ -86,11 +81,11 @@ 

    Dates in R

    - +

    Times in R

    -
    +

    Times are represented using the POSIXct or the POSIXlt class

      @@ -110,11 +105,11 @@

      Times in R

      - +

      Times in R

      -
      +

      Times can be coerced from a character string using the as.POSIXlt or as.POSIXct function.

      x <- Sys.time()
      @@ -132,11 +127,11 @@ 

      Times in R

      - +

      Times in R

      -
      +

      You can also use the POSIXct format.

      x <- Sys.time()
      @@ -155,19 +150,26 @@ 

      Times in R

      - +

      Times in R

      -
      -

      Finally, there is the strptime function in case your dates are written in a different format

      +
      +

      Finally, there is the strptime function in case your dates are +written in a different format

      -
      datestring <- c("January 10, 2012 10:40", "December 9, 2011
      +
      datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10")
       x <- strptime(datestring, "%B %d, %Y %H:%M")
       x
      -## [1] "2012-01-10 10:40:00" "2011-12-09 09:10:00"
      -class(x)
      -## [1] "POSIXlt" "POSIXt"
      +
      + +
      ## [1] "2012-01-10 10:40:00 EST" "2011-12-09 09:10:00 EST"
      +
      + +
      class(x)
      +
      + +
      ## [1] "POSIXlt" "POSIXt"
       

      I can never remember the formatting strings. Check ?strptime for details.

      @@ -176,11 +178,11 @@

      Times in R

      - +

      Operations on Dates and Times

      -
      +

      You can use mathematical operations on dates and times. Well, really just + and -. You can do comparisons too (i.e. ==, <=)

      x <- as.Date("2012-01-01")
      @@ -198,11 +200,11 @@ 

      Operations on Dates and Times

      - +

      Operations on Dates and Times

      -
      +

      Even keeps track of leap years, leap seconds, daylight savings, and time zones.

      x <- as.Date("2012-03-01") y <- as.Date("2012-02-28") 
      @@ -218,11 +220,11 @@ 

      Operations on Dates and Times

      - +

      Summary

      -
      +
      • Dates and times have special classes in R that allow for numerical and statistical calculations
      • Dates use the Date class
      • @@ -236,34 +238,89 @@

        Summary

        - - - - - - - - - - - + + + - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/02_RProgramming/Dates/index.md b/02_RProgramming/Dates/index.md index fff705469..5e6c6789c 100644 --- a/02_RProgramming/Dates/index.md +++ b/02_RProgramming/Dates/index.md @@ -8,7 +8,7 @@ framework : io2012 # {io2012, html5slides, shower, dzslides, ...} highlighter : highlight.js # {highlight.js, prettify, highlight} hitheme : tomorrow # url: - lib: ../../libraries + lib: ../../librariesNew assets: ../../assets widgets : [mathjax] # {mathjax, quiz, bootstrap} mode : selfcontained # {standalone, draft} @@ -92,14 +92,25 @@ p$sec ## Times in R -Finally, there is the `strptime` function in case your dates are written in a different format +Finally, there is the `strptime` function in case your dates are +written in a different format + ```r -datestring <- c("January 10, 2012 10:40", "December 9, 2011 +datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10") x <- strptime(datestring, "%B %d, %Y %H:%M") x -## [1] "2012-01-10 10:40:00" "2011-12-09 09:10:00" +``` + +``` +## [1] "2012-01-10 10:40:00 EST" "2011-12-09 09:10:00 EST" +``` + +```r class(x) +``` + +``` ## [1] "POSIXlt" "POSIXt" ``` I can _never_ remember the formatting strings. Check `?strptime` for details. diff --git a/02_RProgramming/Dates/slides/datetime_slide01.png b/02_RProgramming/Dates/slides/datetime_slide01.png index 5de9e7587..a9ab292db 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide01.png and b/02_RProgramming/Dates/slides/datetime_slide01.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide02.png b/02_RProgramming/Dates/slides/datetime_slide02.png index da030098f..a008dffec 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide02.png and b/02_RProgramming/Dates/slides/datetime_slide02.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide03.png b/02_RProgramming/Dates/slides/datetime_slide03.png index e5820f3e4..a542ecd3c 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide03.png and b/02_RProgramming/Dates/slides/datetime_slide03.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide04.png b/02_RProgramming/Dates/slides/datetime_slide04.png index 6822f157b..9ad7c1484 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide04.png and b/02_RProgramming/Dates/slides/datetime_slide04.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide05.png b/02_RProgramming/Dates/slides/datetime_slide05.png index ce312f427..f34296cf8 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide05.png and b/02_RProgramming/Dates/slides/datetime_slide05.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide06.png b/02_RProgramming/Dates/slides/datetime_slide06.png index b34bb0510..f1912344d 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide06.png and b/02_RProgramming/Dates/slides/datetime_slide06.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide07.png b/02_RProgramming/Dates/slides/datetime_slide07.png index d08186b25..4780feb3e 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide07.png and b/02_RProgramming/Dates/slides/datetime_slide07.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide08.png b/02_RProgramming/Dates/slides/datetime_slide08.png index d0c0de647..8b6774ca4 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide08.png and b/02_RProgramming/Dates/slides/datetime_slide08.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide09.png b/02_RProgramming/Dates/slides/datetime_slide09.png index f25e62cb8..c79060797 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide09.png and b/02_RProgramming/Dates/slides/datetime_slide09.png differ diff --git a/02_RProgramming/Dates/slides/datetime_slide10.png b/02_RProgramming/Dates/slides/datetime_slide10.png index e7bd86141..262d4681f 100644 Binary files a/02_RProgramming/Dates/slides/datetime_slide10.png and b/02_RProgramming/Dates/slides/datetime_slide10.png differ diff --git a/02_RProgramming/profiler/Profiling R Code.pdf b/02_RProgramming/profiler/Profiling R Code.pdf new file mode 100644 index 000000000..f71c720b0 Binary files /dev/null and b/02_RProgramming/profiler/Profiling R Code.pdf differ diff --git a/04_ExploratoryAnalysis/PlottingSystems/Plotting Systems in R.pdf b/04_ExploratoryAnalysis/PlottingSystems/Plotting Systems in R.pdf new file mode 100644 index 000000000..2e961f051 Binary files /dev/null and b/04_ExploratoryAnalysis/PlottingSystems/Plotting Systems in R.pdf differ diff --git a/04_ExploratoryAnalysis/exploratoryGraphs/PM25data.zip b/04_ExploratoryAnalysis/exploratoryGraphs/PM25data.zip new file mode 100644 index 000000000..bba3a4045 Binary files /dev/null and b/04_ExploratoryAnalysis/exploratoryGraphs/PM25data.zip differ diff --git a/05_ReproducibleResearch/Checklist/Reproducible Research Checklist.pdf b/05_ReproducibleResearch/Checklist/Reproducible Research Checklist.pdf new file mode 100644 index 000000000..7fb627ba1 Binary files /dev/null and b/05_ReproducibleResearch/Checklist/Reproducible Research Checklist.pdf differ diff --git a/09_DevelopingDataProducts/yhat/AP_example.R b/09_DevelopingDataProducts/yhat/AP_example.R index 2b3667f3b..5fff44bd8 100644 --- a/09_DevelopingDataProducts/yhat/AP_example.R +++ b/09_DevelopingDataProducts/yhat/AP_example.R @@ -58,7 +58,7 @@ model.predict <- function(df) { yhat.config <- c( username="rdpeng@gmail.com", apikey="90d2a80bb532cabb2387aa51ac4553cc", - env="http://sandbox.yhathq.com/" + env="http://cloud.yhathq.com/" ) yhat.deploy("pollutant") @@ -76,4 +76,5 @@ yhat.config <- c( ) df <- data.frame(lon = c(-76.6167, -118.25), lat = c(39.2833, 34.05), radius = 20) +df <- data.frame(lon = -76.6167, lat = 39.2833, radius = 50) yhat.predict("pollutant", df)