Re: [R] R3.3.1 - Windows10 OS - Overriding default Legend title with user specified title

2016-07-26 Thread Tom Wright
A quick google for "ggplot2 change legend text" turns up several hits. This stackexchange question has several recipes. http://stats.stackexchange.com/questions/5007/how-can-i-change-the-title-o f-a-legend-in-ggplot2 including the correct use of the labs() function; labs(aesthetic='BrandValue in B

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
- wday(a1$date) # note can’t have spaces in variable names week_names <- wday(a1$date, label=TRUE) *From:* Shivi Bhatia [mailto:shivipm...@gmail.com] *Sent:* July 26, 2016 12:16 PM *To:* Tom Wright *Cc:* David L Carlson ; r-help *Subject:* Re: [R] Date Time in R Hello Tom, Please

Re: [R] Date Time in R

2016-07-26 Thread Tom Wright
Hi again Shiva, I think what we need to see is the output from: str(eid$date) and perhaps head(eid$date) If you can send this information before doing any processing on the date (i.e. before the as.Date() function) we may be able to help. -Original Message- From: R-help [mailto:r-help

Re: [R] Excluding coordinates that fall within a circle

2016-06-17 Thread Tom Wright
I'm no expert here but I have recently been playing with the package 'geosphere' it contains plenty of options to calculate distance between two coordinates specified as lat and long. install.packages('geosphere') # only needed once library(geosphere) coord1 <- c(43.60923,-79.322799) coord2 <- c(

Re: [R] Building a binary vector out of dichotomous variables

2016-06-16 Thread Tom Wright
Does this do what you want? as.numeric(with(ds_example,paste(1,year2013,year2014,year2015,sep=''))) On Thu, Jun 16, 2016 at 8:57 AM, wrote: > Hi All, > > I need to build a binary vector made of a set of dichotomous variables. > > What I have so far is: > > -- cut -- > > ds_example <- > struct

Re: [R] strange error message when using rnorm and rbinom

2016-06-14 Thread Tom Wright
As you probably already guessed we are going to need to see the contents of nref, mu.m2 and disp.m2 to help. dput(nref) dput(mu.m2) dput(disp.m2) k might help too. On Tue, Jun 14, 2016 at 2:06 PM, JI Cho wrote: > Dear R users, > > I have been using rnorm, rbinom and have been getting the followi

Re: [R] Closing FTP sessions with RCurl

2016-06-14 Thread Tom Wright
No expert here, and this isn't tested. It seems you can set the forbid.reuse option which will cause curl to shutdown the connection after transfer is complete. if(url.exists("http://www.omegahat.net/RCurl/index.html";)) { curl <- getCurlHandle() curlSetOpt(.opts=list(forbid.reuse=1),curl=cu

Re: [R] VIM package

2016-06-09 Thread Tom Wright
Did you install the package before loading it? install.packages("VIM") On Thu, Jun 9, 2016 at 1:19 PM, Ayyappa Chaturvedula wrote: > Dear R users, > I am trying to use VIM (Visualization and Imputation of Missing Values) > package in R. When I try to install the VIM library (library(VIM)), I am

Re: [R] Problem loading aplpack library

2016-06-09 Thread Tom Wright
Assuming you are on a mac this link may be of assistance: http://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun/ On Wed, Jun 8, 2016 at 7:14 PM, David Howell wrote: > I am having trouble running aplpack on my Mac. It

Re: [R] How to import sensitive data when multiple users collaborate on R-script?

2016-05-31 Thread Tom Wright
My general approach to this is to put the function for loading data into a separate file which is then sourced in the main analysis file. Occasionally I'll use a construct like: if file.exists("loadData_local.R") { source("loadData_local.R") }else{ source("loadData_generic.R") } Whe

Re: [R] Shaded areas in R

2016-05-26 Thread Tom Wright
Hi Óscar, Not really sure what you mean by the time variable being a "character" vector. Unless you are plotting a barchart or boxplot (or similar), I don't this this makes sense. If you can post a sample of your data, preferably using the dput() command we can probably help more. On Thu, May 26,

Re: [R] strange error

2016-05-25 Thread Tom Wright
It may not be the problem, but with RStudio this error pops up when the area reserved for plotting is too small. Typically this area is in the right hand column, if you have this minimised (perhaps to maximise space for typing) you will hit this problem. Try making it bigger. Edit: Just ran your c

Re: [R] identify duplicate entries in data frame and calculate mean

2016-05-24 Thread Tom Wright
me thinking in the right direction. > One thing I should have mentioned that I did not is that the number of > rows in the data frame will be a little over 40,000 rows. > > > On 5/24/2016 4:08 PM, Tom Wright wrote: > > Using dplyr > > $ library(dplyr) > $ x

Re: [R] identify duplicate entries in data frame and calculate mean

2016-05-24 Thread Tom Wright
Using dplyr $ library(dplyr) $ x<-data.frame(Length=c(321,350,340,180,198), ID=c(rep('A234',3),'B123','B225') ) $ x %>% group_by(ID) %>% summarise(m=mean(Length)) On Tue, May 24, 2016 at 3:46 PM, Matthew wrote: > I have a data frame with 10 columns. > In the last colum

Re: [R] ggplot2 not displaying graph in RH7 RStudio Server 3.2.3

2016-05-19 Thread Tom Wright
I just tested your code on my debian install with no problems. RStudio server logs messages to /var/log/messages (on redhat). Does running: $ cat /var/log/messages |grep rsession $ cat /var/log/messages |grep rserver in the shell give any clues? R version 3.2.5 (2016-04-14) Platform: x86_64-p

Re: [R] Create a new variable and concatenation inside a "for" loop

2016-05-02 Thread Tom Wright
As pointed out somewhere in the replies to this you can always use the exists() function. for(i in 1:5){ if(exists(output)){ output <- c(output, i ) }else{ output <- i } } On Wed, Apr 27, 2016, 11:15 AM Gordon, Fabiana < fabiana.gor...@imperial.ac.uk> wrote: > Hello, > >

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
o change this behaviour. On Mon, May 2, 2016 at 11:01 AM, wrote: > I just changed all the names in Command to lowercase, then this > str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have > any idea how I can bring PDT2 also in str_ext

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
PDT2')// I create a vector with these conditions > str_extract(df$Command,paste(v1,collaps='|')) //returning patterns, > using stringr library > > here I see no pattern named PDT2 but there are only PD and t2 patterns. > On Monday, May 2, 2016 8:18 AM, Tom Wright wro

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
),df$Command) I get this error: > Argument "x" is missing, with no default. Actually I don't know how to fix > this. Do you have any idea? > > Tom's code was missing a ")" but not where you put one. He probably also > didn't intend to capita

Re: [R] inserting row(column) in array or dataframe at specified row(column)

2016-05-01 Thread Tom Wright
If you can address your columns by name then order shouldn't matter. If the column order does matter, perhaps a matrix is a better structure to use? On Sun, May 1, 2016, 10:56 AM Jan Kacaba wrote: > Hello dear R users, > > Is there a function or package which can insert row, column or array in >

Re: [R] row names, coulmn names

2016-05-01 Thread Tom Wright
I think what you ask isn't ideal.Each column in a dataframe should be the same data type. While column names are stored in the first row when the df is exported to CSV, they are not stored as columns in the data frame. Instead the column names are stored as a separate attribute of the df. This is w

Re: [R] how to use AND in grepl

2016-04-30 Thread Tom Wright
$Command) On Sat, Apr 30, 2016, 7:07 PM Tom Wright wrote: > subset(df,grepl("t2|pd",x$Command)) > > > On Sat, Apr 30, 2016 at 2:38 PM, ch.elahe via R-help > wrote: > >> Hi all, >> >> I have one factor variable in my df and I want to extract the names

Re: [R] how to use AND in grepl

2016-04-30 Thread Tom Wright
subset(df,grepl("t2|pd",x$Command)) On Sat, Apr 30, 2016 at 2:38 PM, ch.elahe via R-help wrote: > Hi all, > > I have one factor variable in my df and I want to extract the names from > it which contain both "t2" and "pd": > > 'data.frame': 36919 obs. of 162 variables >$TE:

Re: [R] Removing NAs from dataframe (for use in Vioplot)

2016-04-30 Thread Tom Wright
Never let it be said there's only one way to do a thing: require(ggplot2) require(dplyr) #create a sample dataset dat <- data.frame(y1=sample(c(1:10,NA),20,replace=TRUE), y2=sample(c(1:10,NA),20,replace=TRUE), y3=sample(c(1:10,NA),20,replace=TRU

Re: [R] Error using RPostgreSQL

2016-04-22 Thread Tom Wright
On heroku the database uri is stored in an environment variable. > db_uri = Sys.getenv(''DATABASE_URL') I'm not sure if you can use that directly or if you will need to parse it for username, password etc. On Thu, 2016-04-21 at 16:49 +0100, Izaak Rogan wrote: > Hi, > > I'm having trouble connec

Re: [R] Finding Highest value in groups

2016-04-22 Thread Tom Wright
Assuming your dataframe is in a variable x: > require(dplyr) > x %>% group_by(ID) %>% summarise(maxVal = max(Value,na.rm=TRUE)) On Fri, 2016-04-22 at 13:51 +, Saba Sehrish via R-help wrote: > Hi > > > I have two columns in data frame. First column is based on "ID" assigned to > each grou

Re: [R] Problem with X11

2016-04-19 Thread Tom Wright
I don't have my debian box available so can't confirm. But I would try $apt-get install libpng On Tue, Apr 19, 2016 at 11:23 AM, Lorenzo Isella wrote: > Dear All, > I have never had this problem before. I run debian testing on my box > and I have recently update my R environment. > Now, see what

Re: [R] how to find the mean and sd :(

2015-09-11 Thread Tom Wright
On Fri, 2015-09-11 at 07:48 -0700, massmatics wrote: > AM.warpbreaks<=30 The above command is not returning what you expected, what part of the AM.warpbreaks dataframe is expected to be <= 30? Effectively you are using a two stage process. 1) Create a logical vector identifying rows in the datafr

Re: [R] How to obtain a cross tab count of unique values

2015-03-31 Thread Tom Wright
table(unique(df)$PROJECT) On Tue, 2015-03-31 at 14:51 -0500, Walter Anderson wrote: > I have a data frame that shows all of the parks (including duplicates) > that are impacted by a projects 'footprint': > > PROJECT PARKNAME > A PRK A > A PRK B > A PRK A > B PRK C > B

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread Tom Wright
Not entirely sure I understand your problem here (your first email was a lot of reading). Would it make sense to add an extra column device_name Thus ending up with something like: Host Device Type host_Aada0ssd host_Aada1ssd host_Aada2hdd ... host_Nda3 ssd

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread Tom Wright
Nice clean-up!!! On Tue, 2015-03-31 at 14:19 -0400, Ista Zahn wrote: > library(tidyr) > library(dplyr) > bw <- gather(bw, key = "tmp", value = "value", > matches("^d[a-z]+[0-9]+")) > bw <- separate(bw, tmp, c("disc", "var"), "_", extra = "merge") > bw <- spread(bw, var, value) ___

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Tom Wright
samples<-sample(c(rep(1,10),rep(2,10),rep(3,10)),30) samples[samples==1]<-1001:1010 samples[samples==2]<-2001:2010 samples[samples==3]<-3001:3010 fullDf<-rbind(df1,df2,df3) fullDf[sort(order(samples),index.return=TRUE)$ix,] On Tue, 2015-03-31 at 13:05 -0400, Kevin E. Thorpe wrote: > Hello. > >

Re: [R] summary.formula()

2015-03-18 Thread Tom Wright
First you need to make the data pbc available, perhaps by: data(pbc, package="survival") Then the line: sf2<-summary(... looks wrong, usually you would use the summary() function to look at the output from a function, seems to me you are missing the function here. I have no idea what this functi

Re: [R] reading multiple text files from web

2015-03-18 Thread Tom Wright
I think you need to use a loop to iterate through each of the items in getlinks for(link in getlinks) { url<-paste0('http://spec.org/jEnterprise2010/results/',link) output<-readfiles(url) } You're probably also going to need to add some error handling when your sea

Re: [R] Requesting function for A/B testing

2015-03-06 Thread Tom Wright
I can answer this: sample(c(0,1),1) On Fri, 2015-03-06 at 15:04 +0530, Namratha K wrote: > Dear Sir/Madam, > I am a student pursuing MCA .As i am doing an project using R language .I > want to implement A/B testing using R language.I am searching in google > from past few days and not able to imp

Re: [R] plotting the one-dimensional density of events in time

2015-03-06 Thread Tom Wright
plot(density(as.numeric(dd)), axes=FALSE, xlim=c(as.numeric(as.Date("2014-01-01")), as.numeric(as.Date("2014-12-30"))) rug(as.numeric(dd)) axis(side=1, at=seq(from=as.numeric(as.Date('2014-01-01')), to=as.numeric(as.Date('2014-12-1')),length.out=12), lab

Re: [R] problem with function that adds rows to dataframe based on conditional statement

2015-03-06 Thread Tom Wright
If all you want is to add a row of na's could you just do something like: nExpectedRows<-length(unique(animals)) * length(unique(animalYears)) * 2 newDf<-data.frame(animals=rep(NA,nExpectedRows-nrow(comAn)), animalYears=rep(NA,nExpectedRows-nrow(comAn)), animal

Re: [R] Still trying to avoid loops

2015-02-04 Thread Tom Wright
> -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Tom Wright > Sent: Wednesday, February 4, 2015 2:08 PM > To: Rui Barradas > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Still trying to avoid loops > > Thanks, I was not aware of

Re: [R] Still trying to avoid loops

2015-02-04 Thread Tom Wright
; S D visit > 1 a 5 1 > 2 a 1 2 > 3 b 3 1 > 4 c 2 1 > 5 c 3 2 > 6 c 4 3 > > > > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. &

Re: [R] Still trying to avoid loops

2015-02-04 Thread Tom Wright
> > > Aren't the levels of your example wrong? If the levels are > > levels=c('a','b','c'), not c('b', 'a', 'c'), then the following will do the > > job. > > > > unname(unlist(tapply(dat$D, dat$S, or

Re: [R] Still trying to avoid loops

2015-02-04 Thread Tom Wright
,'b','c'), not c('b', 'a', 'c'), then the following will do > the job. > > unname(unlist(tapply(dat$D, dat$S, order))) > > > Hope this helps, > > Rui Barradas > > Em 04-02-2015 19:34, Tom Wright escreveu: > > G

Re: [R] Teaching materials for R course

2015-02-04 Thread Tom Wright
For the introduction to R I strongly suggest you look at the materials published by software-carpentry www.software-carpentry.org. The lessons are all open-source, hosted on github and are under active development. On Tue, 2015-02-03 at 12:08 +0100, Michael Haenlein wrote: > Dear all, > > I am Pr

[R] Still trying to avoid loops

2015-02-04 Thread Tom Wright
Given a dataframe: dat<-data.frame(S=factor(c(rep('a',2),rep('b',1),rep('c',3)),levels=c('b','a','c')), D=c(5,1,3,2,3,4)) where S is a subject identifier and D a visit (actually a date in my real dataset). I would like to generate another column giving the visit number R=c(2,1,1,1

Re: [R] collapse a list of dataframes

2015-02-02 Thread Tom Wright
uot;A","B");return(x)}) > do.call(rbind,t) > > > On Mon, Feb 2, 2015 at 4:00 PM, Tom Wright wrote: > Hi all, > > I'm trying to avoid loops (no real reason, just as an > exercise). > > Given a list: >

[R] collapse a list of dataframes

2015-02-02 Thread Tom Wright
Hi all, I'm trying to avoid loops (no real reason, just as an exercise). Given a list: list(data.frame(a=1:3,b=letters[1:3]),data.frame(x=1:5,b=LETTERS[1:5])) Is there an easy way to collapse this to a single dataframe result<-data.frame(a=c(1:3,1:5),b=c(letters[1:3],LETTERS[1:5])) Thanks _

Re: [R] using png and identify commands

2015-02-02 Thread Tom Wright
replacing png(...) and dev.off() with dev2bitmap('test.png') seems to work. On Mon, 2015-02-02 at 15:56 -0200, Antonio Silva wrote: > Hi R users > > I want to save a plot after using the command identify. > > I use identify to place labels manually near the points in order to avoid > overlapping

Re: [R] ggplot with sparse layout

2015-01-07 Thread Tom Wright
nation of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > > Van: R-help [r-help-boun...@r-project.org] namens Tom Wright [ > t...@maladmin.co

[R] ggplot with sparse layout

2015-01-06 Thread Tom Wright
Hi, I would like to plot the following data such that each plot represents the data from a single id and the plots are grouped according to the group variable. data<-data.frame(id=factor(rep(1:6,each=3)), group=factor(c('a','a','b','c','c','c')), x=runif(18,0,10), y=rnorm(18,0,1)) The followi

Re: [R] Presentation tables in R (knitr)

2014-11-25 Thread Tom Wright
Thanks Duncan, Dropping the extra columns might be the way forward. I'm sure I can work out how to embed latex into a markdown document ;-) On Tue, Nov 25, 2014 at 4:37 PM, Duncan Murdoch wrote: > On 25/11/2014 3:12 PM, Tom Wright wrote: > >> Hi, >> This problem has me s

Re: [R] Presentation tables in R (knitr)

2014-11-25 Thread Tom Wright
em? > > Mark > > On Nov 25, 2014, at 2:12 PM, Tom Wright wrote: > > > > Hi, > > This problem has me stumped so I thought I'd ask the experts. I'm trying > > to create a pretty summary table of some data (which patients have had > > what tes

[R] Presentation tables in R (knitr)

2014-11-25 Thread Tom Wright
Hi, This problem has me stumped so I thought I'd ask the experts. I'm trying to create a pretty summary table of some data (which patients have had what tests at what times). Ideally I'd like to knitr this into a pretty PDF for presentation. If anyone has pointers I'll be grateful. require(tables)

Re: [R] Sum of two consecutive number in dataset.

2014-10-15 Thread Tom Wright
A couple of observations: 1) I'm not sure what the variable i is doing, looks like you are trying to loop through years but perhaps you left that bit of code out for clarity. 2) On the first loop of i you are assigning the values of Samaru56[sow_day,] to all values in Samaru56. For future loops all

Re: [R] plot

2014-09-19 Thread Tom Wright
plot(x=range(x),y=range(c(y1,y2,y3.y4),type='n') lines(x=x,y=y1,lty=1) lines(x=x,y=y2,lty=2) lines(x=x,y=y3,lty=3) lines(x=x,y=y4,lty=4) legend('bottomright',c('Y1','Y2','Y3','Y4','Y5'),lty=1:4) or something like that. On Fri, 2014-09-19 at 14:11 -0500, Marc Schwartz wrote: > On Sep 19, 2014,

Re: [R] ggplot - boxplot and points split by two factors

2014-09-08 Thread Tom Wright
ggplot(data,aes(x = z1, y = x, fill=x2)) + geom_boxplot() + geom_point(alpha=0.5, position=position_jitterdodge(jitter.width=0.1), aes(group=x2)) On Mon, 2014-09-08 at 13:10 -0400, Tom Wright wrote: > Hi, > I'm trying to create a boxplot overlayed with points where

[R] ggplot - boxplot and points split by two factors

2014-09-08 Thread Tom Wright
Hi, I'm trying to create a boxplot overlayed with points where the data is split by two factor groups. So far: x1<-factor(rep(LETTERS[1:4],5)) x2<-factor(rep(letters[1:2],10)) z<-runif(20,0,10) data<-data.frame(x1=x1,x2=x2,z=z) ggplot(data,aes(x=x1,y=z,fill=x2)) + geom_boxplot() +

Re: [R] regex pattern assistance

2014-08-15 Thread Tom Wright
ort still works, not everything has moved to linkedin and stackoverflow. Thanks again, Tom On Fri, 2014-08-15 at 12:18 -0400, Tom Wright wrote: > Hi, > Can anyone please assist. > > given the string > > > x<-"/mnt/AO/AO Data/S01-012/120824/" > > I would lik

[R] regex pattern assistance

2014-08-15 Thread Tom Wright
Hi, Can anyone please assist. given the string > x<-"/mnt/AO/AO Data/S01-012/120824/" I would like to extract "S01-012" require(stringr) > str_match(x,"\\/mnt\\/AO\\/AO Data\\/(.+)\\/+") > str_match(x,"\\/mnt\\/AO\\/AO Data\\/(\\w+)\\/+") both nearly work. I expected I would use something lik

Re: [R] How to write a loop in which i has to be in POSIX format?

2014-05-09 Thread Tom Wright
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")])

Re: [R] Fast way to populate a sparse matrix

2014-04-29 Thread Tom Wright
Thanks everyone, That's a 3000 fold speedup. Now if only I can get the same improvement on the stMincuts iGraph algorithm. On Fri, Apr 25, 2014 at 4:20 AM, Martin Maechler wrote: > > Stefan Evert > > on Fri, 25 Apr 2014 09:09:31 +0200 writes: > > > On 24 Apr 2014, at 23:56, G

[R] Fast way to populate a sparse matrix

2014-04-24 Thread Tom Wright
I need to generate a sparse matrix. Currently I have the data held in two regular matrices. One 'targets' holds the column subscripts while the other 'scores' holds the values. I have written a 'toy' sample below. Using this approach takes about 90 seconds to populate a 3 x 3 element matrix

[R] packages implementing graph algorithms

2014-04-23 Thread Tom Wright
Are there any packages implementing graph search algorithms? I'm looking for the equivalent of matlab findshortestpath in the bioinfomatics toolbox. Thanks, Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] summarizing a dataset on a factor

2014-03-27 Thread Tom Wright
- > David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Tom Wrig

Re: [R] ? ~ ADONIS

2014-03-27 Thread Tom Wright
I'm no expert on the adonis functions by the error you are getting usually means the dataset is not quite what you expected. Are you sure the event dataset is loading as you expect? On Tue, 2014-03-25 at 16:36 -0400, Maggie Wisniewska wrote: > Hello, > I am an R noivce, so excuse my simple questio

[R] summarizing a dataset on a factor

2014-03-27 Thread Tom Wright
Hi all, I've spent too long in matlab land recently and seem to have forgotten my R skillz ;-) I'm sure I'm missing a simple way to do this... Given a data frame id<-rep(1:5,2) eye<-c(rep('l',5),rep('r',5)) age<-rep(round(runif(5,0,12)),2) response<-round(runif(10,1,10)*10)/10 response2<-sample(c(

[R] Analyse the effect of group membership

2014-03-24 Thread Tom Wright
Hi, Given a matrix set.seed(500) matrix(round(runif(100,0,1)), ncol=5, dimnames=list(Subject=1:20, Group=c('A','B','C','D','E'))) Is there an easy way to identify which combinations of groups exist, i.e. subject2 is a member of group 'A+B+D+E' however no one is a member of

[R] problem fitting 2 term exponential with nls

2013-10-25 Thread Tom Wright
Hi, Can anyone explain why the nls function is giving an error? Thanks Tom > head(d) age time 1 23.57 223.0 2 42.63 223.0 3 62.30 222.0 4 32.93 220.5 5 9.37 228.0 6 23.83 227.0 > fit<-nls(d$time~a1*exp(b1*d$age) + a2*exp(b2*d$age)+c ,start(a1=10