Re: [R] how to write a loop to repetitive jobs

2018-04-18 Thread jim holtman
Try this: result <- lapply(71:75, function(x){ # use 'paste0' to add the number to the file name input <- read.csv(paste0("C:/Awork/geneAssociation/removed8samples/neuhausen", x, "/seg.pr3.csv") , head=TRUE )

Re: [R] how to write a loop to repetitive jobs

2018-04-17 Thread K. Elo
Hi! An alternative with 'assign': for ( i in 71:75) {   setwd(paste("C:/Awork/geneAssociation/removed8samples/neuhausen", i, sep=""))   temp.df<-read.csv("seg.pr3.csv", head=T)   temp.df$id<-paste0("sn",i,sep="")   assign(paste0("seg",i,sep=""),temp.df) } rm(temp.df,i)    # Clean up HTH, Kimmo

Re: [R] how to write a loop to repetitive jobs

2018-04-17 Thread Albrecht Kauffmann
Hello Ding, try this: seg <- list() for ( d in 71:75) { s <- paste0("seg",d) sn <- paste0("sn",d) Dir<-paste("C:/Awork/geneAssociation/removed8samples/neuhausen", i, sep="") setwd(Dir) seg[[s]] <- read.csv("seg.pr3.csv", head=T) seg[[s]]$id <- sn } Greetings, Albrecht --

Re: [R] how to write a loop to repetitive jobs

2018-04-16 Thread Ding, Yuan Chun
Hi Rui, Thank you very much!! It worked very well, I am looking into how to use lapply and do.call. Ding -Original Message- From: Rui Barradas [mailto:ruipbarra...@sapo.pt] Sent: Monday, April 16, 2018 2:16 PM To: Ding, Yuan Chun; r-help@r-project.org Subject: Re: [R] how to write

Re: [R] how to write a loop to repetitive jobs

2018-04-16 Thread Rui Barradas
Hello, The following might do it. Without data it's untested. wd <- function(i){ paste0("C:/Awork/geneAssociation/removed8samples/neuhausen7", i, "/seg.pr3.csv") } seg <- lapply(1:5, function(i) { DF <-read.csv(wd(i)) DF$id <- paste0("sn7", i) DF }) seg <- do.call(rbind,

[R] how to write a loop to repetitive jobs

2018-04-16 Thread Ding, Yuan Chun
Hi All.., I need to do the following repetitive jobs: seg71 <- read.csv("C:/Awork/geneAssociation/removed8samples/neuhausen71/seg.pr3.csv", head=T) seg71$id <-"sn71" seg72 <- read.csv("C:/Awork/geneAssociation/removed8samples/neuhausen72/seg.pr3.csv", head=T) seg72$id <-"sn72" seg73 <-

Re: [R] How to write a loop in which i has to be in POSIX format?

2014-05-09 Thread Tom Wright
i is an element in zn so replace zn[i] with just i for (i in zn){ treat$su[treat$Zugnacht==as.POSIXct(i, UTC)] - min(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zni, UTC)]) treat$sa[treat$Zugnacht==as.POSIXct(zni, UTC)] - max(treat$Vollzeit[treat$Zugnacht==as.POSIXct(zni, UTC)]) }

[R] How to write a loop in which i has to be in POSIX format?

2014-05-08 Thread peregrine
Hallo, I have a table in which I would like to insert the min and max values of another column (date and time in as.POSIXct Format). This is my row table, where su and sa are still the same as Vollzeit: head(treat) Vollzeit Datum Zugnacht su

Re: [R] How to write a loop in R to select multiple regression model and validate it ?

2013-06-05 Thread beginner
This is not a homework but part of my research. -- View this message in context: http://r.789695.n4.nabble.com/How-to-write-a-loop-in-R-to-select-multiple-regression-model-and-validate-it-tp4668669p4668720.html Sent from the R help mailing list archive at Nabble.com.

[R] How to write a loop in R to select multiple regression model and validate it ?

2013-06-04 Thread beginner
I would like to run a loop in R. I have never done this before, so I would be very grateful for your help ! 1. I have a sample set: 25 objects. I would like to draw 1 object from it and use it as a test set for my future external validation. The remaining 24 objects I would like to use as a

[R] How to write a loop in R to select multiple regression model and validate it ?

2013-06-04 Thread beginner
I would like to run a loop in R. I have never done this before, so I would be very grateful for your help ! 1. I have a sample set: 25 objects. I would like to draw 1 object from it and use it as a test set for my future external validation. The remaining 24 objects I would like to use as a

Re: [R] How to write a loop in R to select multiple regression model and validate it ?

2013-06-04 Thread Jeff Newmiller
This doesn't look like a task you have acquired through a real-life problem... it looks like homework. There is a stated no-homework policy in the Posting Guide (please read it), since you should be using the resources provided along with your educational environment (teaching assistants,

[R] How to write a loop?

2009-05-27 Thread Maithili Shiva
Dear R helpers,   Following is a R script I am using to run the Fast Fourier Transform. The csv files has 10 columns with titles m1, m2, m3 .m10.     When I use the following commands, I am getting the required results. The probelm is if there are 100 columns, it is not wise to define 100

Re: [R] How to write a loop?

2009-05-27 Thread Linlin Yan
Why did you use different variable names rather than index of list/data.frame? On Wed, May 27, 2009 at 6:34 PM, Maithili Shiva maithili_sh...@yahoo.com wrote: Dear R helpers, Following is a R script I am using to run the Fast Fourier Transform. The csv files has 10 columns with titles m1,

Re: [R] How to write a loop?

2009-05-27 Thread Andrew Dolman
Try lapply(ONS, fft) and take a look here http://cran.r-project.org/doc/manuals/R-intro.html for the basics of data structures in R and how to apply functions to them. Andy. andydol...@gmail.com 2009/5/27 Linlin Yan yanlinli...@gmail.com Why did you use different variable names rather