Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on hypatia.math.ethz.ch X-Spam-Status: No, hits=3.5 required=5.0 tests=BAYES_44,RCVD_IN_BL_SPAMCOP_NET autolearn=no version=2.63 X-Spam-Level: *** Dear ladies and gentlmen, I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? Thanks a lot! Claudia
Hi, have a look at list.files() and import them in a loop or similar. Regards Michael Claudia Paladini wrote:> > Content-Type: text/plain; charset="iso-8859-1" > Content-Transfer-Encoding: 7bit > X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on hypatia.math.ethz.ch > X-Spam-Status: No, hits=3.5 required=5.0 tests=BAYES_44,RCVD_IN_BL_SPAMCOP_NET autolearn=no version=2.63 > X-Spam-Level: *** > > Dear ladies and gentlmen, > I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? > Thanks a lot! > Claudia > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- Michael T. Mader Institute for Bioinformatics/MIPS, GSF Ingolstaedter Landstrasse 1 D-85764 Neuherberg 0049-89-3187-3576 response time (n.) An unbounded, random variable Tr associated with a given TIMESHARING system and representing the putative time which elapses between Ts, the time of sending a message, and Te, the time when the resulting error diagnostic is received. S. Kelly-Bootle, The Devil's DP Dictionary
Claudia Paladini wrote:> > Dear ladies and gentlmen, > I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? > Thanks a lot! > Claudia> > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlInn order to get a list "dat" containing all the data: setwd("path") files <- dir(pattern="dat$") dat <- lapply(files, scan) Uwe Ligges
On Tue, Feb 24, 2004 at 02:34:35PM +0100, Claudia Paladini wrote:> Dear ladies and gentlmen, > I want to import a directory with about 400 files (.dat) in R. I know > how to import a single file (with scan...) but I've good no idea how > to import 400 at once. Can you help me ?You can get list of the files you need: flist <- system("ls", intern = TRUE) Then run on that list: for (fname in flist) { get(fname, scan(file = fname, ...)) ... } -- WBR, Timur
Claudia Paladini wrote:> > Dear ladies and gentlmen, I want to import a directory with about 400 > files (.dat) in R. I know how to import a single file (with scan...) > but I've good no idea how to import 400 at once. Can you help me ? > Thanks a lot! Claudiasetwd("c:/myfiles/") ## list.files uses regular expressions. ## For reading all files which start with "S" use for example: files <- list.files(pattern="^S.*") ## then read the data within a loop, e.g.: dat2 <- NULL for (f in files) { dat <- read.table(f) dat2 <- rbind(dat2, dat) } Thomas P.
I don't know what these files are. so depending on whether you want to call them with 400 different names or just have one data set for the 400 files. but in either case you can do a for loops on the directory. i.e. put the 400 files in a seperate directory and setwd("to that directory") do this for (i %in% dir()){ assign(gsub(".dat", "", i), scan(....))} this will create the 400 files with names without the .dat at the end. note if you want to merge theem or rbind them, just replace the the command assign above by rbind or merge. On Tue, 24 Feb 2004, Claudia Paladini wrote:> Dear ladies and gentlmen, > I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? > Thanks a lot! > Claudia > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
> From: Jean Eid > > I don't know what these files are. so depending on whether you want to > call them with 400 different names or just have one data set > for the 400 > files. but in either case you can do a for loops on the > directory. i.e. > put the 400 files in a seperate directory and setwd("to that > directory") > do this > > for (i %in% dir()){ > assign(gsub(".dat", "", i), scan(....))}1. I guess you meant "in" rather than "%in%" inside the for()? 2. It is probably easier to store the results in a list in such situations; e.g., fList <- list.files() datList <- vector(mode="list", length=length(fList)) names(datList) <- fList for (f in fList) datList[[f]] <- scan(f) Cheers, Andy> this will create the 400 files with names without the .dat at the end. > note if you want to merge theem or rbind them, just replace the the > command assign above by rbind or merge. > > > > On Tue, 24 Feb 2004, Claudia Paladini wrote: > > > > > Dear ladies and gentlmen, > > I want to import a directory with about 400 files (.dat) in > R. I know how to import a single file (with scan...) but I've > good no idea how to import 400 at once. Can you help me ? > > Thanks a lot! > > Claudia > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments,...{{dropped}}
Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on hypatia.math.ethz.ch X-Spam-Status: No, hits=1.7 required=5.0 tests=AWL,BAYES_44,RCVD_IN_BL_SPAMCOP_NET autolearn=no version=2.63 X-Spam-Level: * Dear Ladies and gentlemen, I'm looking for a means in R to test whether a timese series is stationary or not. Can somebody help me? Kind regards Claudia ______________________________________________________________________________ Nachrichten, Musik und Spiele schnell und einfach per Quickstart im