[R] subset and "or" operator

2009-03-23 Thread lauramorg...@bluewin.ch
Hello, I'm trying to subset a dataframe where I have many observation taken in different years. I would like to subset the dataframe (in this example called "table") to get a new dataframe containing only the observation of year 1995, 1998 and 2000. I've tried to use subset and the or operator "

[R] non linear regression with nls

2009-02-03 Thread lauramorg...@bluewin.ch
Hello, I'm a beginner with R and it's the first time I'm using the R-help list... I hope I'm in the right place, if not: Sorry!! I need to do non linear regressions on a data set which columns are: "river.name""Portata" "PTG.P" "PO4.P" "NT.N""NH4.N" "NO3.N" "BOD5""SiO2"

Re: [R] non linear regression with nls

2009-02-05 Thread lauramorg...@bluewin.ch
Thank you a lot Mr. Ritz! I've tried the loop you suggested and I added a list for lower and upper limits of the parameters, but there is still a problem... I have a list of functions, which works... fz1<-function(Portata, a, b){a+(b/Portata)} fz2<-function(Portata, a, b){a*exp(b*Portata)} fz3

Re: [R] non linear regression with nls

2009-02-05 Thread lauramorg...@bluewin.ch
e how can someone specify the groups/subset? Thanks a lot! Laura Messaggio originale Da: kfr...@wisc.edu Data: 03.02.2009 15.36 A: Oggetto: Re: [R] non linear regression with nls Hi, Laura- You might have a look at ?nlsList(). Ken - Original Message - From: "

Re: [R] non linear regression with nls

2009-02-06 Thread lauramorg...@bluewin.ch
Thank you! It worked perfectly, also for the other variables! Messaggio originale Da: r...@life.ku.dk Data: 06.02.2009 13.29 A: Oggetto: Re: [R] non linear regression with nls Hi Laura, I think you have to make a list formulas: formList <- list(NT.N ~ fz1(Portata, a, b), NT.N ~ fz2(Po

[R] plotting the result of a nonlinear regression

2009-02-10 Thread lauramorg...@bluewin.ch
Hello, to plot the result of a singular non linear regression (using nls) I usually use the function plotfit, for example: r.PTG.V<-nls(PTG.P~ fz1(Portata, a,b), data=dati, start=list(a=10, b=10), nls.control(maxiter=200), algorithm='port', trace=TRUE, na.action=na.omit, lower=list(a=0, b=10),

[R] summary of a list

2009-02-10 Thread lauramorg...@bluewin.ch
Hello, I'm using the following for loop to find regression curves using a list of functions (formList), a list of starting values (startList), uppervalues (upperList) and lower values (lowerList). A sample of the list of function I use in the loop is the following: FormList <- list(PTG.P ~ fz1(P

[R] plots and text to the same output file

2009-02-11 Thread lauramorg...@bluewin.ch
Hello, I would like to save different plots and some text (like summaries, AIC, ...) on the same file. I've read the e-mails entitled "Output results to a single postscript document" written some days ago and I've tried to use the function odfInsertPlot() in the package "odfWeave" but it doesn'

Re: [R] plotting the result of a nonlinear regression

2009-02-12 Thread lauramorg...@bluewin.ch
Oggetto: Re: [R] plotting the result of a nonlinear regression ?predict On Tue, Feb 10, 2009 at 11:06 AM, lauramorg...@bluewin.ch wrote: > Hello, > to plot the result of a singular non linear regression (using nls) I usually > use the function plotfit, for example: > > r.P

Re: [R] summary of a list

2009-02-13 Thread lauramorg...@bluewin.ch
Hello Dieter and everyone, Thank you for your advice... but I didn't manage to solve my problem... :-( I actually like the fact that R tells me which ones of my regressions didn't achieve convergence and gives me a warning saying that there was a false or singular convergence... the problem is t

Re: [R] summary of a list

2009-02-13 Thread lauramorg...@bluewin.ch
Thank you a lot!!! That was fantastic! It worked perfectly!!! Laura Hi Laura, try using the functions try() and inherits() to "catch" any errors in the loop: summaryList <- list() for (i in 1:35) { tempSummary <- try(summary(resultList[[i]]), silent = TRUE) if (inherits(tempSummary, "tr

[R] odfWeave & prettyR

2009-02-13 Thread lauramorg...@bluewin.ch
Hello, I've been trying to use odfWeave and prettyR packages to create documents with both text and graphs, but so far I haven't been very lucky... With the function R2html () in prettyR package, when I try to use a source file, which works perfectly if I run it directly form R using "source("f

Re: [R] read.table : how to condition on error while opening file?

2009-02-19 Thread lauramorg...@bluewin.ch
Hello Stephane, here is something you could try, filelist <- c("file1.txt", "file2.txt", "file3.txt") for (i in 1:3) { tmpList<-try(read.table(filelist[[i]]), silent=TRUE) if(inherits(tmpList, "try-error")) {print(paste("error opening file ", filelist[[i]])) } else { tmp<-read.table(filelist[[i]]

[R] write.table

2009-02-19 Thread lauramorg...@bluewin.ch
Hello, I tried to turn lists into vectors and then bind them together in order to create a dataframe but if, after this, I try to use the function write.table I get the following error message: Error in write.table(x, file, nrow(x), p, rnames, sep, eol, na, dec, as.integer(quote), : 'list'

Re: [R] mean over previous cells

2009-02-20 Thread lauramorg...@bluewin.ch
If, suppose, the name of your dataframe is "dataframe" , you could try something like: mean60days<-c() for(i in 1:length(dataframe$SST)) + { + mean60days[[i]]<-mean(dataframe$SST[i-10:i]) + } I'm not really sure it will work... my skills aren't that great... Anyway, it worked on a sample I tried i

Re: [R] mean over previous cells

2009-02-20 Thread lauramorg...@bluewin.ch
Sorry, I meant: If, suppose, the name of your dataframe is "dataframe" , you could try something like: mean60days<-c() for(i in 1:length(dataframe$SST)) + { + mean60days[[i]]<-mean(dataframe$SST[i-60:i]) + } I'm not really sure it will work... my skills aren't that great... Anyway, it worked on a

Re: [R] write.table

2009-02-20 Thread lauramorg...@bluewin.ch
Sorry, I'm using R 2.8.1 on Microsoft Windows XP professional 2002 Service Pack 2. The error I get is Error in write.table(x, file, nrow(x), p, rnames, sep, eol, > na, dec, as.integer(quote), : 'list' type not implemented in 'EncodeElement' The problem is that I can' t manage to save the

Re: [R] write.table

2009-02-20 Thread lauramorg...@bluewin.ch
ist" I thought that the function as.vector() could turn a list of numbers into a vector... was I wrong? ----Messaggio originale Da: rip...@stats.ox.ac.uk Data: 20.02.2009 12.40 A: "lauramorg...@bluewin.ch" Copia: Oggetto: Re: [R] write.table On Fri, 20 Feb 2009, lauramorg.

Re: [R] write.table

2009-02-20 Thread lauramorg...@bluewin.ch
.4697276 -1.2026201 -1.4366955 -1.4713526 use unlist > unlist(x) [1] -0.7349324 -0.4697276 -1.2026201 -1.4366955 -1.4713526 > Regards Petr > I thought that the function as.vector() could turn a list of numbers into a > vector... was I wrong? > > Messaggio originale---