Re: [R] dynamic object names?

2005-09-19 Thread Duncan Murdoch
John Charles Considine wrote:
> On Mon, 2005-09-19 at 11:38 +0200, Uwe Ligges wrote:
> 
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>I am trying to extract data from a matrix. Let's say that i am interested in
>>>extracting 
>>>rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
>>>like to add a number to prefix. As result I should get 4 objects named: 
>>>
>>>prefix_1 
>>>prefix_2 
>>>prefix_3
>>>prefix_4
> 
> Samir,
> In addition to the other comments, part of the problem may be that you
> can't assign the character '_' to standard objects.  Could you use '.'
> instead?

Actually underscores have been allowed in names since version 1.9.0.

Duncan Murdoch

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dynamic object names?

2005-09-19 Thread Uwe Ligges
John Charles Considine wrote:

> On Mon, 2005-09-19 at 11:38 +0200, Uwe Ligges wrote:
> 
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>I am trying to extract data from a matrix. Let's say that i am interested in
>>>extracting 
>>>rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
>>>like to add a number to prefix. As result I should get 4 objects named: 
>>>
>>>prefix_1 
>>>prefix_2 
>>>prefix_3
>>>prefix_4
> 
> Samir,
> In addition to the other comments, part of the problem may be that you
> can't assign the character '_' to standard objects.


Why not???
R can handle standard names with "_" in it for ages now.

Uwe Ligges



 > Could you use '.' instead?
> JC 
> 
> 
>>>I attepted to solve the problem with a loop, but without success. Any hints??
>>
>>
>>1. In fact, you do not really want it.
>>2. You want to use "<-" rather than "->" for assigments. Reading your 
>>code is really hard when you are using this non-conventional way.
>>3. In order to answer your question: This is the FAQ "How can I turn a 
>>string into a variable?". The posting guide asks you to read these FAQs 
>>before sending questions to R-help. Please do so.
>>
>>Uwe Ligges
>>
>>
>>
>>
>>
matrix(LETTERS[1:16], ncol=4) -> MM
MM
>>>
>>> [,1] [,2] [,3] [,4]
>>>[1,] "A"  "E"  "I"  "M" 
>>>[2,] "B"  "F"  "J"  "N" 
>>>[3,] "C"  "G"  "K"  "O" 
>>>[4,] "D"  "H"  "L"  "P" 
>>>
>>>
>>>for (xxx in 1:4) {
>>>MM[xxx,] -> prefix_xxx;
>>>}
>>>
>>>
>>>Thanks
>>>
>>>samir
>>>
>>>__
>>>R-help@stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>__
>>R-help@stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dynamic object names?

2005-09-19 Thread vincent
see
?paste
hih

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dynamic object names?

2005-09-19 Thread John Charles Considine
On Mon, 2005-09-19 at 11:38 +0200, Uwe Ligges wrote:
> [EMAIL PROTECTED] wrote:
> 
> > I am trying to extract data from a matrix. Let's say that i am interested in
> > extracting 
> > rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
> > like to add a number to prefix. As result I should get 4 objects named: 
> > 
> > prefix_1 
> > prefix_2 
> > prefix_3
> > prefix_4
Samir,
In addition to the other comments, part of the problem may be that you
can't assign the character '_' to standard objects.  Could you use '.'
instead?

JC 

> > 
> > I attepted to solve the problem with a loop, but without success. Any 
> > hints??
> 
> 
> 1. In fact, you do not really want it.
> 2. You want to use "<-" rather than "->" for assigments. Reading your 
> code is really hard when you are using this non-conventional way.
> 3. In order to answer your question: This is the FAQ "How can I turn a 
> string into a variable?". The posting guide asks you to read these FAQs 
> before sending questions to R-help. Please do so.
> 
> Uwe Ligges
> 
> 
> 
> 
> > 
> >>matrix(LETTERS[1:16], ncol=4) -> MM
> >>MM
> > 
> >  [,1] [,2] [,3] [,4]
> > [1,] "A"  "E"  "I"  "M" 
> > [2,] "B"  "F"  "J"  "N" 
> > [3,] "C"  "G"  "K"  "O" 
> > [4,] "D"  "H"  "L"  "P" 
> > 
> > 
> > for (xxx in 1:4) {
> > MM[xxx,] -> prefix_xxx;
> > }
> > 
> > 
> > Thanks
> > 
> > samir
> > 
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
> > http://www.R-project.org/posting-guide.html
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dynamic object names?

2005-09-19 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:

> I am trying to extract data from a matrix. Let's say that i am interested in
> extracting 
> rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
> like to add a number to prefix. As result I should get 4 objects named: 
> 
> prefix_1 
> prefix_2 
> prefix_3
> prefix_4
> 
> I attepted to solve the problem with a loop, but without success. Any hints??


1. In fact, you do not really want it.
2. You want to use "<-" rather than "->" for assigments. Reading your 
code is really hard when you are using this non-conventional way.
3. In order to answer your question: This is the FAQ "How can I turn a 
string into a variable?". The posting guide asks you to read these FAQs 
before sending questions to R-help. Please do so.

Uwe Ligges




> 
>>matrix(LETTERS[1:16], ncol=4) -> MM
>>MM
> 
>  [,1] [,2] [,3] [,4]
> [1,] "A"  "E"  "I"  "M" 
> [2,] "B"  "F"  "J"  "N" 
> [3,] "C"  "G"  "K"  "O" 
> [4,] "D"  "H"  "L"  "P" 
> 
> 
> for (xxx in 1:4) {
> MM[xxx,] -> prefix_xxx;
> }
> 
> 
> Thanks
> 
> samir
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] dynamic object names?

2005-09-19 Thread samir

I am trying to extract data from a matrix. Let's say that i am interested in
extracting 
rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
like to add a number to prefix. As result I should get 4 objects named: 

prefix_1 
prefix_2 
prefix_3
prefix_4

I attepted to solve the problem with a loop, but without success. Any hints??

> matrix(LETTERS[1:16], ncol=4) -> MM
> MM
 [,1] [,2] [,3] [,4]
[1,] "A"  "E"  "I"  "M" 
[2,] "B"  "F"  "J"  "N" 
[3,] "C"  "G"  "K"  "O" 
[4,] "D"  "H"  "L"  "P" 


for (xxx in 1:4) {
MM[xxx,] -> prefix_xxx;
}


Thanks

samir

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html