数据准备与正则表达式

Tidyverse 中的分类数据

Emily Robinson

Data Scientist

处理过长的名称

gathered_data %>%
   distinct(response_var)
# A tibble: 9 x 1
  response_var          
  <chr>
1 在飞机上换到未售出的座位是否失礼?
2 一般来说,和陌生人多说几句是否失礼?
3 在飞机上放倒座椅是否失礼?
4 为了更靠近某人而请他与您换座位是否失礼?
5 为了更靠近某人而请他与您换座位是否失礼?
6 若您要去洗手间,叫醒乘客是否失礼?  
7 若您想走动,叫醒乘客是否失礼?          
8 一般而言,带婴儿上飞机是否失礼?                           
9 一般而言,明知孩子会吵闹仍带其上飞机是否失礼?       
Tidyverse 中的分类数据

正则表达式

str_detect("happy", ".")
[1] TRUE
str_detect("happy", "h.")
[1] TRUE
str_detect("happy", "y.")
[1] FALSE
Tidyverse 中的分类数据

正则表达式

string <- "Statistics is the best"
str_remove(string, ".*the ")
[1] "best"
Tidyverse 中的分类数据

练习时间!

Tidyverse 中的分类数据

Preparing Video For Download...