-
Notifications
You must be signed in to change notification settings - Fork 0
/
1. AK Workshop Participant File Answer Key.R
85 lines (37 loc) · 1.34 KB
/
1. AK Workshop Participant File Answer Key.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
## Exploratory Data Analysis:
## investigate the structure with str()
str(Census2020)
## see the columns of the dataframe and display a portion with glimpse()
glimpse(Census2020)
## explore the dimensions of the dataframe with dim()
dim(Census2020)
## look up the top and bottom rows of the dataset, with head() and tail()
head(Census2020)
tail(Census2020)
## display the column names with colnames() and names(), note the difference in return format
colnames(Census2020)
names(Census2020)
## row names
rownames(Census2020)
## explore the largest and smallest value of a column with min() and max()
min(Census2020$`2020 Census Resident Population`)
max(Census2020$`2020 Census Resident Population`)
## display the summary statistics with summary(), call the whole dataframe and one column
summary(Census2020)
## open the complete dataset in a new window with View()
View(Census2020)
## to identify a column within the dataset: df$colname
Census2020$State
Census2020$Pop
Census2020$year
## to identify an exact position within the dataset: df[row,col]
Census2020[1,]
Census2020[,1]
Census2020[1,1]
Census2020[1,1:3]
Census2020[1:3,1:3]
## use the assignment operator to assign values/store data to an object: <-
CensusAL <- Census2020[1,1:3]
CensusCA <- Census2020[5, 1:3]
CensusPop <- Census2020[,2]
USPop <- sum(CensusPop)