[R] how to get the varifying character with two variables?

David Winsemius dwinsemius at comcast.net
Thu Sep 1 14:30:50 CEST 2011


On Sep 1, 2011, at 3:45 AM, Jie TANG wrote:

> thank you. it works.
> but further question is that if we  can let the " flnm" to be a 2- 
> dimension
> matrix [3,5]?
> since
> mtdno<-paste("data",1:3,sep="")
> tyno<-paste("obs",1:5,sep="")
> flnm<-paste(mtdno,tyno,"_err.dat",sep="")
> flnm would be a 1-dimension with 15 elements?

Just take out the c() call that converted the matrix from outer into a  
vector.

-- 
David

>
> thankyou
>
> 2011/9/1 Jorge I Velez <jorgeivanvelez at gmail.com>
>
>> Hi Jie,
>>
>> Try
>>
>> c(outer(mtdno, tyno, FUN = paste, "_err.dat", sep = ""))
>>
>> HTH,
>> Jorge
>>
>>
>> On Thu, Sep 1, 2011 at 3:11 AM, Jie TANG <> wrote:
>>
>>> hi R user
>>> mtdno<-paste("data",1:3,sep="")
>>> tyno<-paste("obs",1:5,sep="")
>>> flnm<-paste(mtdno,tyno,"_err.dat",sep="")
>>>
>>> flnm  is
>>> [1] "data1obs1_err.dat" "data2obs2_err.dat" "data3obs3_err.dat"
>>> [4] "data1obs4_err.dat" "data2obs5_err.dat"
>>>
>>> but actually what i want is data from 1 to  3 and obs from 1 to 5.  
>>> thus ,I
>>> can read 15 files but not 5 files
>>>
>>> how could I  do?
>>> thanks.
>>> --
>>> TANG Jie
>>>
>>>       [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at 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.
>>>
>>
>>
>
>
> -- 
> TANG Jie
> Email: totangjie at gmail.com
> Tel: 0086-2154896104
> Shanghai Typhoon Institute,China
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list