-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_tabulate.log
56 lines (49 loc) · 1.96 KB
/
2_tabulate.log
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
R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
> library(data.table)
Warning message:
package ‘data.table’ was built under R version 3.2.5
>
> load("homeown_race_sex.Rdata")
>
> d[ , URBAN := factor(URBAN, levels=c(1,2),
+ labels=c("Rural", "Urban"))]
> d[ , FARM := factor(FARM, levels=c(1,2),
+ labels=c("Non-Farm", "Farm"))]
> d[ , OWNERSHP := factor(OWNERSHP, levels=c(1,2),
+ labels=c("Owned or being bought (loan)",
+ "Rented"))]
> d[ , FREE_AND_CLEAR := MORTGAGE == 1]
> d[ , SEX := factor(SEX, levels=c(1,2),
+ labels=c("Male", "Female"))]
> d[ , RACE := factor(RACE, levels=1:9,
+ labels=c("White", "Black/Negro",
+ "American Indian or Alaska Native",
+ "Chinese", "Japanese",
+ "Other Asian or Pacific Islander",
+ "Other race, nec", "Two major races",
+ "Three or more major races"))]
>
> setkey(d, YEAR, RACE, SEX, URBAN, FARM, STATEFIP)
>
> out <- d[ , .(own=sum(PERWT*(OWNERSHP=="Owned or being bought (loan)"), na.rm=TRUE),
+ free_and_clear=sum(PERWT*FREE_AND_CLEAR, na.rm=TRUE),
+ group_n=sum(PERWT)), by=key(d)]
>
> write.csv(out, "homeownership_by_race_sex_urban_farm.csv", row.names=FALSE)
>
> proc.time()
user system elapsed
66.459 3.245 70.130