Re: [R] saving a character vector

2006-02-05 Thread Philippe Grosjean
If I understand the question correctly, both Jim Holtman's and John Fox's answers are correct solutions. However, they are not optimal ones (that was not the question -optimize my code, please-, but one can talk about it a little bit). - Jim proposes (I rework a little bit his code): generateIn

Re: [R] saving a character vector

2006-02-04 Thread jim holtman
Is this what you want? It returns a character vector with the values: > generate.index<-function(n.item){ + .return <- character() # initialize vector + for (i in 1:n.item) +{ +for (j in ((i+1):n.item)) +{ + # concatenate the results + .return <- c(.return, paste("i",form

Re: [R] saving a character vector

2006-02-04 Thread Ferdinand Alimadhi
In order to use something like temp<-generate.index(10) your function should return something. See ?return for more information, especially this If the end of a function is reached without calling 'return', the value of the last evaluated expression is returned. The following code might

Re: [R] saving a character vector

2006-02-04 Thread Dominik Heier
Sorry. Forget my last post. I seem to be brain dead. Going to bed now (its late in Germany). Sorry again.. Am Sonntag, den 05.02.2006, 00:56 +0100 schrieb Dominik Heier: > Am Samstag, den 04.02.2006, 17:46 -0600 schrieb Taka Matzmoto: > > Hi R users > > > > I wrote a function that generates so

Re: [R] saving a character vector

2006-02-04 Thread John Fox
- > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Dominik Heier > Sent: Saturday, February 04, 2006 6:57 PM > To: Taka Matzmoto > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] saving a character vector > >

Re: [R] saving a character vector

2006-02-04 Thread Dominik Heier
Am Samstag, den 04.02.2006, 17:46 -0600 schrieb Taka Matzmoto: > Hi R users > > I wrote a function that generates some character strings. > > generate.index<-function(n.item){ > for (i in 1:n.item) > { > for (j in ((i+1):n.item)) > { > > cat("i",formatC(i,

[R] saving a character vector

2006-02-04 Thread Taka Matzmoto
Hi R users I wrote a function that generates some character strings. generate.index<-function(n.item){ for (i in 1:n.item) { for (j in ((i+1):n.item)) { cat("i",formatC(i,digits=2,flag="0"),".",formatC(j,digits=2,flag="0"),"\n",sep="") }