gpt4 book ai didi

r - 使用第一个拆分字符将行分成列

转载 作者:行者123 更新时间:2023-12-03 16:29:27 26 4
gpt4 key购买 nike

具有这样的数据框:

data.frame(text = c("separate1: and: more","another 20: 42")

如何在每行中使用first:进行分隔?预期输出示例
data.frame(text1 = c("separate1","another 20"), text2 = c("and: more","42")

最佳答案

library(reshape2)

df <- data.frame(text = c("separate1: and: more","another 20: 42")

colsplit(df$text, ":", c("text1", "text2"))

关于r - 使用第一个拆分字符将行分成列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60152655/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com