This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

  library(tidyverse)
  library(nycflights13)

Problem 1:

  table(filter(flights, month >= 7,  month <= 9)[,"month"])
month
    7     8     9 
29425 29327 27574 
  table(filter(flights, month %in% 7:9)[,"month"])
month
    7     8     9 
29425 29327 27574 
  table(flights[flights$month %in% 7:9, "month"])
month
    7     8     9 
29425 29327 27574 
  
  (dts <- c("2019/02/24 24:00:00", "2019/02/25 00:00:00",
            "2019/02/25 00:00:00.01", "2019/02/24 23:59:59.999999"))
[1] "2019/02/24 24:00:00"        "2019/02/25 00:00:00"       
[3] "2019/02/25 00:00:00.01"     "2019/02/24 23:59:59.999999"
  (dts.posixct <- as.POSIXct(dts))
[1] "2019-02-25 00:00:00 PST" "2019-02-25 00:00:00 PST" "2019-02-25 00:00:00 PST"
[4] "2019-02-24 23:59:59 PST"
  dts.posixct[1] == dts.posixct[2]
[1] TRUE
  dts.posixct[2] - dts.posixct[1]
Time difference of 0 secs
  dts.posixct[3] - dts.posixct[1]
Time difference of 0.00999999 secs
  dts.posixct[3] - dts.posixct[2]
Time difference of 0.00999999 secs
  dts.posixct[2] - dts.posixct[4]
Time difference of 9.536743e-07 secs

Means

  mean(c("a","b","c","d"))
Warning: argument is not numeric or logical: returning NA
[1] NA

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

LS0tDQp0aXRsZTogIlBhZ2UgNDkgSG9tZXdvcmsgQW5zd2VycyINCm91dHB1dDoNCiAgaHRtbF9kb2N1bWVudDoNCiAgICBkZl9wcmludDogcGFnZWQNCi0tLQ0KDQpUaGlzIGlzIGFuIFtSI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