Initial email: Here is a runable program. When I plot Day and Wgt, it graphs all the data points. All I need is daily.sub1 plotted. I also need each "Tanks" to have its own col or pch. When I run it with the line with pch, it gives me nothing.
rm(list=ls()) Trial<-rep(c(1,2),each=12) Tanks=rep(c("a3","a4","c4","h4"),each=3,2) Day=rep(c(1:12),2) Wgt=c(1:24) daily<-cbind(Trial, Tanks, Day, Wgt) daily daily.sub<-subset(daily, subset=Trial==2 & Tanks=="a4"|Trial==2 & Tanks=="c4"|Trial==2 & Tanks=="h4") daily.sub1<-as.data.frame(daily.sub) attach(daily.sub1) daily.sub1 x11() plot(Day, Wgt) #plot(Day, Wgt, pch=c(2,19,21)[Tanks]) detach(daily.sub1) On Tue, Feb 2, 2010 at 4:38 PM, Rolf Turner <r.tur...@auckland.ac.nz> wrote: > > > What did you ***expect*** or hope to get out of > > ``c(2,19,21)[Tanks]'' ???? > > Please note that this expression makes no sense at all as it stands. > > You apparently want to use plotting symbols 2, 19, and 21 respectively, > depending in some way upon the value in ``Tanks''. Since you have > specified three plotting symbols and ``Tanks'' has *four* distinct > values, this is somewhat mysterious. > > If you would just tell us what you are actually trying to *do* we would > probably be able to tell you how to do it. > > cheers, > > Rolf Turner > > > On 3/02/2010, at 2:19 PM, Marlin Keith Cox wrote: > > > I tried the following and still could not get it to work. I understand > your > > logic, but cannot get this to work. > > > > rm(list=ls()) > > Trial<-rep(c(1,2),each=12) > > Tanks=rep(c("a3","a4","c4","h4"),each=3,2) > > Day=rep(c(1:12),2) > > Wgt=c(1:24) > > daily<-cbind(Trial, Tanks, Day, Wgt) > > daily > > daily.sub<-subset(daily, subset=Trial==2 & Tanks=="a4"|Trial==2 & > > Tanks=="c4"|Trial==2 & Tanks=="h4") > > daily.sub1<-as.data.frame(daily.sub) > > > > x11() > > plot(Day, Wgt, pch=c(2,19,21)[Tanks]) > > with(daily.sub1,c(2,19,21)[Tanks]) > > > > On Tue, Feb 2, 2010 at 1:05 PM, Jeff Laake <jeff.la...@noaa.gov> wrote: > > > >> The problem is with attach. You should have seen an error that the > objects > >> are aliased. You have Tanks in your workspace and in the attached > >> dataframe. It is using the one in your workspace which is not a factor > >> variable. Try: > >> > >> > >> c(2,19,21)[Tanks] > >> with(daily.sub1,c(2,19,21)[Tanks]) > >> > >> Avoid attach and use with which is a temporary attach that won't be > subject > >> to that problem. > >> > >> --jeff > >> > >> On 2/2/2010 11:51 AM, Marlin Keith Cox wrote: > >> > >>> Here is a runable program. When I plot Day and Wgt, it graphs all the > >>> data > >>> points. All I need is daily.sub1 plotted. I also need each "Tanks" to > >>> have > >>> its own col or pch. When I run it with the line with pch, it gives me > >>> nothing. > >>> > >>> rm(list=ls()) > >>> Trial<-rep(c(1,2),each=12) > >>> Tanks=rep(c("a3","a4","c4","h4"),each=3,2) > >>> Day=rep(c(1:12),2) > >>> Wgt=c(1:24) > >>> daily<-cbind(Trial, Tanks, Day, Wgt) > >>> daily > >>> daily.sub<-subset(daily, subset=Trial==2& Tanks=="a4"|Trial==2& > >>> Tanks=="c4"|Trial==2& Tanks=="h4") > >>> daily.sub1<-as.data.frame(daily.sub) > >>> attach(daily.sub1) > >>> daily.sub1 > >>> x11() > >>> plot(Day, Wgt) > >>> #plot(Day, Wgt, pch=c(2,19,21)[Tanks]) > >>> detach(daily.sub1) > >>> > >>> > >>> > >> > > > > > > -- > > M. Keith Cox, Ph.D. > > Alaska NOAA Fisheries, National Marine Fisheries Service > > Auke Bay Laboratories > > 17109 Pt. Lena Loop Rd. > > Juneau, AK 99801 > > keith....@noaa.gov > > marlink...@gmail.com > > U.S. (907) 789-6603 > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > ###################################################################### > Attention: > This e-mail message is privileged and confidential. If you are not the > intended recipient please delete the message and notify the sender. > Any views or opinions presented are solely those of the author. > > This e-mail has been scanned and cleared by MailMarshal > www.marshalsoftware.com > ###################################################################### > -- M. Keith Cox, Ph.D. Alaska NOAA Fisheries, National Marine Fisheries Service Auke Bay Laboratories 17109 Pt. Lena Loop Rd. Juneau, AK 99801 keith....@noaa.gov marlink...@gmail.com U.S. (907) 789-6603 [[alternative HTML version deleted]] ______________________________________________ R-help@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.