Re: [R] Problem with loop in folders

2020-04-25 Thread Fredrik Karlsson
Hi, I am sorry if I am misunderstanding what you are trying to do here, but can you simplify it this way? (unfortualtely, this is untested since I dont have a suitable set of files and a directory structure to test against) dbifiles <- list.files(pattern="*.dbi",recursive=TRUE) csvfiles <- gsub

Re: [R] Problem with loop in folders

2020-04-24 Thread Sarah Goslee
I suspect much if not all of your trouble would be eliminated by using file.path() instead of paste0(). https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/file.path (Also check your file name - you probably want a . between name and csv, so using paste(name, "csv", sep = ".") woul

Re: [R] Problem with loop in folders

2020-04-24 Thread Bert Gunter
What package is "read.dbf" from? What error message/behavior did you see? Should it be: path<-setwd(paste0("inpath/",folder)) ## did you forget the "/" ? Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathe

Re: [R] Problem with loop, matrix and data frame

2013-11-26 Thread jim holtman
You reused 'i' in the inner 'for' loop. This looks like it give the correct answer: > n<-c(10,8,7,5) > n_goal<-c(8,9,9,4) > w<-c(0.1,0.1,0.1,0.1) > matrix<-mat.or.vec(6,4) > FI<-function(n_t) { + (((n_goal[1]-n[1]+W[1]-f[1]+n_t[1])^2)+((n_goal[2]-n[2]+W[2]-f[2]+n_t[2]-n_t[1])^2)+ + ((n_goal[3]-n

Re: [R] Problem with loop

2011-12-03 Thread Komine
Hi, Thank Michael for your help. Komine -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-loop-tp4148083p4154147.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.

Re: [R] Problem with loop

2011-12-02 Thread R. Michael Weylandt
You never create a variable called "Mat2002273" or "Mat2002361" so you can't ask R to loop over all the values between them. If I were you, I'd code something like this: lf <- list.files() # PUT IN SOME CODE TO REMOVE FILES YOU DON'T WANT TO USE pv <- vector("numeric", length(lf)) for(i in lf)

Re: [R] Problem with Loop and overwritten results

2009-04-13 Thread unbekannt
thank you so much! this solved my problem unbekannt wrote: > > > Dear all, > > I am a newbie to R and practising at the moment. > > Here is my problem: > > I have a programme with 2 loops involved. > The inner loop get me matrices as output and safes all values for me. > > Now once

Re: [R] Problem with Loop and overwritten results

2009-04-12 Thread David Winsemius
Dear unbekannt; The construction that would append a number to a numeric vector would be: vec <- c(vec , number) You can create an empty vector with vec <- c() or vec <- NULL -- David Winsemius On Apr 12, 2009, at 2:10 PM, unbekannt wrote: Dear all, I am a newbie to R and practising a