0

作为标题,我希望“相应问题”列的输出与原始数据集相同,但它将该列中的所有空格替换为“。”

我使用的代码是:

raw= read.csv("DATA2X02 class survey 2020 (Responses) - Form responses 1.csv", na=c("n/a", "", " "))
x = raw %>% janitor::clean_names()
colnames(x)[2] = "covid_test"
colnames(x)[4] = "postcode"
colnames(x)[5] = "dentist"
colnames(x)[6] = "university_work"
colnames(x)[7] = "social_media"
colnames(x)[8] = "dog_or_cat"
colnames(x)[9] = "live_with_parents"
colnames(x)[10] = "exercising"
colnames(x)[12] = "asthma"
colnames(x)[13] = "paid_work"
colnames(x)[14] = "fav_season"
colnames(x)[16] = "height"
colnames(x)[17] = "floss_frequency"
colnames(x)[18] = "glasses"
colnames(x)[20] = "steak_preference"
colnames(x)[21] = "stress_level"

tibble(Position = 1:21, `Variable name` = colnames(x), `Corresponding question` = colnames(raw)) %>%
  gt::gt() %>% 
  gt::tab_source_note("Table 1: Variable names and the corresponding questions asked in the DATA2002 survey.")

我的输出是: 我的输出

我想要这样的输出: 输出应该像

谢谢!

4

0 回答 0