Sources and Structure
September 24, 2024
Thoughts? 😎 💭
unvotes
)unvotes
)read_csv()
function from readr
packagereadr
package is part of the tidyverse
<-
is the assignment operator
#
is the comment operator
library()
and name of library
library(readr)
install.packages("readr")
Use glimpse()
to see the columns and data types:
# load libraries
library(readr)
library(dplyr)
dem_summary <- read_csv("data/dem_summary.csv")
glimpse(dem_summary)
Rows: 6
Columns: 5
$ region <chr> "The West", "Latin America", "Eastern Europe", "Asia", "Afri…
$ polyarchy <dbl> 0.8709230, 0.6371358, 0.5387451, 0.4076602, 0.3934166, 0.245…
$ gdp_pc <dbl> 37.913054, 9.610284, 12.176554, 9.746391, 4.410484, 21.134319
$ flfp <dbl> 52.99082, 48.12645, 50.45894, 50.32171, 56.69530, 26.57872
$ women_rep <dbl> 28.12921, 21.32548, 17.99728, 14.45225, 17.44296, 10.21568
Or use View()
or click on the name of the object in your Environment tab to see the data in a spreadsheet:
05:00
Now try writing the same data to a file with a different name
02:00
read_excel()
to read in the data05:00
googlesheets4
gs4_deauth()
to authenticateread_sheet()
to read in the data05:00
glimpse()
and View()
05:00