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

[R] Problem with loop in folders

2020-04-24 Thread Shubhasmita Sahani
Hi Everyone, I am trying to loop through the folders in the major working directory. Read the dbf file into the data frame then save the data frame as CSV file in another folder. For this, I have written this code, But not able to figure out where it is going wrong. Any ideas will be of great suppo

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

[R] Problem with loop, matrix and data frame

2013-11-26 Thread ANNA SIMEONIDOU
Hi all, I'm sorry, maybe the solution in my problem is easy, but i am still new to R, and any help here is appreciated! I want to create a data frame, or a matrix in which the output of each loop will be stored. Here is the program > n<-c(10,8,7,5) > n_goal<-c(8,9,9,4) > w<-c(0.1,0.1,0.1,0.1)

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)

[R] Problem with loop

2011-12-02 Thread Komine
Hi, I try to build a loop difficultly. I have in a folder called Matrices several files (.csv) called Mat2002273, Mat2002274 to Mat2002361. I want to calculate for each file the mean of the column called Pixelvalues. I try this code but as result, I have this message: Mat2002273 not found >

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

[R] Problem with Loop and overwritten results

2009-04-12 Thread unbekannt
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 I wrote a 2nd loop around the other loop in order to repeat the inner loop a couple of