R_DATACAMP6 Introduction to Data

  • Language of data 数据语言

用data()导入dataset

droplevels()把没用的levels去除掉
一般可以用table()查看levels

ifelse(test, yes, no)
test为真,输出yes值,否则输出no值。

email50_fortified <- email50 %>%
mutate(number_yn = case_when(
number == "none" ~ "no",
number != "none" ~ "yes"
)
)

  • Sampling strategies and experimental design

sample_n()随机抽样

x = case_when(
[condition 1] ~ [value of x when condition 1 is true],
[condition 2] ~ [value of x when condition 2 is true],
[condition 3] ~ [value of x when condition 3 is true]
)

你可能感兴趣的:(R_DATACAMP6 Introduction to Data)