This is a level of complexity I've not before encountered and I have not seen the solution in Deepayan Sarkar's book. Briefly, I want to plot values for each of 5 factors over a range of dates to visualize whether the relative values of each factor change over time. The data frame structure is: 'data.frame': 46 obs. of 3 variables: $ sampdate : Date w/ 8 levels " 2000-07-18 ",..: 1 1 1 1 1 2 2 2 ... $ func_feed_grp: Factor w/ 7 levels " Filterer ",..: 1 2 3 6 7 1 7 ... $ pct : num 0.0351 0.7054 0.0442 0.1078 0.1074 ... and the raw data for the data.frame is: 'sampdate','func_feed_grp','pct' '2000-07-18','Filterer',0.0351 '2000-07-18','Gatherer',0.7054 '2000-07-18','Grazer',0.0442 '2000-07-18','Predator',0.1078 '2000-07-18','Shredder',0.1074 '2003-07-08','Filterer',0.1570 '2003-07-08','Gatherer',0.7039 '2003-07-08','Grazer',0.0023 '2003-07-08','Predator',0.0456 '2003-07-08','Shredder',0.0912 '2005-07-13','Filterer',0.0293 '2005-07-13','Gatherer',0.6634 '2005-07-13','Grazer',0.0055 '2005-07-13','Predator',0.0552 '2005-07-13','Shredder',0.2466 '2006-06-28','Filterer',0.0414 '2006-06-28','Gatherer',0.4776 '2006-06-28','Grazer',0.1033 '2006-06-28','Predator',0.2012 '2006-06-28','Shredder',0.1765 '2010-09-14','Filterer',0.0811 '2010-09-14','Gatherer',0.5785 '2010-09-14','Grazer',0.0284 '2010-09-14','Omnivore',0.0131 '2010-09-14','Parasite',0.0018 '2010-09-14','Predator',0.0736 '2010-09-14','Shredder',0.2234 '2011-07-13','Filterer',0.0041 '2011-07-13','Gatherer',0.9011 '2011-07-13','Grazer',0.0563 '2011-07-13','Omnivore',0.0100 '2011-07-13','Parasite',0.0037 '2011-07-13','Predator',0.0247 '2011-07-15','Filterer',0.0385 '2011-07-15','Gatherer',0.8469 '2011-07-15','Grazer',0.0147 '2011-07-15','Omnivore',0.0005 '2011-07-15','Parasite',0.0197 '2011-07-15','Predator',0.0688 '2011-07-15','Shredder',0.0109 '2012-07-11','Filterer',0.1275 '2012-07-11','Gatherer',0.5030 '2012-07-11','Grazer',0.0257 '2012-07-11','Omnivore',0.0008 '2012-07-11','Predator',0.1464 '2012-07-11','Shredder',0.1966 What I want is a line (can be distinguished by color or line style) for each factor in the func_feed_grp column displaying the pct value for each sampdate. Plots and comparisons among multiple streams will follow my learning how to generate these figures. My attempt using xyplot() failed: xyplot(pct ~ sampdate | func_feed_grp, data = 'burns.date.ffg') Error in eval(substitute(groups), data, environment(x)) : invalid 'envir' argument of type 'character' Please point me in the direction to create these plots. Rich
HI, xyplot(pct~sampdate|func_feed_grp,data='burns.date.ffg') #Error in eval(substitute(groups), data, environment(x)) : ?# invalid 'envir' argument of type 'character' ?xyplot(pct~sampdate|func_feed_grp,data=burns.date.ffg) #no error #Not sure about your exact specification, so this would get you started. xyplot(pct~sampdate,data=burns.date.ffg,groups=func_feed_grp,pch=1:7,type="l") A.K. ----- Original Message ----- From: Rich Shepard <rshepard at appl-ecosys.com> To: r-help at r-project.org Cc: Sent: Thursday, August 15, 2013 12:51 PM Subject: [R] Plotting Multiple Factors By Dates With Lattice ? This is a level of complexity I've not before encountered and I have not seen the solution in Deepayan Sarkar's book. Briefly, I want to plot values for each of 5 factors over a range of dates to visualize whether the relative values of each factor change over time. ? The data frame structure is: 'data.frame':??? 46 obs. of? 3 variables: ? $ sampdate? ? : Date w/ 8 levels " 2000-07-18 ",..: 1 1 1 1 1 2 2 2 ... ? $ func_feed_grp: Factor w/ 7 levels " Filterer? ? ? ",..: 1 2 3 6 7 1 7 ... ? $ pct? ? ? ? ? : num? 0.0351 0.7054 0.0442 0.1078 0.1074 ... and the raw data for the data.frame is: 'sampdate','func_feed_grp','pct' '2000-07-18','Filterer',0.0351 '2000-07-18','Gatherer',0.7054 '2000-07-18','Grazer',0.0442 '2000-07-18','Predator',0.1078 '2000-07-18','Shredder',0.1074 '2003-07-08','Filterer',0.1570 '2003-07-08','Gatherer',0.7039 '2003-07-08','Grazer',0.0023 '2003-07-08','Predator',0.0456 '2003-07-08','Shredder',0.0912 '2005-07-13','Filterer',0.0293 '2005-07-13','Gatherer',0.6634 '2005-07-13','Grazer',0.0055 '2005-07-13','Predator',0.0552 '2005-07-13','Shredder',0.2466 '2006-06-28','Filterer',0.0414 '2006-06-28','Gatherer',0.4776 '2006-06-28','Grazer',0.1033 '2006-06-28','Predator',0.2012 '2006-06-28','Shredder',0.1765 '2010-09-14','Filterer',0.0811 '2010-09-14','Gatherer',0.5785 '2010-09-14','Grazer',0.0284 '2010-09-14','Omnivore',0.0131 '2010-09-14','Parasite',0.0018 '2010-09-14','Predator',0.0736 '2010-09-14','Shredder',0.2234 '2011-07-13','Filterer',0.0041 '2011-07-13','Gatherer',0.9011 '2011-07-13','Grazer',0.0563 '2011-07-13','Omnivore',0.0100 '2011-07-13','Parasite',0.0037 '2011-07-13','Predator',0.0247 '2011-07-15','Filterer',0.0385 '2011-07-15','Gatherer',0.8469 '2011-07-15','Grazer',0.0147 '2011-07-15','Omnivore',0.0005 '2011-07-15','Parasite',0.0197 '2011-07-15','Predator',0.0688 '2011-07-15','Shredder',0.0109 '2012-07-11','Filterer',0.1275 '2012-07-11','Gatherer',0.5030 '2012-07-11','Grazer',0.0257 '2012-07-11','Omnivore',0.0008 '2012-07-11','Predator',0.1464 '2012-07-11','Shredder',0.1966 ? What I want is a line (can be distinguished by color or line style) for each factor in the func_feed_grp column displaying the pct value for each sampdate. Plots and comparisons among multiple streams will follow my learning how to generate these figures. ? My attempt using xyplot() failed: xyplot(pct ~ sampdate | func_feed_grp, data = 'burns.date.ffg') Error in eval(substitute(groups), data, environment(x)) : ? invalid 'envir' argument of type 'character' ? Please point me in the direction to create these plots. Rich ______________________________________________ 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.
Hi Rich, It's better to dput() your dataset.? From what you showed: burns.date.ffg<- read.table(text=" 'sampdate','func_feed_grp','pct' '2000-07-18','Filterer',0.0351 '2000-07-18','Gatherer',0.7054 '2000-07-18','Grazer',0.0442 '2000-07-18','Predator',0.1078 '2000-07-18','Shredder',0.1074 '2003-07-08','Filterer',0.1570 '2003-07-08','Gatherer',0.7039 '2003-07-08','Grazer',0.0023 '2003-07-08','Predator',0.0456 '2003-07-08','Shredder',0.0912 '2005-07-13','Filterer',0.0293 '2005-07-13','Gatherer',0.6634 '2005-07-13','Grazer',0.0055 '2005-07-13','Predator',0.0552 '2005-07-13','Shredder',0.2466 '2006-06-28','Filterer',0.0414 '2006-06-28','Gatherer',0.4776 '2006-06-28','Grazer',0.1033 '2006-06-28','Predator',0.2012 '2006-06-28','Shredder',0.1765 '2010-09-14','Filterer',0.0811 '2010-09-14','Gatherer',0.5785 '2010-09-14','Grazer',0.0284 '2010-09-14','Omnivore',0.0131 '2010-09-14','Parasite',0.0018 '2010-09-14','Predator',0.0736 '2010-09-14','Shredder',0.2234 '2011-07-13','Filterer',0.0041 '2011-07-13','Gatherer',0.9011 '2011-07-13','Grazer',0.0563 '2011-07-13','Omnivore',0.0100 '2011-07-13','Parasite',0.0037 '2011-07-13','Predator',0.0247 '2011-07-15','Filterer',0.0385 '2011-07-15','Gatherer',0.8469 '2011-07-15','Grazer',0.0147 '2011-07-15','Omnivore',0.0005 '2011-07-15','Parasite',0.0197 '2011-07-15','Predator',0.0688 '2011-07-15','Shredder',0.0109 '2012-07-11','Filterer',0.1275 '2012-07-11','Gatherer',0.5030 '2012-07-11','Grazer',0.0257 '2012-07-11','Omnivore',0.0008 '2012-07-11','Predator',0.1464 '2012-07-11','Shredder',0.1966 ",sep=",",header=TRUE) ?burns.date.ffg$sampdate<- as.Date(as.character(burns.date.ffg$sampdate)) library(lattice) xyplot(pct~sampdate|func_feed_grp,data=burns.date.ffg) #no error #or xyplot(pct~sampdate,data=burns.date.ffg,groups=func_feed_grp,pch=1:7,type="l") #or xyplot(pct~sampdate|func_feed_grp,data=burns.date.ffg,groups=func_feed_grp,type="l") A.K. ----- Original Message ----- From: Rich Shepard <rshepard at appl-ecosys.com> To: arun <smartpink111 at yahoo.com> Cc: Sent: Thursday, August 15, 2013 4:23 PM Subject: Re: [R] Plotting Multiple Factors By Dates With Lattice On Thu, 15 Aug 2013, arun wrote:> #or > xyplot(pct~sampdate|func_feed_grp,data=burns.date.ffg,groups=func_feed_grp,type="l")A.K., ? That's still producing the same error, but now I have more to look at. Thanks, Rich -- Richard B. Shepard, Ph.D.? ? ? ? ? |? ? ? Have knowledge, will travel. Applied Ecosystem Services, Inc.? | <http://www.appl-ecosys.com>? ? Voice: 503-667-4517? ? ? Fax: 503-667-8863