Dear group, I need help on two problems: 1. I am trying to plot density plots for each individual in 8 occasions. I can do this by subject wiht the code below: par(mfrow=c(4,2)) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==0])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==1])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==10])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==11])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==100])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==101])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==110])) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==111])) I have total of 100 subjects and I want to automate this and create for every subject. 2. I want to also plot each subject in the same plot for all 8 scenarios instead of the way I am doing above. Could you please help me with the coding? I tried sm.densityplot.compare but it is giving me an error: missing data are removed missing data are removed Error in if (opt$nbins > 0) { : missing value where TRUE/FALSE needed In addition: Warning message: In cbind(X, group) : number of rows of result is not a multiple of vector length (arg 2) I appreciate your help. Regards, Ayyappa [[alternative HTML version deleted]]
How about providing the data for at least one subject/8 occasions using dput(dataframe)? This line at the bottom of your message: "provide commented, minimal, self-contained, reproducible code" is important. Nothing you sent allows us to reproduce what you are doing and suggest ways to improve it. Looking at your code it seems interesting that the 8 WSEQ values are represented as binary. It may be easier to automate if that were converted to a factor (but perhaps it already is a factor, there is no way to tell from what you have provided). Question 2 refers to a function that does not seem to exist - sm.densityplot.compare - plus you copy the error message but not your function call. How can we possibly tell you what you did wrong? Is this really function sm.density.compare() in package sm? ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Ayyappa Chaturvedula > Sent: Friday, August 03, 2012 10:37 AM > To: r-help at r-project.org > Subject: [R] Density plots > > Dear group, > > I need help on two problems: > > 1. I am trying to plot density plots for each individual in 8 > occasions. > I can do this by subject wiht the code below: > par(mfrow=c(4,2)) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==0])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==1])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==10])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==11])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==100])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==101])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==110])) > plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS > EQ==111])) > > I have total of 100 subjects and I want to automate this and create for > every subject. > > 2. I want to also plot each subject in the same plot for all 8 > scenarios > instead of the way I am doing above. Could you please help me with the > coding? > > I tried sm.densityplot.compare but it is giving me an error: > missing data are removed > missing data are removed > Error in if (opt$nbins > 0) { : missing value where TRUE/FALSE needed > In addition: Warning message: > In cbind(X, group) : > number of rows of result is not a multiple of vector length (arg 2) > > I appreciate your help. > > Regards, > Ayyappa > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
I am sorry either naivety with group. I will follow the instructions from now. Regards, Ayyappa On Aug 3, 2012, at 12:18 PM, "David L Carlson" <dcarlson at tamu.edu> wrote:> How about providing the data for at least one subject/8 occasions using > dput(dataframe)? This line at the bottom of your message: "provide > commented, minimal, self-contained, reproducible code" is important. Nothing > you sent allows us to reproduce what you are doing and suggest ways to > improve it. Looking at your code it seems interesting that the 8 WSEQ values > are represented as binary. It may be easier to automate if that were > converted to a factor (but perhaps it already is a factor, there is no way > to tell from what you have provided). > > Question 2 refers to a function that does not seem to exist - > sm.densityplot.compare - plus you copy the error message but not your > function call. How can we possibly tell you what you did wrong? Is this > really function sm.density.compare() in package sm? > > ---------------------------------------------- > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > >> -----Original Message----- >> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- >> project.org] On Behalf Of Ayyappa Chaturvedula >> Sent: Friday, August 03, 2012 10:37 AM >> To: r-help at r-project.org >> Subject: [R] Density plots >> >> Dear group, >> >> I need help on two problems: >> >> 1. I am trying to plot density plots for each individual in 8 >> occasions. >> I can do this by subject wiht the code below: >> par(mfrow=c(4,2)) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==0])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==1])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==10])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==11])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==100])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==101])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==110])) >> plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WS >> EQ==111])) >> >> I have total of 100 subjects and I want to automate this and create for >> every subject. >> >> 2. I want to also plot each subject in the same plot for all 8 >> scenarios >> instead of the way I am doing above. Could you please help me with the >> coding? >> >> I tried sm.densityplot.compare but it is giving me an error: >> missing data are removed >> missing data are removed >> Error in if (opt$nbins > 0) { : missing value where TRUE/FALSE needed >> In addition: Warning message: >> In cbind(X, group) : >> number of rows of result is not a multiple of vector length (arg 2) >> >> I appreciate your help. >> >> Regards, >> Ayyappa >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >