我有一个包含 6 个变量的数据框(文本摘录和编码器类别:Julie、Amy、Hannah、Mae)。
library(sjmisc)
library( reactable)
myData <- data.frame(
stringsAsFactors = FALSE,
id = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L),
Excerpt = c("Lorem ipus sed,",
"Maecenas pharetra eleifend turpis, in volutpat enim malesuada quis. Dui",
"Donec id magna dictum, dignissim mi eget, imperdiet nunc.",
"Ut sed purus lorem. Aliquam sagittis ante odio, a fringilla urna luctus eu. Etiam ligu",
"Integer eu erat faucibus, sodales ipsum quis, ultricies neque. In suscipit","Lorem ipshoncus sed,",
"Maecenas pharetra eleifend turpis","Donec id magna dictum, dignissim",
"Ut sed purus lorem. Aliquam",
"Integer eu erat faucibus, sodales ipsum quis, ultricies neque. In suscipit"),
Julie = c("I love pimento",
"Eat more avocado","Eat more avocado","Fish are quiet pets",
"I love pimento","I love pimento","I love pimento",
"Eat more avocado","I love pimento","I love pimento"),
Mae = c("I love pimento",NA,
"I prefer cats","Fish are quiet pets","I love pimento",
"I love pimento","Fish are quiet pets","Eat more avocado",
"Doesn't belong","I love pimento"),
Hannah = c("I love pimento",
"dogs make the best pets","I prefer cats","I prefer cats",
"I love pimento","I love pimento","I love pimento",
"I prefer cats","I love pimento","I love pimento"),
Amy = c("I love pimento",
"Eat more avocado","Eat more avocado","Fish are quiet pets",
"I love pimento","I love pimento","I love pimento",
"Eat more avocado","I love pimento","I love pimento"))
我使用 sjmisc 包来计算编码人员将特定字符串分配给摘录的次数
# counts strings across multiple columns
myData$fish <- row_count(myData, Julie:Amy, count = "Fish are quiet pets", append = FALSE)
myData$pimento <- row_count(myData, Julie:Amy, count = "I love pimento", append = FALSE)
myData$cats <- row_count(myData, Julie:Amy, count = "I prefer cats", append = FALSE)
myData$avocado <- row_count(myData, Julie:Amy, count = "Eat more avocado", append = FALSE)
myData$dogs <- row_count(myData, Julie:Amy, count = "dogs make the best pets", append = FALSE)
myData$notBelong <- row_count(myData, Julie:Amy, count = "Doesn't belong", append = FALSE)
当我查看 myData 时,我可以看到我现在总共有 12 个变量,并且我可以看到 6 个新变量中每一个的计数,但是,当我尝试使用 reactable 查看结果时,我可以看到我创建的新列,但列中未显示计数数据。
reactable (myData)
我该怎么做才能让计数数据显示在 Reactable 中?谢谢你。