如何将一列的数据框架分为R中的两个列?
如何将一列的数据框架分为R中的两个列?
这是dput(head(分类法,n = 30))
structure(list(X1..Neodiprion.virginianus = c(" species, hymenopterans",
"2. Nepsalus jezoensis", " species, insects", "3. Prochas sp. 2 YYH-2022a",
" species, wasps, ants & bees", "4. Prochas sp. 1 YYH-2022a",
" species, wasps, ants & bees", "5. Eccoptopterus sp. 1 CP-2022",
" species, beetles", "6. Andricus sp. 1 CYS-2022a", " species, wasps, ants & bees",
"7. Paralabellula curvicauda", " species, earwigs", "8. Paralabellula",
" genus, earwigs", "9. Pristiphora sp.", " species, hymenopterans",
"10. Phyllotreta flexuosa", " species, beetles", "11. Nematinae sp.",
" species, hymenopterans", "12. Euura sp.", " species, hymenopterans",
"13. Dolerus sp.", " species, hymenopterans", "14. Ivieolus inflaticollis",
" species, beetles", "15. Germarostes sp.", " species, beetles",
"16. Germarostes globosus")), row.names = c(NA, 30L), class = "data.frame")
我需要循环数据框架: [![输入图像描述在此处] [1]] [1]
非常感谢! [1]: https://i.sstatic.net/ly1ho.png
How can I separate the data frame of one column into two columns in R?
This the dput(head(taxonomy, n=30))
structure(list(X1..Neodiprion.virginianus = c(" species, hymenopterans",
"2. Nepsalus jezoensis", " species, insects", "3. Prochas sp. 2 YYH-2022a",
" species, wasps, ants & bees", "4. Prochas sp. 1 YYH-2022a",
" species, wasps, ants & bees", "5. Eccoptopterus sp. 1 CP-2022",
" species, beetles", "6. Andricus sp. 1 CYS-2022a", " species, wasps, ants & bees",
"7. Paralabellula curvicauda", " species, earwigs", "8. Paralabellula",
" genus, earwigs", "9. Pristiphora sp.", " species, hymenopterans",
"10. Phyllotreta flexuosa", " species, beetles", "11. Nematinae sp.",
" species, hymenopterans", "12. Euura sp.", " species, hymenopterans",
"13. Dolerus sp.", " species, hymenopterans", "14. Ivieolus inflaticollis",
" species, beetles", "15. Germarostes sp.", " species, beetles",
"16. Germarostes globosus")), row.names = c(NA, 30L), class = "data.frame")
I need the folowing data frame:
[![enter image description here][1]][1]
Many thanks!
[1]: https://i.sstatic.net/ly1ho.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下事实,即排回收索引,因此
c(t,f)
将从第一行开始其他行,c(f,t)
将获得从第二行开始的所有其他行:输出
You can use the fact that row indices are recycled so
c(T,F)
will get every other row starting with the first row andc(F,T)
will get every other row starting with the second row:Output