下面有两列属和种名的数据(第6列和第7列)。我想将这两列与字符串数据合并到一个合并了名称的新列中。
我对R很陌生,下面的代码不起作用!感谢您对堆栈溢出的帮助!
#TRYING TO MIX GENUS & SPECIES COLUMN
accepted_genus <- merged_subsets_2[6]
accepted_species <- merged_subsets_2[7]
accepted_genus
accepted_species
merged_subsets_2%>%
bind_cols(accepted_genus, accepted_species)
merged_subsets_2
我们可以使用str_c
从stringr
library(dplyr)
library(stringr)
df %>%
mutate(Col3 = str_c(Col1, Col2))
或搭配 unite
library(tidyr)
df %>%
unite(Col3, Col1, Col2, sep="", remove = FALSE)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句