R: Assign multiple variables from a data.frame at once in an environment

410 views Asked by At

Is it possible to assign multiple key-variable at once in an environment in R. I've a data.frame with two columns col1=key col2=value. In order to create an environment I do now :

e <- new.env(hash=TRUE,size=dim(dataframe)[1])
for(i in 1:dim(dataframe)[1]){
    assign(x=dataframe[i,1],value=dataframe[i,2],envir=e)
}

But it takes a while for big data.frame. I wonder if it's possible to assign all keys and variables at once by giving column 1 and 2 in parameter ?

Thanks

0

There are 0 answers