![]() ![]() Remember when we wanted to decide the order of the categories in the factor? We can assign that order using the levels argument in factor(). ![]() We’re taking the previous values of our variable ( gender), doing something to it (making it a factor), and then reassigning the variable gender to our fixed set of values. One thing to notice: we are doing something called reassignment here. # $ gender male, male, female, male, female, male. Smoke_complete %>% #reassign the gender variable to be a factor mutate( gender = factor(gender)) %>% glimpse() # Rows: 1,152 # $ ethnicity "not hispanic or latino", "not hispanic. # $ gender "male", "male", "female", "male", "fema. # $ years_smoked NA, NA, NA, NA, NA, NA, NA, NA, NA, 26. # $ vital_status "dead", "dead", "dead", "alive", "alive. # $ tumor_stage "stage ia", "stage ib", "stage ib", "st. Smoke_complete %>% mutate( age_at_death = age_at_diagnosis + days_to_death) %>% glimpse() # Rows: 1,152 8.8.2 More about the Multiple Testing Problem.8.8 Analysis of Variance (ANOVA) (Optional).8.6 How Correlated are the Three Variables?.8.2.2 Googling is StandaRd pRactice foR eRrors.8.2.1 Understanding the difference between warnings and errors.7.5 Making your data long: pivot_longer().7 Part 5: Doing useful things with multiple tables.6.8 Other really useful forcats functions.6.5 fct_rev() - reversing the order of a factor.6.1 Making a factor variable out of disease.5.5 Standardizing variable names: clean_names().5.4.3 group_by()/summarize to calculate mean and standard deviation values.5.3.4 Using mutate to make a continuous variable categorical using case_when.5.3.3 Using mutate to make our character variables into factors.5.3.1 Using mutate to calculate a new variable based on other variables.5.3 mutate() - A confusing name, a powerful dplyr verb.5 Part 4: mutate(), group_by()/summarize().4.7.8 The difference between filter() and select().4.7.6 More about Comparison and Logical Operators.4.7.5 Filtering requires a little logic.4.7.3 Sorting Data Frames using arrange().4.4 Brief Aside: Categorical Data ( factors).4.3.2 Changing visual properties using built in themes. ![]()
0 Comments
Leave a Reply. |