简体   繁体   English

根据特定向量在Data.frame中创建观察

[英]Creating Observation in Data.frame based on specific vector

so in my case i have a data.frame which looks like follows. 所以在我的情况下,我有一个data.frame,如下所示。

date <- c("13.02","12.02","10.01")
text <- c("textabc")
time <- c("10 o'clock")

In the end my data.frame should like this: 最后,我的data.frame应该像这样:

在此处输入图片说明

So for every date string there should be a new observation in the data.frame. 因此,对于每个日期字符串,在data.frame中应该有一个新的观察值。 How can i do this? 我怎样才能做到这一点?

Thanks for your help! 谢谢你的帮助!

Try cbind.fill() from rowr 尝试从rowr cbind.fill()

library(rowr)
names <- c("text", "date", "time")
df <- cbind.fill(text, date, time)
colnames(df) <- names
# df output
     text  date       time
1 textabc 13.02 10 o'clock
2 textabc 12.02 10 o'clock
3 textabc 10.01 10 o'clock

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM