I would like to convert a character string into a variable name for a list variable, Here is an example.
x=rnorm(1:100)
y=rnorm(1:100)*5+10
OneDimModel = NULL;
OneDimModel$model = lm(y~x)
I would like to reassign list variable OneDimModel
for one individual case to a summarising variable paste("DataCentre$sitenumber", i, sep="")
, where [i]
can be varied across different cases.
So the end product would be something like for case 1:
DataCentre$sitenumber1 = OneDimModel
I have tried function assign()
, but it only works for single value, could someone help me.
You need to do use extract operator
[[
Or simply