-
Notifications
You must be signed in to change notification settings - Fork 7
/
practice_dataframes.R
44 lines (19 loc) · 1 KB
/
practice_dataframes.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
# Data Frames 1
# Functions that may be useful:
# names(), nrow(), str(), View(), table(), factor()
# read in the safi data, then do the tasks below
safi <- read.csv("data/SAFI_clean.csv",
na = c("", "NULL", "NA"))
# What are the names of the variables in the data (the columns)
# You can see variable descriptions at: http://www.datacarpentry.org/socialsci-workshop/data/
# How many observations in the data?
# Open the data frame in the viewer
# hint: use the View() function or click on the data in the Environment pane
# What are the types of the variables?
# Make a table of respondent_wall_type to see how many observations for each;
# what do you notice?
# Select just village and no_membrs columns (the latter is number of family members)
# Print just the first row of data
# Drop the instanceID column so it's no longer in the data frame
# select the column respondent_wall_type for just the rows where the village is God
# select rows where no_membrs is between 2 and 5