In this lab you can use the interactive console to explore or Knit the document. Remember anything you type here can be “sent” to the console with Cmd-Enter (OS-X) or Ctrl-Enter (Windows/Linux) in an R code chunk.
youth
library(readr)
youth = read_csv("http://johnmuschelli.com/intro_to_r/data/Youth_Tobacco_Survey_YTS_Data.csv")
## Parsed with column specification:
## cols(
## .default = col_character(),
## YEAR = col_double(),
## Data_Value = col_double(),
## Data_Value_Std_Err = col_double(),
## Low_Confidence_Limit = col_double(),
## High_Confidence_Limit = col_double(),
## Sample_Size = col_double(),
## DisplayOrder = col_double()
## )
## See spec(...) for full column specifications.
youth
for any problems.problems(youth)
## [1] row col expected actual
## <0 rows> (or 0-length row.names)
stop_for_problems(youth)
readxl
package with the library
command. If it is not installed, install it via: RStudio –> Tools –> Install Packageslibrary(readxl)
Download in the dataset of monuments from: http://johnmuschelli.com/intro_to_r/data/Monuments.xlsx file to Monuments.xlsx
download.file("http://johnmuschelli.com/intro_to_r/data/Monuments.xlsx",
destfile = "Monuments.xlsx",
overwrite = TRUE)
read_excel()
function in the readxl
package to read the Monuments.xlsx
file and call the output mon
.mon = read_excel("Monuments.xlsx")
mon
object as a CSV file calling it “monuments.csv”, using readr::write_csv
:write_csv(mon, "monuments.csv")
mon
object as a RDS file calling it “monuments.rds”, using readr::write_rds
:readr::write_rds(mon, "monuments.rds")