Reputation: 478
I have a sample vector
as below:
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")
I want to convert this vector
to a data.frame
such that the colnames
of the data.frame
are the rownames
of the existing vector and the first and only row of the data.frame
is the values of the vector.
Upvotes: 1
Views: 142
Reputation: 886948
We can use as.data.frame.list
out <- type.convert(as.data.frame.list(single.SSE), as.is = TRUE)
Upvotes: 1
Reputation: 388817
You can convert to matrix with nrow = 1
and change the data to dataframe. Use type.convert
to change the data to their respective types.
result <- type.convert(as.data.frame(matrix(single.SSE, nrow = 1,
dimnames = list(NULL, names(single.SSE)))), as.is = TRUE)
Upvotes: 1