我有一个示例vector,如下所示:
dput(single.SSE)
c(AASHTO.Ext.SSE = "13.1685678457711", AASHTO.Int.SSE = "2.57651416013485",
Cai.Int.SSE = "4.78553017599823", Cai.Ext.SSE = "0.0683423975312745",
Suks.Int.SSE = "4.45954027996822", Suks.Ext.SSE = "0.0338390012831625",
Shahawy.Ext.SSE = "26.5084532366265", Henry.Int.SSE = "51.9309887392544",
Henry.Ext.SSE = "26.80132330346", Rigid.Int.SSE = "0.766791166554609",
Rigid.Ext.SSE = "3.81626934833545")我想把这个vector转换成一个data.frame,这样data.frame的colnames就是现有向量的rownames,data.frame的第一行也是唯一一行就是向量的值。
发布于 2021-02-01 20:25:48
我们可以使用as.data.frame.list
out <- type.convert(as.data.frame.list(single.SSE), as.is = TRUE)发布于 2021-02-01 18:10:08
您可以使用nrow = 1转换为矩阵,并将数据转换为数据帧。使用type.convert将数据更改为其各自的类型。
result <- type.convert(as.data.frame(matrix(single.SSE, nrow = 1,
dimnames = list(NULL, names(single.SSE)))), as.is = TRUE)https://stackoverflow.com/questions/65990618
复制相似问题