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
)
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
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
--
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
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,
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 <-
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)])
}
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
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.
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
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
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,
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
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,
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
15 matches
Mail list logo