-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_script_data_import.R
63 lines (49 loc) · 1.96 KB
/
example_script_data_import.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#install.packages("googledrive")
library("googledrive")
setwd("~/Downloads")
## Second, download the Rda files from the shared Google Drive:
url_DS0001 = "https://drive.google.com/file/d/1yw_6RSxSFlOenZrvUpjG-CGbrzXLQB_J/view?usp=sharing"
drive_download(url_DS0001)
url_DS0002 = "https://drive.google.com/file/d/1FbQlPctKWaoY3m3mYYY7Iz18meaPDNyx/view?usp=sharing"
drive_download(url_DS0002)
url_DS0003 = "https://drive.google.com/file/d/1PZ59yUC1l30VtU153Qlp7V_WwO-nbyga/view?usp=sharing"
drive_download(url_DS0003)
url_DS0004 = "https://drive.google.com/file/d/1tQC-nMYFV_9g9CDkdc6RHDJRmliko7Rn/view?usp=sharing"
drive_download(url_DS0004)
url_DS0005 = "https://drive.google.com/file/d/19J-7vRhgZDA7Ma9s6_aPWjalc_P1RMRh/view?usp=sharing"
drive_download(url_DS0005)
## Third, load the rda files that were saved locally:
load(file="38090-0001-Data.rda")
load(file="38090-0002-Data.rda")
load(file="38090-0003-Data.rda")
load(file="38090-0004-Data.rda")
load(file="38090-0005-Data.rda")
## Give the data files better names
dat1 <- da38090.0001
dat2 <- da38090.0002
dat3 <- da38090.0003
dat4 <- da38090.0004
dat5 <- da38090.0005
## Here's some examples of variables that may be of interst:
names(dat2)
# V2025B # HH bldng with restricted access
summary(dat2$V2026) # household income
summary(dat2$V2031) # race of household head
summary(dat2$V2045) # reference person sex
summary(dat2$V2049A) # reference person race
summary(dat2$V2120) # public housing
summary(dat2$V2122) # family structure
summary(dat3$V3017) # sex
summary(dat3$V3023A) # race
summary(dat3$V3081) # # of crimes
summary(dat3$V3086) # gender identity
summary(dat3$V3084) # sex orientation
summary(dat3$V3034) # theft
summary(dat3$V3040) # theft attack or threat
summary(dat3$V3042) # attack treat weapon
library(tidyverse)
dat2 %>% select(V2021, V2026, V2073, V2076) %>%
drop_na() %>%
filter((V2021=="(05) Mbl hme/trlr no rm")|
(V2021=="(06) Mbl hme/trlr room")) %>% dim
summary(dat2$V2021)