I am trying to find the Wanted data structure from the current data structure. I partially know the schemas of the expected data structure. The required data structure includes another class list(...)
and factor
. Current data structure
> print(dat.m)
[,1] [,2]
ave_max 150 61
ave 60 0
lepo 41 0
dat.m <- structure(c(150L, 60L, 41L, 61L, 0L, 0L), .Dim = c(3L, 2L), .Dimnames = list(
c("ave_max", "ave", "lepo"), NULL))
Required Data Structure
> print(dat.m)
Vars M1 M2
1 ave_max 150 61
2 ave 60 0
3 lepo 41 0
I know that schematically something close to the following, where the unknowns structure(c(...)
androw.names = c(...)
structure(list(Vars = structure(c(...), .Label = c("ave_max",
"ave", "lepo"), class = "factor"), M1 = c(150, 60,
41), M2 = c(61, 0, 0)), .Names = c("Vars", "ave_max", "ave",
"lepo"), class = "data.frame", row.names = c(...))
R: 3.4.0 (backports)
OS: Debian 8.7