Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to name variables on the fly?

Tags:

r

r-faq

assign

Is it possible to create new variable names on the fly?

I'd like to read data frames from a list into new variables with numbers at the end. Something like orca1, orca2, orca3...

If I try something like

paste("orca",i,sep="")=list_name[[i]] 

I get this error

target of assignment expands to non-language object 

Is there another way around this?

like image 681
Maiasaura Avatar asked Apr 20 '10 22:04

Maiasaura


1 Answers

Use assign:

assign(paste("orca", i, sep = ""), list_name[[i]]) 
like image 60
Shane Avatar answered Sep 18 '22 00:09

Shane