I have a list converted from a JSON-string which looks like this:
print(p)
$species
[1] "Ratte"
$value
[1] "fitness"
$aggregation
[1] "mean"
I would like to use the information given the list as arguments in a function to transform a data-frame [Data] like this:
transformedData <- dcast(
Data[Data$species==p[[1]],],run_nr~paste(p[[2]],"_value",sep = ""),fun.aggregate = p[[3]]
)
This part
Data[Data$species==p[[1]],]
does work, of course.
unfortunately I do not know how to deal with the character strings of the other ones. I tried to convert the variables with as.name(paste(p[[2]],"_value",sep = ""))
and as.function(p[[3]])
, without success... does anyone knows a workaround?