[R] iterative variable names

2011-12-05 Thread bcdc
Hi,

I'm trying to assign iterative names to variable, but all my attempts have
failed. I have a loop, and for every iteration, I need to create a variable,
and I'd like to name them iteratively, such as:

for(i in 1:10)
{
   x_i - c(values)
}

I need it to return ten variables: x_1, x_2, ..., x_10

How can I do it?

Thank you very much!
Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] iterative variable names

2011-12-05 Thread Uwe Ligges



On 05.12.2011 11:00, bcdc wrote:

Hi,

I'm trying to assign iterative names to variable, but all my attempts have
failed. I have a loop, and for every iteration, I need to create a variable,
and I'd like to name them iteratively, such as:

for(i in 1:10)
{
x_i- c(values)
}



You actually want to create a list of objects that you return in the end.

Uwe Ligges



I need it to return ten variables: x_1, x_2, ..., x_10

How can I do it?

Thank you very much!
Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] iterative variable names

2011-12-05 Thread Jim Holtman
?assign

for (i in 1:10) assign(paste('x_', i, sep = ''), i)

but before you do this, consider using a 'list'; check the archives since this 
is asked a lot.
Sent from my iPad

On Dec 5, 2011, at 5:00, bcdc bia@gmail.com wrote:

 Hi,
 
 I'm trying to assign iterative names to variable, but all my attempts have
 failed. I have a loop, and for every iteration, I need to create a variable,
 and I'd like to name them iteratively, such as:
 
 for(i in 1:10)
 {
   x_i - c(values)
 }
 
 I need it to return ten variables: x_1, x_2, ..., x_10
 
 How can I do it?
 
 Thank you very much!
 Beatriz
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] iterative variable names

2011-12-05 Thread bcdc
Thank you very much, assign was exactly what I needed! For my case, it worked
better than list! :)

Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4160262.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] iterative variable names

2011-12-05 Thread S Ellison
 

 -Original Message-

 Thank you very much, assign was exactly what I needed! For my 
 case, it worked better than list! :)

If assign(paste('x_', i)) works better for your case than using a list or array 
, you must surely have a very strange case


S Ellison***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.