a <- "dog cat carrot cabbage"
b <- "orange cat chair cabbage"
c <- "dog phone book beach"
x <- data.frame(a,b,c)
> x
a b c
1 dog cat carrot cabbage orange cat chair cabbage dog phone book beach这是建在柱子上的。我想要的是一个1列数据帧,每个字符串都作为一行。我该怎么做?
发布于 2016-06-28 05:43:54
d <- c(a,b,c)
data.frame(d)输出:
d
1 dog cat carrot cabbage
2 orange cat chair cabbage
3 dog phone book beach发布于 2016-06-28 05:57:05
另一种选择是使用as.data.frame
as.data.frame(c(a,b,c))
# c(a, b, c)
#1 dog cat carrot cabbage
#2 orange cat chair cabbage
#3 dog phone book beach您也可以使用rbind
rbind(a, b, c)
# [,1]
#a "dog cat carrot cabbage"
#b "orange cat chair cabbage"
#c "dog phone book beach" 发布于 2016-06-28 06:28:03
可以逐行构建矩阵并将其转换为df。
data.frame(matrix(c(1, 7, 4, 6, 2, 0, 6, 2, 8), 3, 3, byrow = TRUE))https://stackoverflow.com/questions/38067892
复制相似问题