I am trying to load binary files in the following fashion
load("pred/Pred_pres_a_indpdt")
load("pred/Pred_pres_b_indpdt")
load("pred/Pred_pres_c_indpdt")
load("pred/Pred_pres_d_indpdt")
load("pred/Pred_pres_e_indpdt")
load("pred/Pred_pres_f_indpdt")
but I would like to set up a for loop to repla
Dear Chris,
Try this:
x <- c("a","b","c","d","e","f")
sapply(x, function(i){
i <- paste("pred/Pred_pres_",i,"_indpdt", sep ="")
load(i)
}
)
HTH,
Jorge
On Thu, Jul 30, 2009 at 4:06 PM, waltzmiester wrote:
>
> I am trying to load binary files in t
Try this,
files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")
lapply(files, load)
HTH,
baptiste
2009/7/30 waltzmiester :
>
> I am trying to load binary files in the following fashion
>
> load("pred/Pred_pres_a_indpdt")
> load("pred/Pred_pres_b_indpdt")
> load("pred/Pred_pres_c_ind
Try this:
sapply(sprintf("pred/Pred_pres_%s_indpt", x), load, envir = .GlobalEnv)
You need set the envir argument to global environment inside the sapply.
On Thu, Jul 30, 2009 at 5:06 PM, waltzmiester wrote:
>
> I am trying to load binary files in the following fashion
>
> load("pred/Pred_pres_
Thanks very much for these two solutions, but they are still printing
"Pred_pres_[i]_indpdt" on the screen and not executing the function load
Chris
baptiste auguie-5 wrote:
>
> Try this,
>
> files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")
>
> lapply(files, load)
>
>
> HT
I'm just guessing but what about
letters <- letters[1:6]
mynames <- paste("pred/Pred_pres_",letters,"_indpdt")
for(i in 1:6) load(mynames[i])
--- On Thu, 7/30/09, waltzmiester wrote:
> From: waltzmiester
> Subject: Re: [R] for loop for file names
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of waltzmiester
> Sent: Thursday, July 30, 2009 1:29 PM
> To: r-help@r-project.org
> Subject: Re: [R] for loop for file names
>
>
> Thanks very much f
7 matches
Mail list logo