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]]
Prof Brian Ripley
2011-Sep-01 07:33 UTC
[R] how to get the varifying character with two variables?
See ?outer (use paste as the function, as in one of the examples). On Thu, 1 Sep 2011, 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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? thankyou 2011/9/1 Jorge I Velez <jorgeivanvelez@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@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@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]]
David Winsemius
2011-Sep-01 12:30 UTC
[R] how to get the varifying character with two variables?
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
Possibly Parallel Threads
- how to read a group of files into one dataset?
- how to return back to go on my cycle while read my files
- how to skip out and go on read while the read.table meet with a null file
- how to skip from some null file and go on reading?
- langpack.exe cannot be varified