r - Tibble 和粘贴功能
问题描述
我尝试在小标题上使用粘贴功能,但我在下面得到了这个结果。我试图用 as.data.frame 对其进行转换,但结果是一样的。我真的需要使用 dplyr 来管理更大的数据集。
提前致谢。
Species=iris %>% select(Species)
paste("This is a ",Species)
[1] "这是 ac(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)"
解决方案
这是我必须工作的解决方案。您可以使用 mutate 将字符串“This is a”与 Species 列粘贴在一起。我已将其保存为名为 which_species 的变量。
# Load tidyverse
library(tidyverse)
# Select Species from iris
Species = iris %>% select(Species)
# I created a new variable pasting your string and the Species column together
Species <- Species %>% mutate(which_species = paste0("This is a ", Species))
# Check out the output
head(Species)
推荐阅读
- c - SPI 电子墨水显示器与 PIC 18F46K22 接口的问题
- python - 无法从 pyproj 导入名称 Transformer
- reactjs - 24小时格式的文本字段材料ui
- swift - 初始化类 | 迅速
- ios - 键盘隐藏时不要隐藏输入附件视图
- html - HTML5 中 void 元素中的开始标签和结束标签在哪里?
- point-cloud-library - PCL:如何在 PCL 可视化中选择其他点云
- mysql - 在父子层次结构中查找最多 7 个级别的级别段
- javascript - 附加时如何滚动到项目?
- javascript - How to type useRef hook in Flow?