# Investigate and clean the data set sample.trial # Use the function, str( ) to list: # the class of sample.trial # the number of observations and variables # the variable names and types # The variables gender and treatment should be factors # (categorical variables). If these variables are not factors, # please change both variables to factors. # Use the str() function to check that the changes have been # made correctly. # List the first 11 lines of the data set # Summarize the data set using summary( ) ?summary() # Convert the numeric variable age into the factor age.groups # using the function cut( ) and the following # breaks: 17, 25, 39, 60 # Assign the new variable, age.groups, to the data frame, sample.trial # NOTE: Review Lecture 6 Class Notes - # Converting continuous variables to categorical variables ?cut() # Check: Print the first 11 observations # Create a subset of males only and assign this subset to the # object, males ?subset() # Use the object males to create a frequency table for the # variable, age.group
age | gender | treatment |
26 | F | A |
32 | F | B |
18 | M | B |
29 | F | A |
35 | F | B |
35 | M | A |
38 | F | B |
55 | M | B |
56 | M | A |
34 | F | A |
22 | M | A |
22 | F | A |
23 | F | B |
35 | F | B |
34 | F | A |
22 | F | B |
34 | M | B |
56 | F | A |
59 | F | B |
29 | M | A |
45 | F | A |
43 | F | B |
33 | F | B |
23 | M | A |
49 | F | A |
51 | F | A |
23 | F | B |
38 | F | A |
34 | M | B |
19 | F | A |
39 | F | B |
40 | M | B |
# Investigate and clean the data set sample.trial # Use the function, str( ) to list: # the class of sample.trial # the number of observations and variables # the variable names and types # The variables gender and treatment should be factors # (categorical variables). If these variables are not factors, # please change both variables to factors. # Use the str() function to check that the changes have been # made correctly. # List the first 11 lines of the data set # Summarize the data set using summary( ) ?summary() # Convert the numeric variable age into the factor age.groups # using the function cut( ) and the following # breaks: 17, 25, 39, 60 # Assign the new variable, age.groups, to the data frame, sample.trial # NOTE: Review Lecture 6 Class Notes - # Converting continuous variables to categorical variables ?cut() # Check: Print the first 11 observations # Create a subset of males only and assign this subset to the # object, males ?subset() # Use the object males to create a frequency table for the # variable, age.group
To investigate and clean the data set sample.trial, we can follow these steps:
Step by step
Solved in 3 steps