If I have a data set "c" and one variable "x" inside.
The x variable only has two observation is 5 and 6.
I want to assign two variable c1
, c2
for c$x[1]
and c$x[2]
I tried to use the function below, but it does not work.
rf<-function(){
for(i in 1:2)
assign(paste("c", i,sep=""),paste("c$x[",i, "]" ,sep="")])}
How could I revise the syntax to get the results?