Week 4- r studio notes Flashcards
1
Q
how would you do data wrangling?
A
RTA_filter <- RTA %>%
filter(intend > 0)
RTA_recode <- RTA_filter %>%
mutate(condition = recode(condition, “1” = “rta”, “2” = “control”),
actualdonate = recode(actualdonate, “1” = “donated” , “0” = “no_donate”))
head(RTA_recode)
- The filter() function is used to subset a data frame, retaining all rows that satisfy your conditions.
- mutate() function- add new variables in the specified data frame.
- recode- allows you to create new variables and to replace existing values of a variables based on a criterion.
- head- used to display the first n rows present in the input data frame
2
Q
descriptive stats
A
count() lets you quickly count the unique values of one or more variables
3
Q
how to calculate chi squared in r
A
results <- chisq.test(x = RTA_recode$condition,
y = RTA_recode$actualdonate,
correct = FALSE)
results
view(results)
- correct=false tells r not to do Yate’s correction