[R] Lattice different colours for bars

2013-06-12 Thread Andrew McFadden (Andy)
Hi all Perhaps this is torturous methodology. I was trying to use lattice to produce a barchart showing the number positive and negative over time. I wasn't quite sure how create a different colour for values of arbo$Ikeda in the example below ie red for ikeda and green for neg. library(resha

[R] Lattice graph strips and axes

2011-11-22 Thread Andrew McFadden
Titer) x=barchart( Titer ~ n | Test+Breed, data=heif, layout = c(2,4),between = list(y = c(0.5),x = c(0.5)),scales = list(x = list(alternating = 1, tck = c(1,0)), y = list(alternating = 1, tck = c(1,0))), xlab = "count (n)", ylab = "titer") useOuterStrips(x) Kind regards

[R] Lattice graph help

2011-11-21 Thread Andrew McFadden
,2), scales=list(x=list(at=c(seq(0, 60, by = 15)),tick.number=c(5), labels=c(seq(0, 60, by = 15 ) useOuterStrips(x) Kind regards Andrew McFadden MVS BVSc | Veterinary Epidemiologist, Investigation and Diagnostic Centre | Biosecurity New Zealand Ministry of Agriculture and Forestry | 66 Ward St, Wall

[R] Dealing with null values Aggregate function

2011-05-16 Thread Andrew McFadden
ot;red","red","red","red","blue","blue","blue","blue","bl ue","blue")) aggregate(x = testDF, by = list(testDF$v3), FUN = "mean") For this example I would like to get a mean value for red (v1=4.5; v

[R] Overlapping x axes using Lattice

2011-05-03 Thread Andrew McFadden
esti[,2]+ pesti[,3] ,alternating=TRUE,tick.number=1, stack=TRUE,type = "count", xlab="VNT",rot=c(180,180),draw=FALSE) Thank you in advance. Andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry o

Re: [R] [Requires Classification] Re: Adding a regression line to an xyplot

2010-02-14 Thread Andrew McFadden
Thanks, yes that does the trick, sorry inadvertently left the "tavg" in my example. I haven't used the panel function before looks like it maybe useful. Really appreciate your help. regards Andrew McFadden MVS BVSc | Incursion Investigator (animals), Investigation and Di

[R] Adding a regression line to an xyplot

2010-02-14 Thread Andrew McFadden
ALSE, type=c("p","g"),xlab="a",ylab="b") > I would appreciate your help. > > Kind regards > > andy > > Andrew McFadden MVS BVSc > Incursion Investigator > Investigation & Diagnostic Centres - Wallaceville Biosecurity New &g

Re: [R] [Requires Classification] Re: Subset function: selecting variables within a factor

2009-04-13 Thread Andrew McFadden
Hey Thomas Thanks mate I knew there had to be an easy answer. Thanks for coming to my rescue. Regards Andrew McFadden MVS BVSc | Incursion Investigator (animals), Investigation and Diagnostic Centre | Biosecurity New Zealand Ministry of Agriculture and Forestry | 66 Ward St, Wallaceville

[R] Subset function: selecting variables within a factor

2009-04-13 Thread Andrew McFadden
= c(80,90) I would appreciate your help. Kind regards andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal

[R] Recode of text variables

2009-04-01 Thread Andrew McFadden
","A") x recode(x, "c(A,B)='Treat 1'; else='Treat 2'") recode(x, "1:2='A'; 3='B'") In Microsoft access a simple way of recoding is to join two tables in a query any simple way of doing the same in R? Kind regards Andy And

[R] Adjusting font size in a lattice graph

2009-03-31 Thread Andrew McFadden
ards andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: Investigation and Diagnostic Centre- Wallaceville Box

[R] Combining columns from two dataframes

2009-03-17 Thread Andrew McFadden
ot;2008-08-14" , "2008-08-14","2008-09-20"), format = "%Y-%m-%d"),c(1:6)) names(a)=c("a","b") a b<- data.frame(as.Date(c("2008-07-27","2008-10-01"), format = "%Y-%m-%d"),c(1:2)) names(b)=c("c","d&

[R] Producing a matrix of values

2008-11-11 Thread Andrew McFadden
.sna[src, des] = tra[i, 3] : subscript out of bounds There is something wrong with the highlighted code. I know that there must be some descrepancy in the numbers of values I am using but don't know why or how to fix it. Thanks for your help in advance. Kind regards andy Andrew McFadden M

[R] R loop

2008-06-05 Thread Andrew McFadden
set<-as.Date(c("2008-01-01"), format = "%Y-%m-%d") set for(i in a$date){ if (a$date[i]>set & a$date[i]set +7){a$wk<-2}else {a$wk<-3} } a Kind regards andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville B

[R] Legend in scatterplot and adding regression lines

2008-05-12 Thread Andrew McFadden
panel=panel.superpose ,xlab="Time (weeks)",ylab="Farrowing rate", key = list(points = Rows(trellis.par.get("superpose.symbol"), 1:4), text = list(levels(Dataset$Operator)), columns = 4)) Regards Andy Andrew McFadden MVS BVSc Incursio

[R] Finding unmatched data between two dataframe using several factors

2008-05-11 Thread Andrew McFadden
, "zane"),z=c(10,20,30,40,50)) dat2 I would like to know data that from dat2 that doesn't appear in dat1 based on both the x and y factors ie (A5, dan, 40) and (A6,zane, 50). I have tried two approaches but have not been successful ? nomatch <- subset(dat1, is.element(?

[R] Spatial join between two datasets using x and y co-ordinates

2008-05-06 Thread Andrew McFadden
dog And therefore limit the data in dataset 1 to that which has the same x and y co-ordinates as dataset 2. Any suggestions? Regards Andy Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and

[R] Instantaneous hazard of an event i.e. death

2008-04-16 Thread Andrew McFadden
"hazard.ratio.plot" but lack the experience to know how to code this Anyone be able to help? Regards Andrew Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecurity New Zealand Ministry of Agriculture and Forestry Phone 04 89

[R] Distances between two datasets of x and y co-ordinates

2008-03-12 Thread Andrew McFadden
Hi all I am trying to determine the distances between two datasets of x and y points. The number of points in dataset One is very small i.e. perhaps 5-10. The number of points in dataset Two is likely to be very large i.e. 20,000-30,000. My initial approach was to append the first dataset to the

[R] R code for selecting places spatially and by time

2008-03-06 Thread Andrew McFadden
,2,2,2,1,1) ) date<-as.character(rep(as.Date(c("2008-01-02","2008-01-17","2008-01-01") ,format = "%Y-%m-%d"),c(4,4,2))) cbind(x,y,date) Regards Andrew Andrew McFadden MVS BVSc Incursion Investigator Investigation & Diagnostic Centres - Wallaceville Biosecur

[R] If else in R code

2008-02-07 Thread Andrew McFadden
Hi There I am a new user of "R" and having a few problems a<-c("2001-02-1","NA","NA") a<-as.Date(a,format = "%Y-%m-%d") b<-c("2001-03-1","2001-03-2","2001-03-3") b<-as.Date(b,format = "%Y-%m-%d") c<-data.frame(a,b) I would like to write an if statement where if "a" is not null return "a", if