Hello All: Using the below dataset how can I make a barplot with Date(X) and NumEggs(Y) by Site. Then plot Temp(lineplot) It seems really simple, but I am having a hard time trying to do it by Site. Thanks Date NumEggs Site Temp 1 2008-04-22 0 Massacre Flat (RK424.5) 51.20 2 2008-04-23 0 Massacre Flat (RK424.5) 50.80 3 2008-04-24 0 Massacre Flat (RK424.5) 51.80 4 2008-04-25 0 Massacre Flat (RK424.5) 53.40 5 2008-04-26 0 Massacre Flat (RK424.5) 55.30 6 2008-04-27 0 Massacre Flat (RK424.5) 56.80 7 2008-04-28 0 Massacre Flat (RK424.5) 57.10 8 2008-04-29 0 Massacre Flat (RK424.5) 55.80 9 2008-04-30 0 Massacre Flat (RK424.5) 53.10 10 2008-05-01 0 Massacre Flat (RK424.5) 53.90 11 2008-05-02 9 Massacre Flat (RK424.5) 55.85 12 2008-05-03 0 Massacre Flat (RK424.5) 55.85 13 2008-05-04 0 Massacre Flat (RK424.5) 55.85 14 2008-05-05 0 Massacre Flat (RK424.5) 55.85 15 2008-05-06 1 Massacre Flat (RK424.5) 57.30 16 2008-05-07 0 Antelope Creek (RK377) 56.80 17 2008-05-08 0 Antelope Creek (RK377) 56.50 18 2008-05-09 2 Antelope Creek (RK377) 56.30 19 2008-05-10 0 Antelope Creek (RK377) 56.50 20 2008-05-11 0 Antelope Creek (RK377) 56.50 21 2008-05-12 0 Antelope Creek (RK377) 55.90 22 2008-05-13 2 Antelope Creek (RK377) 56.20 23 2008-05-14 0 Antelope Creek (RK377) 57.70 24 2008-05-15 0 Antelope Creek (RK377) 57.60 25 2008-05-16 0 Antelope Creek (RK377) 58.00 26 2008-05-17 0 Antelope Creek (RK377) 59.20 27 2008-05-18 0 Antelope Creek (RK377) 59.50 28 2008-05-19 0 Antelope Creek (RK377) 58.60 29 2008-05-20 8 Antelope Creek (RK377) 57.50 30 2008-05-21 0 Antelope Creek (RK377) 55.30 31 2008-05-22 0 Antelope Creek (RK377) 55.00 32 2008-05-23 0 Antelope Creek (RK377) 54.70 33 2008-05-24 0 Antelope Creek (RK377) 54.10 34 2008-05-25 0 Antelope Creek (RK377) 53.70 35 2008-05-26 0 Antelope Creek (RK377) 54.30 36 2008-05-27 0 Antelope Creek (RK377) 54.70 37 2008-05-28 0 Antelope Creek (RK377) 55.90 38 2008-05-29 0 Antelope Creek (RK377) 56.30 39 2008-05-30 0 Antelope Creek (RK377) 56.80 40 2008-05-31 0 Antelope Creek (RK377) 57.40 41 2008-06-01 0 Antelope Creek (RK377) 57.50 42 2008-06-02 0 Antelope Creek (RK377) 57.60 43 2008-06-03 0 Antelope Creek (RK377) 57.70 44 2008-06-04 0 Antelope Creek (RK377) 57.10 45 2008-06-05 0 Antelope Creek (RK377) 57.40 46 2008-06-06 14 Antelope Creek (RK377) 57.50 47 2008-06-07 0 Antelope Creek (RK377) 57.40 48 2008-06-08 0 Antelope Creek (RK377) 57.80 49 2008-06-09 0 Antelope Creek (RK377) 58.60 50 2008-06-10 3 Antelope Creek (RK377) 58.80 51 2008-06-11 0 Antelope Creek (RK377) 57.80 52 2008-06-12 0 Antelope Creek (RK377) 58.20 53 2008-06-13 1 Massacre Flat (RK424.5) 58.80 54 2008-06-14 0 Massacre Flat (RK424.5) 59.50 55 2008-06-15 0 Massacre Flat (RK424.5) 59.50 56 2008-06-16 0 Massacre Flat (RK424.5) 59.60 57 2008-06-17 0 Massacre Flat (RK424.5) 59.60 58 2008-06-18 0 Massacre Flat (RK424.5) 58.90 59 2008-06-19 0 Massacre Flat (RK424.5) 58.60 60 2008-06-20 1 RBDD (RK391) 58.80 61 2008-06-21 0 RBDD (RK391) 59.20 62 2008-06-22 0 RBDD (RK391) 58.20 63 2008-06-23 0 RBDD (RK391) 58.60 64 2008-06-24 0 RBDD (RK391) 58.50 65 2008-06-25 0 RBDD (RK391) 58.60 66 2008-06-26 0 RBDD (RK391) 58.60 67 2008-06-27 0 RBDD (RK391) 60.00 Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA
Try this: library(lattice) DF$Date <- as.Date(DF$Date) xyplot(NumEggs ~ Date | Site, DF, type = "h") Also look at ggplot2 for another way. On Fri, Sep 26, 2008 at 2:38 PM, Felipe Carrillo <mazatlanmexico at yahoo.com> wrote:> Hello All: > Using the below dataset how can I make a barplot with > Date(X) and NumEggs(Y) by Site. Then plot Temp(lineplot) > It seems really simple, but I am having a hard time trying to > do it by Site. Thanks > > > Date NumEggs Site Temp > 1 2008-04-22 0 Massacre Flat (RK424.5) 51.20 > 2 2008-04-23 0 Massacre Flat (RK424.5) 50.80 > 3 2008-04-24 0 Massacre Flat (RK424.5) 51.80 > 4 2008-04-25 0 Massacre Flat (RK424.5) 53.40 > 5 2008-04-26 0 Massacre Flat (RK424.5) 55.30 > 6 2008-04-27 0 Massacre Flat (RK424.5) 56.80 > 7 2008-04-28 0 Massacre Flat (RK424.5) 57.10 > 8 2008-04-29 0 Massacre Flat (RK424.5) 55.80 > 9 2008-04-30 0 Massacre Flat (RK424.5) 53.10 > 10 2008-05-01 0 Massacre Flat (RK424.5) 53.90 > 11 2008-05-02 9 Massacre Flat (RK424.5) 55.85 > 12 2008-05-03 0 Massacre Flat (RK424.5) 55.85 > 13 2008-05-04 0 Massacre Flat (RK424.5) 55.85 > 14 2008-05-05 0 Massacre Flat (RK424.5) 55.85 > 15 2008-05-06 1 Massacre Flat (RK424.5) 57.30 > 16 2008-05-07 0 Antelope Creek (RK377) 56.80 > 17 2008-05-08 0 Antelope Creek (RK377) 56.50 > 18 2008-05-09 2 Antelope Creek (RK377) 56.30 > 19 2008-05-10 0 Antelope Creek (RK377) 56.50 > 20 2008-05-11 0 Antelope Creek (RK377) 56.50 > 21 2008-05-12 0 Antelope Creek (RK377) 55.90 > 22 2008-05-13 2 Antelope Creek (RK377) 56.20 > 23 2008-05-14 0 Antelope Creek (RK377) 57.70 > 24 2008-05-15 0 Antelope Creek (RK377) 57.60 > 25 2008-05-16 0 Antelope Creek (RK377) 58.00 > 26 2008-05-17 0 Antelope Creek (RK377) 59.20 > 27 2008-05-18 0 Antelope Creek (RK377) 59.50 > 28 2008-05-19 0 Antelope Creek (RK377) 58.60 > 29 2008-05-20 8 Antelope Creek (RK377) 57.50 > 30 2008-05-21 0 Antelope Creek (RK377) 55.30 > 31 2008-05-22 0 Antelope Creek (RK377) 55.00 > 32 2008-05-23 0 Antelope Creek (RK377) 54.70 > 33 2008-05-24 0 Antelope Creek (RK377) 54.10 > 34 2008-05-25 0 Antelope Creek (RK377) 53.70 > 35 2008-05-26 0 Antelope Creek (RK377) 54.30 > 36 2008-05-27 0 Antelope Creek (RK377) 54.70 > 37 2008-05-28 0 Antelope Creek (RK377) 55.90 > 38 2008-05-29 0 Antelope Creek (RK377) 56.30 > 39 2008-05-30 0 Antelope Creek (RK377) 56.80 > 40 2008-05-31 0 Antelope Creek (RK377) 57.40 > 41 2008-06-01 0 Antelope Creek (RK377) 57.50 > 42 2008-06-02 0 Antelope Creek (RK377) 57.60 > 43 2008-06-03 0 Antelope Creek (RK377) 57.70 > 44 2008-06-04 0 Antelope Creek (RK377) 57.10 > 45 2008-06-05 0 Antelope Creek (RK377) 57.40 > 46 2008-06-06 14 Antelope Creek (RK377) 57.50 > 47 2008-06-07 0 Antelope Creek (RK377) 57.40 > 48 2008-06-08 0 Antelope Creek (RK377) 57.80 > 49 2008-06-09 0 Antelope Creek (RK377) 58.60 > 50 2008-06-10 3 Antelope Creek (RK377) 58.80 > 51 2008-06-11 0 Antelope Creek (RK377) 57.80 > 52 2008-06-12 0 Antelope Creek (RK377) 58.20 > 53 2008-06-13 1 Massacre Flat (RK424.5) 58.80 > 54 2008-06-14 0 Massacre Flat (RK424.5) 59.50 > 55 2008-06-15 0 Massacre Flat (RK424.5) 59.50 > 56 2008-06-16 0 Massacre Flat (RK424.5) 59.60 > 57 2008-06-17 0 Massacre Flat (RK424.5) 59.60 > 58 2008-06-18 0 Massacre Flat (RK424.5) 58.90 > 59 2008-06-19 0 Massacre Flat (RK424.5) 58.60 > 60 2008-06-20 1 RBDD (RK391) 58.80 > 61 2008-06-21 0 RBDD (RK391) 59.20 > 62 2008-06-22 0 RBDD (RK391) 58.20 > 63 2008-06-23 0 RBDD (RK391) 58.60 > 64 2008-06-24 0 RBDD (RK391) 58.50 > 65 2008-06-25 0 RBDD (RK391) 58.60 > 66 2008-06-26 0 RBDD (RK391) 58.60 > 67 2008-06-27 0 RBDD (RK391) 60.00 > > > Felipe D. Carrillo > Supervisory Fishery Biologist > Department of the Interior > US Fish & Wildlife Service > California, USA > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Felipe Carrillo wrote:> Hello All: > Using the below dataset how can I make a barplot with > Date(X) and NumEggs(Y) by Site. Then plot Temp(lineplot) > It seems really simple, but I am having a hard time trying to > do it by Site. Thanks >Hi Felipe, This might do what you want: fdc<-read.table("fdc.dat",header=TRUE) fdc$Date<-as.Date(fdc$Date,format="%Y-%m-%d") library(plotrix) par(mar=c(5,4,4,4)) barp(fdc$NumEggs,names.arg=fdc$Date,xlab="Date",ylab="Number of eggs", main="Number of eggs by date",col=fdc$Site) # a low trick to align the x-axis for the temperature line startDate<-as.Date("2008-04-21",format="%Y-%m-%d") lines(fdc$Date-startDate,fdc$Temp/5) axis(4,at=10:12,labels=c(50,55,60)) mtext("Temperature",side=4,at=5,line=1) legend(2,14,levels(fdc$Site),fill=1:3) Jim