Using the .csv version of the data you read in,
1. Subset the data to remove all missing values.
(a) How many observations does the subsetted data have now?
(b) Why is there a difference between the number of observations in the original and the subsetted
data?
2. Using the original version of the data, subset the data so that it only contains mths and scien. Use
the head() function to check if you were successful.
3. Using the original version of the data, subset the data so that it only contains the first seven variables.
Use the head() function to check if you were successful.
4. Using the original version of the data, subset the data so that it only contains the first seven variables
and mths and scien. Use the head() function to check if you were successful.
1.
mcs.omit <- na.omit(mcs1)
1.a The new data has 7756 observations.
1.b The reason it is less is because we removed all observations that had a missing value for at least one variable.
2.
mcs1.small <- subset(mcs1, select=c(mths,scien))
head(mcs1.small)
mths scien
1 Strongly Strongly
2 Disagree Agree
3 Disagree Strongly
4 Agree Agree
5 Agree Strongly
6 Agree Disagree
3.
mcs1.small.2 <- subset(mcs1, select=c(mcsid:internet))
head(mcs1.small.2)
mcsid cnum sex tv games compu internet
1 M10002P 1 boy 2 hours Less tha yes 1 hour t
2 M10007U 1 boy 3 hours 7 hours no 7 hours
3 M10015U 1 girl Less tha Less tha yes Less tha
4 M10016V 1 boy 2 hours 1 hour t yes 1 hour t
5 M10018X 1 girl 3 hours None no 5 hours
6 M10020R 1 girl 3 hours 1 hour t yes 2 hours
4.
mcs1.small.3 <- subset(mcs1, select=c(mcsid:internet,mths,scien))
head(mcs1.small.3)
mcsid cnum sex tv games compu internet mths scien
1 M10002P 1 boy 2 hours Less tha yes 1 hour t Strongly Strongly
2 M10007U 1 boy 3 hours 7 hours no 7 hours Disagree Agree
3 M10015U 1 girl Less tha Less tha yes Less tha Disagree Strongly
4 M10016V 1 boy 2 hours 1 hour t yes 1 hour t Agree Agree
5 M10018X 1 girl 3 hours None no 5 hours Agree Strongly
6 M10020R 1 girl 3 hours 1 hour t yes 2 hours Agree Disagree
You might also like to view...
Extensive knowledge of another culture will eliminate concerns, conflict and misunderstandings based on differences
Indicate whether the statement is true or false
The election of Barack Obama to the presidency in 2008 showed that major changes in American history:
A. Happen almost by accident B. Happen when social, economic and political forces come together in surprising ways C. Can only happen with a well thought-out strategy beforehand D. Occur because of the amount of financial clout of the campaign
Social welfare program policies reflect the dominant beliefs of the system and nation at the time they were enacted. Therefore, what could we conclude was the dominant belief of society at the time TANF replaced AFDC in 1996?
What will be an ideal response?
It is difficult to define the developmental tasks of old age because
a. as people age, their functional age may be more important than their chronological age. b. as life expectancy increases, the stage of old age keeps getting longer. c. as people age, they become more alike instead of demonstrating individual developmental characteristics. d. their functional age may be more informative, and the stage of old age keeps getting longer.