[R] pairing data using combn with criteria

2012-11-16 Thread bjmjarrett
Dear All, I have a dataframe made up of individual beetles consisting of individual number, family number, mother's family number, father's family number, and sex of the beetle. I would like to pair up the individuals for breeding. I would, however, like to avoid breeding beetles of the same sex

[R] confidence interval as shaded band (lme)

2011-08-08 Thread bjmjarrett
Hi all, I’m trying to plot confidence intervals for the fitted values I get with my lme model in R. Is there any way I can plot this in the form of a shaded band, like the output of geom_smooth() in ggplot2 package. ggplot2 seems to use only lm, glm, gam, loess and rlm as smoothing methods. Any

Re: [R] error in self-made function - cannot deal with objects of length = 1

2011-08-01 Thread bjmjarrett
> But why not just > c(x[1], diff(x))/max(x) So simple! Thank you ever so much Berend. Best wishes, Ben -- View this message in context: http://r.789695.n4.nabble.com/error-in-self-made-function-cannot-deal-with-objects-of-length-1-tp3710555p3710646.html Sent from the R help mailing list a

[R] error in self-made function - cannot deal with objects of length = 1

2011-08-01 Thread bjmjarrett
I have a function to calculate the rate of increase (the difference between the value and the previous value divided by the total number of eggs in a year) of egg production over the course of a year: rate <- function(x){ storage <- matrix(nrow=length(x),ncol=1) storage[1,] <- x[1] /

[R] plot with two y axes BUT unaligned x axis

2011-06-15 Thread bjmjarrett
Hi all, I have scoured the archives of this forum but nothing quite seems to fit the bill... I would like to plot a graph displaying two variables (y axes) that share date as the x axis. However, the date values for each variable are not the same - for example, some parasitoids were not released

Re: [R] Adapting R code for different traps

2011-06-09 Thread bjmjarrett
Hi Jon, Sorry about the lack of information. I'll give the data from one of my traps: (nb. all of the data for each trap is referenced to the start day of the trap. ie ACAP1 started collecting at day 0 but parasitoid releases occurred 266, 259, 225 etc days before collecting took place) Trapc

Re: [R] Adapting R code for different traps

2011-06-09 Thread bjmjarrett
The below works for one trap. Surely there is a quick way to scale it to all of the traps? > temp.ACAP1<-outer(release.days[Trap=="ACAP1"],collection.days.2[Trap=="ACAP1"],'-') > temp.ACAP1<-ifelse(temp.ACAP1>=0,NA,temp.ACAP1) > diff.ACAP1<-apply(temp.ACAP1,2,max,na.rm=TRUE) Thanks Ben -- View

[R] Adapting R code for different traps

2011-06-09 Thread bjmjarrett
Hi all, My code: > temp<-outer(release.days,collection.days,'-') > temp<-ifelse(temp>=0,NA,temp) > release.diff<-apply(temp,2,max,na.rm=TRUE) works for one trap and does what I want. That is, it determines the time difference between the collection date of a trap and date of parasitoid release i

[R] VLOOKUP in R - tried everything.

2011-06-03 Thread bjmjarrett
I am attempting to emulate the VLOOKUP function from Excel in R. I want to compare one column (coll.minus.release) with another (release.days) to get the number of parasitoid released at that time (TotalParasitoids). for example: coll.minus.release release.daysParasitoidTotal -12