[R] Auto Data in the ISLR Package
Dear All: I would like to create a subset data set *with only* all Ford and all Toyota cars from the Auto data set in ISLR R Package. Thank you very much in advance. Please use the following code to see how is the data look like. install.packages("ISLR") library(ISLR) data(Auto) head(Auto) with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Auto Data in the ISLR Package
Dear Eric: Thank you very much. It works nicely. *Just one more thing;* how to create a new variable (say, *Make*) with *Make = Ford* for the ford brand and *Make = T**oyota* for the toyota brand. Once again thank you all. abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Sun, Dec 17, 2017 at 3:10 AM, Eric Berger wrote: > myAuto <- Auto[ grep("ford|toyota",Auto$name),] > > > > On Sat, Dec 16, 2017 at 10:28 PM, Bert Gunter > wrote: > >> I did not care to load the packages -- small reproducible examples are >> preferable, as the posting guide suggests. >> >> But, if I have understood correctly: >> >> See, e.g. ?subset >> >> Alternatively, you can read up on indexing data frames in any good basic R >> tutorial. >> >> Cheers, >> Bert >> >> Bert Gunter >> >> "The trouble with having an open mind is that people keep coming along and >> sticking things into it." >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) >> >> On Sat, Dec 16, 2017 at 11:44 AM, AbouEl-Makarim Aboueissa < >> abouelmakarim1...@gmail.com> wrote: >> >> > Dear All: >> > >> > I would like to create a subset data set *with only* all Ford and all >> > Toyota cars from the Auto data set in ISLR R Package. Thank you very >> much >> > in advance. >> > >> > Please use the following code to see how is the data look like. >> > >> > >> > install.packages("ISLR") >> > library(ISLR) >> > data(Auto) >> > head(Auto) >> > >> > >> > with many thanks >> > abou >> > __ >> > >> > >> > *AbouEl-Makarim Aboueissa, PhD* >> > >> > *Professor of Statistics* >> > >> > *Department of Mathematics and Statistics* >> > *University of Southern Maine* >> > >> > [[alternative HTML version deleted]] >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > 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. >> > >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posti >> ng-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Auto Data in the ISLR Package
Dear Eric: Many Thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Sun, Dec 17, 2017 at 5:25 AM, Eric Berger wrote: > myAuto <- Auto[ grep("ford|toyota",Auto$name),] > myAuto$Make <- NA > myAuto$Make[grep("ford",myAuto$name)] <- "Ford" > myAuto$Make[grep("toyota",myAuto$name)] <- "Toyota" > > Regards, > Eric > > > On Sun, Dec 17, 2017 at 11:58 AM, AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >> Dear Eric: >> >> Thank you very much. It works nicely. >> >> *Just one more thing;* how to create a new variable (say, *Make*) with *Make >> = Ford* for the ford brand and *Make = T**oyota* for the toyota brand. >> >> Once again thank you all. >> >> abou >> >> __ >> >> >> *AbouEl-Makarim Aboueissa, PhD* >> >> *Professor of Statistics* >> >> *Department of Mathematics and Statistics* >> *University of Southern Maine* >> >> >> On Sun, Dec 17, 2017 at 3:10 AM, Eric Berger >> wrote: >> >>> myAuto <- Auto[ grep("ford|toyota",Auto$name),] >>> >>> >>> >>> On Sat, Dec 16, 2017 at 10:28 PM, Bert Gunter >>> wrote: >>> >>>> I did not care to load the packages -- small reproducible examples are >>>> preferable, as the posting guide suggests. >>>> >>>> But, if I have understood correctly: >>>> >>>> See, e.g. ?subset >>>> >>>> Alternatively, you can read up on indexing data frames in any good >>>> basic R >>>> tutorial. >>>> >>>> Cheers, >>>> Bert >>>> >>>> Bert Gunter >>>> >>>> "The trouble with having an open mind is that people keep coming along >>>> and >>>> sticking things into it." >>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) >>>> >>>> On Sat, Dec 16, 2017 at 11:44 AM, AbouEl-Makarim Aboueissa < >>>> abouelmakarim1...@gmail.com> wrote: >>>> >>>> > Dear All: >>>> > >>>> > I would like to create a subset data set *with only* all Ford and all >>>> > Toyota cars from the Auto data set in ISLR R Package. Thank you >>>> very much >>>> > in advance. >>>> > >>>> > Please use the following code to see how is the data look like. >>>> > >>>> > >>>> > install.packages("ISLR") >>>> > library(ISLR) >>>> > data(Auto) >>>> > head(Auto) >>>> > >>>> > >>>> > with many thanks >>>> > abou >>>> > __ >>>> > >>>> > >>>> > *AbouEl-Makarim Aboueissa, PhD* >>>> > >>>> > *Professor of Statistics* >>>> > >>>> > *Department of Mathematics and Statistics* >>>> > *University of Southern Maine* >>>> > >>>> > [[alternative HTML version deleted]] >>>> > >>>> > __ >>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> > 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. >>>> > >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> __ >>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide http://www.R-project.org/posti >>>> ng-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>> >>> >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Draw Overlapping Circles with shaded tracks
Dear All: I am wondering if there is a way in R to draw these two circles with shaded tracks in both circles using R, and make both circles uncovered. I am trying to make it in MS words, but I could not. Your help will be highly appreciated. In my previous post I added the image of the two circles, but the post never published. I just thought to resent the post again without the image. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Draw Overlapping Circles with shaded tracks
Dear All: Thank you very much for all of you. I just have one more thing. Is there a way to fill the borders with small dots, may be different sizes. I tried to do it, but it looks ugly. Here what I tried: library(plotrix) plot(0:10, 0:10, type="n",axes=FALSE,xlab="",ylab="") 0:5, draw.circle(4,5,radius=3,border="#ffaa", lwd=75) draw.circle(4,5,radius=2.50,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.55,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.60,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.65,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.70,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.75,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.80,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.85,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.90,border="red",lty=3,lwd=3) draw.circle(4,5,radius=2.95,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.0,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.05,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.10,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.15,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.20,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.25,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.30,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.35,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.40,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.45,border="red",lty=3,lwd=3) draw.circle(4,5,radius=3.50,border="red",lty=3,lwd=3) draw.circle(7.5,5,radius=3,border="#ffaa",lwd=75) draw.circle(7.5,5,radius=2.50,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.55,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.60,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.65,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.70,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.75,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.80,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.85,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.90,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=2.95,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.0,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.05,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.10,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.15,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.20,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.25,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.30,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.35,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.40,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.45,border="blue",lty=3,lwd=3) draw.circle(7.5,5,radius=3.50,border="blue",lty=3,lwd=3) Once again thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Sun, Dec 31, 2017 at 8:40 AM, Marc Girondot via R-help < r-help@r-project.org> wrote: > Another solution: > > library("HelpersMG") plot(0:10,type="n",axes=FALSE,xlab="",ylab="", > asp=1) ellipse(center.x = 3, center.y = 5, radius.x = 5, radius.y = 5, > lwd=10, col=NA, border=rgb(red = 1, green = 0, blue=0, alpha = 0.5)) > ellipse(center.x = 8, center.y = 5, radius.x = 5, radius.y = 5, lwd=10, > col=NA, border=rgb(red = 0, green = 1, blue=0, alpha = 0.5)) > > > (Without the graphic example, it is difficult to know what tit was > supposed to do !) > > Marc > > Le 31/12/2017 à 14:10, John Kane via R-help a écrit : > > That code nees the plotrix package: > > library(plotrix) > > pdf("circles.pdf") > > plot(0:10,type="n",axes=FALSE,xlab="",ylab="") > > draw.circle(4,5,radius=3,border="#ff0000aa",lwd=10) > > draw.circle(6,5,radius=3,border="#ffaa",lwd=10) > > dev.off() > > > > > > > > > > On Friday, December 29, 2017, 6:06:32 PM EST, Jim Lemon < > drjimle...@gmail.com> wrote: > > > > Hi Abou, > > Without an illustration it's hard to work out what you want. here is a > > simple example of two circles using semi-transparency. Is this any > > help? > > > > pdf("circles.pdf") > > plot(0:10,type="n",axes=FALSE,xlab=""
[R] svm
Dear All: I am trying to use the R function "svm" with "type =C-classification" , but I got the following error message SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*, kernel='linear',scale=FALSE) *Error in eval(predvars, data, env) : object 'type' not found* I am wondering if I should install a specific R package(s). *Here is my codes:* feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75, 1,3.5,4,4,5,5.5,6,6,6.5) length(feature.x1) feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1,1, 3.5,3.5,5.8,3,4,4.5,5,4,1,4,3) length(feature.x2) y <- c(rep(-1,11), rep(1,11)) typey<-as.factor(y) my.data.x1x2y <- data.frame(feature.x1, feature.x2, typey) my.data.x1x2y install.packages("e1071") library(e1071) SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, type='C-classification', kernel='linear',scale=FALSE) plot(my.data.x1x2y[,-3],col=(typey+3)/2, pch=18, xlim=c(-1,6), ylim=c(-1,6)) box(lwd = 2, col="darkgreen") with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] svm --- type~.
Dear All: Just fixed where is the problem I am trying to use the R function "svm" with "type~." , but I got the following error message SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*, kernel='linear',scale=FALSE) *Error in eval(predvars, data, env) : object 'type' not found* I am wondering if I should install a specific R package(s). *Here is my codes:* feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75, 1,3.5,4,4,5,5.5,6,6,6.5) length(feature.x1) feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1,1, 3.5,3.5,5.8,3,4,4.5,5,4,1,4,3) length(feature.x2) y <- c(rep(-1,11), rep(1,11)) typey<-as.factor(y) my.data.x1x2y <- data.frame(feature.x1, feature.x2, typey) my.data.x1x2y install.packages("e1071") library(e1071) SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, type='C-classification', kernel='linear',scale=FALSE) plot(my.data.x1x2y[,-3],col=(typey+3)/2, pch=18, xlim=c(-1,6), ylim=c(-1,6)) box(lwd = 2, col="darkgreen") with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] svm --- type~.
got it thank you abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Wed, Jan 10, 2018 at 2:41 PM, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > Dear All: Just fixed where is the problem > > > I am trying to use the R function "svm" with "type~." , but I got the > following error message > > > SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, *type='C-classification'*, > kernel='linear',scale=FALSE) > > *Error in eval(predvars, data, env) : object 'type' not found* > > > I am wondering if I should install a specific R package(s). > > > > *Here is my codes:* > > > feature.x1 <- c(0.25,0.5,1,1,1.5,2,2.25,2.5,2,1,3, 5,3.75, > 1,3.5,4,4,5,5.5,6,6,6.5) > > length(feature.x1) > > > > feature.x2 <- c(2,3.5,1,2.5,1.75,2,1.75,1.5,2.5,1,1, > 3.5,3.5,5.8,3,4,4.5,5,4,1,4,3) > > length(feature.x2) > > > y <- c(rep(-1,11), rep(1,11)) > > typey<-as.factor(y) > > > my.data.x1x2y <- data.frame(feature.x1, feature.x2, typey) > > my.data.x1x2y > > > > install.packages("e1071") > > library(e1071) > > > > SVM.Model1 <- svm(type ~ ., data=my.data.x1x2y, type='C-classification', > kernel='linear',scale=FALSE) > > plot(my.data.x1x2y[,-3],col=(typey+3)/2, pch=18, xlim=c(-1,6), > ylim=c(-1,6)) > > box(lwd = 2, col="darkgreen") > > > > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] shading (fill) the area between two lines
Dear All: I am trying to shade the area between the two lines; *line 1* and *line 2*. You can use this code as an example. x100<-c(-1,1,2,3,4,5,6,3) y100<-c(4,5,3,1,4,4,2,-1) plot(x100,y100) *# line1* abline(a=-(Beta0-1)/Beta[1,2], b=-Beta[1,1]/Beta[1,2], lwd = 3, col="skyblue", lty=3) # lty=3, *# line 2* abline(a=-(Beta0+1)/Beta[1,2], b=-Beta[1,1]/Beta[1,2], lwd = 3, col="skyblue", lty=3) # lty=3, thank you very much for your help with thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Calculate LC50
Dear All: good morning I need helps with the calculation of the *LC50* from the data below x<-c(0,0.3,0.7,1,4,10) y<-c(100,86,65,51.3,19.2,7.4) yxreg<-lm(y~x) any help will be highly appreciated. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Adding Axis value to R Plot
Dear All: good morning within this code, please see below, plot(0:1.0, 0:1.0, type = "n", yaxs = "i", xaxs = "i", xaxt = "n", yaxt = "n", xlab = "Age", ylab = "Distance (ft)", cex.lab=1.5) grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2) Is there a way to force R to add the following Axis ticks to this plot xticks <- c(15,25,35,45,55,65,75,85) yticks <- c(300,400,500,600) with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Adding Axis value to R Plot
Dear Jim: many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Mon, Jun 25, 2018 at 7:25 PM, Jim Lemon wrote: > Hi Abou, > You can't display an axis if it is not in the range of the plot. I > think you want: > > plot(0,type="n",yaxs="i",xaxs="i",xaxt="n",yaxt="n",xlim=c(15,85), > ylim=c(300,600),xlab="Age",ylab="Distance (ft)",cex.lab=1.5) > grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2) > xticks <- c(15,25,35,45,55,65,75,85) > yticks <- c(300,400,500,600) > axis(1,at=xticks) > axis(2,at=yticks) > > Note the addition of xlim and ylim arguments. > > Jim > > On Tue, Jun 26, 2018 at 12:36 AM, AbouEl-Makarim Aboueissa > wrote: > > Dear All: good morning > > > > > > > > within this code, please see below, > > > > > > plot(0:1.0, 0:1.0, type = "n", yaxs = "i", xaxs = "i", xaxt = "n", yaxt > = > > "n", xlab = "Age", ylab = "Distance (ft)", cex.lab=1.5) > > grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2) > > > > > > > > Is there a way to force R to add the following Axis ticks to this plot > > > > > > xticks <- c(15,25,35,45,55,65,75,85) > > yticks <- c(300,400,500,600) > > > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor of Statistics* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Install package "diagram"
Dear All: I am trying to install the package "diagram". It is in the list. But when I selected the package to install it, it says: Question: "would you like to use a personal library instead?" I selected No. Then it says > utils:::menuInstallPkgs() Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : 'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : unable to install packages > Any help will be appreciated. with many thanks abou -- __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Fwd: Install package "diagram"
Dear All: When I selected "yes" to the question Question: "would you like to use a personal library instead?", it works thanks any way abou -- Forwarded message ------ From: AbouEl-Makarim Aboueissa Date: Wed, Aug 16, 2017 at 11:58 AM Subject: Install package "diagram" To: r-help@r-project.org Dear All: I am trying to install the package "diagram". It is in the list. But when I selected the package to install it, it says: Question: "would you like to use a personal library instead?" I selected No. Then it says > utils:::menuInstallPkgs() Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : 'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : unable to install packages > Any help will be appreciated. with many thanks abou -- __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine -- __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Load R data files
Dear All: I am trying to load an R data set, but I got the following message. Please see below. The file is there. setwd("F:/Fall_2017/5-STA574/2-Notes/1-R/1-R_new/chapter4-Entering_Data") datahs0csv <- read.table("hs0.csv", header=T, sep=",") attach(datahs0csv) detach(datahs0csv) rm(list=ls()) Then I tried to reload the data, but I got this error message. I am not sure what was wrong. *> load("datahs0csv.rda")* Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection In addition: Warning message: In readChar(con, 5L, useBytes = TRUE) : cannot open compressed file 'datahs0csv.rda', probable reason 'No such file or directory' Any help will be appreciated. with thanks abou __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Load R data files
Dear All: It was saved, but there was a space somewhere. So it works for me now. I do have another similar problem. I saved an R data file save(datahs0csv,file=" F:\Fall_2017\5-STA574\2-Notes\1-R\1-R_new\chapter4-Entering_Data/datahs0csv2 .rda") *The new R data file "*datahs0csv2.rda*" is in the directory.* I tried to load the file "" to R, but I got an error message. Please see below. > *load(file="F:/Fall_2017/5-STA574/2-Notes/1-R/1-R_new/chapter4-Entering_Data/datahs0csv2.rda")* > It seems for me that the file was loaded to R. But when I typed the data name, it says that the not found. > *datahs0csv2* *Error: object 'datahs0csv2' not found* with many thanks abou On Tue, Sep 12, 2017 at 2:53 PM, Ulrik Stervbo wrote: > Hi Abou, > > You haven't saved the datahs0csv. > > When you are done manipulating datahs0csv you can use save(datahs0csv, > file = 'datahs0csv.rda'). Then you should be able to load the data. > HTH > Ulrik > > On Tue, 12 Sep 2017, 20:46 AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >> Dear All: >> >> I am trying to load an R data set, but I got the following message. Please >> see below. The file is there. >> >> setwd("F:/Fall_2017/5-STA574/2-Notes/1-R/1-R_new/chapter4-Entering_Data") >> >> datahs0csv <- read.table("hs0.csv", header=T, sep=",") >> attach(datahs0csv) >> >> detach(datahs0csv) >> rm(list=ls()) >> >> Then I tried to reload the data, but I got this error message. I am not >> sure what was wrong. >> >> *> load("datahs0csv.rda")* >> >> Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection >> In addition: Warning message: >> In readChar(con, 5L, useBytes = TRUE) : >> cannot open compressed file 'datahs0csv.rda', probable reason 'No such >> file or directory' >> >> >> Any help will be appreciated. >> >> >> with thanks >> abou >> >> __ >> AbouEl-Makarim Aboueissa, PhD >> Professor of Statistics >> Department of Mathematics and Statistics >> University of Southern Maine >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > -- __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Load R data files
Dear Ulrik: thank you very much abou On Tue, Sep 12, 2017 at 3:34 PM, Ulrik Stervbo wrote: > The object you load has the same name as the object you saved. In this > case datahs0csv and not the name of the file sans .rda > > On Di., 12. Sep. 2017, 21:26 AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >> Dear All: >> >> >> It was saved, but there was a space somewhere. So it works for me now. >> >> I do have another similar problem. >> >> I saved an R data file >> >> >> save(datahs0csv,file=" F:\Fall_2017\5-STA574\2-Notes\ >> 1-R\1-R_new\chapter4-Entering_Data/datahs0csv2.rda") >> >> *The new R data file "*datahs0csv2.rda*" is in the directory.* >> >> I tried to load the file "" to R, but I got an error message. Please see >> below. >> >> > >> *load(file="F:/Fall_2017/5-STA574/2-Notes/1-R/1-R_new/chapter4-Entering_Data/datahs0csv2.rda")* >> > >> It seems for me that the file was loaded to R. But when I typed the data >> name, it says that the not found. >> >> > *datahs0csv2* >> >> *Error: object 'datahs0csv2' not found* >> >> >> with many thanks >> abou >> >> On Tue, Sep 12, 2017 at 2:53 PM, Ulrik Stervbo >> wrote: >> >>> Hi Abou, >>> >>> You haven't saved the datahs0csv. >>> >>> When you are done manipulating datahs0csv you can use save(datahs0csv, >>> file = 'datahs0csv.rda'). Then you should be able to load the data. >>> HTH >>> Ulrik >>> >>> On Tue, 12 Sep 2017, 20:46 AbouEl-Makarim Aboueissa < >>> abouelmakarim1...@gmail.com> wrote: >>> >>>> Dear All: >>>> >>>> I am trying to load an R data set, but I got the following message. >>>> Please >>>> see below. The file is there. >>>> >>>> setwd("F:/Fall_2017/5-STA574/2-Notes/1-R/1-R_new/chapter4- >>>> Entering_Data") >>>> >>>> datahs0csv <- read.table("hs0.csv", header=T, sep=",") >>>> attach(datahs0csv) >>>> >>>> detach(datahs0csv) >>>> rm(list=ls()) >>>> >>>> Then I tried to reload the data, but I got this error message. I am not >>>> sure what was wrong. >>>> >>>> *> load("datahs0csv.rda")* >>>> >>>> Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection >>>> In addition: Warning message: >>>> In readChar(con, 5L, useBytes = TRUE) : >>>> cannot open compressed file 'datahs0csv.rda', probable reason 'No such >>>> file or directory' >>>> >>>> >>>> Any help will be appreciated. >>>> >>>> >>>> with thanks >>>> abou >>>> >>>> __ >>>> AbouEl-Makarim Aboueissa, PhD >>>> Professor of Statistics >>>> Department of Mathematics and Statistics >>>> University of Southern Maine >>>> >>>> [[alternative HTML version deleted]] >>>> >>>> __ >>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> 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. >>>> >>> >> >> >> -- >> __ >> AbouEl-Makarim Aboueissa, PhD >> Department of Mathematics and Statistics >> University of Southern Maine >> > -- __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Graph f(x) = 1/x
Dear All: good morning I am trying to graph the function y=f(x)=1/x over the interval (-5,5). But I am getting an error message. Please see below. I am getting the error message: *Error in xy.coords(x, y, xlabel, ylabel, log) : * * 'x' and 'y' lengths differ* x x <- seq(-5, 5, 0.01) y < 1/x plot(x,y, type='l', xlim=c(-5, 5), ylim=c(-5, 5), xlab = "x", ylab = "f(x) = 1/x", lwd = 2, col ="red") abline(h=0, lty=2, col = "blue") abline(v=0, lty=2, col = "blue") axis(1) axis(2) title(main="The Graph of f(x) = 1/x") any help will be highly appreciated. with thanks abou __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Graph f(x) = 1/x
Dear Zeileis: Thank you very much abou On Tue, Sep 19, 2017 at 4:13 AM, Achim Zeileis wrote: > > > On Tue, 19 Sep 2017, AbouEl-Makarim Aboueissa wrote: > > Dear All: good morning >> >> I am trying to graph the function y=f(x)=1/x over the interval (-5,5). But >> I am getting an error message. Please see below. >> >> I am getting the error message: *Error in xy.coords(x, y, xlabel, ylabel, >> log) : * >> * 'x' and 'y' lengths differ* >> > > You have "y < 1/x" rather than "y <- 1/x"! So "y" is not assigned and > presumably you have some old "y" variable in your global environment that > is used and does not match the length of "x". > > >> x >> >> x <- seq(-5, 5, 0.01) >> y < 1/x >> >> plot(x,y, type='l', xlim=c(-5, 5), ylim=c(-5, 5), xlab = "x", ylab = "f(x) >> = 1/x", lwd = 2, col ="red") >> >> abline(h=0, lty=2, col = "blue") >> abline(v=0, lty=2, col = "blue") >> axis(1) >> axis(2) >> title(main="The Graph of f(x) = 1/x") >> >> >> any help will be highly appreciated. >> >> >> with thanks >> abou >> __ >> AbouEl-Makarim Aboueissa, PhD >> Professor of Statistics >> Department of Mathematics and Statistics >> University of Southern Maine >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posti >> ng-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> -- __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Install the Package "ISwR"
Dear All: good morning I am trying to install the "" package, but I am getting this error message. *> utils:::menuInstallPkgs()* *Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :* * 'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable* *Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : * * unable to install packages* *>* When I select the ISwR package from the list I got I message saying "*Question? Would you like to use a personal library instead?*" I answered by No. Then it gives me the above message. Thank you for your time. with thanks abou __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Install the Package "ISwR"
I simply answered Yes, Yes, Yes. It works now. thank you very much abou On Wed, Sep 20, 2017 at 6:09 AM, Eric Berger wrote: > What if you answer 'Yes' ? > > On Wed, Sep 20, 2017 at 1:03 PM, AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >> Dear All: good morning >> >> I am trying to install the "" package, but I am getting this error >> message. >> >> >> *> utils:::menuInstallPkgs()* >> *Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, >> type >> = type) :* >> * 'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable* >> *Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type >> = >> type) : * >> * unable to install packages* >> *>* >> >> When I select the ISwR package from the list I got I message saying >> "*Question? >> Would you like to use a personal library instead?*" I answered by No. Then >> it gives me the above message. >> >> >> Thank you for your time. >> >> >> with thanks >> abou >> __ >> AbouEl-Makarim Aboueissa, PhD >> Professor of Statistics >> Department of Mathematics and Statistics >> University of Southern Maine >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posti >> ng-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > -- __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Remove spacing at the top and bottom of a plot
Dear All: Is there is away to remove spacing at the top and the bottom of a plot? If so, any help will be appreciated. Please use this code as an example: par(mfrow=c(1,2)) lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) n.draw <- 100 mu <- 9 n <- 24 SD <- sd(lizard) draws <- matrix(rnorm(n.draw * n, mu, SD), n) get.conf.int <- function(x) { t.test(x)$conf.int } conf.int <- apply(draws, 2, get.conf.int) plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail length", ylab = "sample run") for (i in 1:n.draw) { if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){ lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green') lines(conf.int[, i], rep(i, 2), lwd = 2) } else { lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red') } } abline(v = 9, lwd = 3, col='blue') lty = 2, Thank you very much for your help. with many thanks abou __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Remove spacing at the top and bottom of a plot
Dear David: Thank you very much. with thanks abou On Sun, Sep 24, 2017 at 5:28 PM, David L Carlson wrote: > The default margins are set as lines below, left, top, and right using > mar=c(5.1, 4.1, 4.1, 2.1). Just change the top margin something like 1.1: > > par(mfrow=c(1,2), mar=c(5.1, 4.1, 1.1, 2.1)) > > --- > David L. Carlson > Department of Anthropology > Texas A&M University > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > AbouEl-Makarim Aboueissa > Sent: Sunday, September 24, 2017 3:59 PM > To: R mailing list > Subject: [R] Remove spacing at the top and bottom of a plot > > Dear All: > > Is there is away to remove spacing at the top and the bottom of a plot? If > so, any help will be appreciated. > > > Please use this code as an example: > > > par(mfrow=c(1,2)) > > > lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8, > 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) > > n.draw <- 100 > mu <- 9 > n <- 24 > SD <- sd(lizard) > draws <- matrix(rnorm(n.draw * n, mu, SD), n) > > get.conf.int <- function(x) { > t.test(x)$conf.int > } > > conf.int <- apply(draws, 2, get.conf.int) > > plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail > length", ylab = "sample run") > > for (i in 1:n.draw) { > if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){ > lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green') > lines(conf.int[, i], rep(i, 2), lwd = 2) > } > else { > lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red') > } > } > > abline(v = 9, lwd = 3, col='blue') lty = 2, > > > > > > Thank you very much for your help. > > > with many thanks > abou > __ > AbouEl-Makarim Aboueissa, PhD > > Professor of Statistics > Department of Mathematics and Statistics > University of Southern Maine > > [[alternative HTML version deleted]] > > __________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > -- __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Shift the normal curve to the top or near to the top of the histogram
Dear All: One more thing. I want to add the normal curve to the histogram. Is there away to stretch the peak of the curve to the top of the histogram or at least near to the top of the histogram. Please see the code below. Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) x<-seq(5,12, 0.001) hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail Lengths") curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), add=TRUE, col=2, lwd = 2) with many thanks abou __________ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Shift the normal curve to the top or near to the top of the histogram
Dear Jim: Thank you very much abou On Sun, Sep 24, 2017 at 8:18 PM, Jim Lemon wrote: > Hi Abou, > Try this: > > library(plotrix) > curve(rescale(dnorm(x > ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), > c(0,6)),add=TRUE, col=2, lwd = 2) > > Jim > > > On Mon, Sep 25, 2017 at 9:35 AM, AbouEl-Makarim Aboueissa > wrote: > > Dear All: > > > > One more thing. > > > > I want to add the normal curve to the histogram. Is there away to stretch > > the peak of the curve to the top of the histogram or at least near to the > > top of the histogram. > > > > Please see the code below. > > > > > > Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, > > 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) > > > > x<-seq(5,12, 0.001) > > > > hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail > > Lengths") > > > > curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail. > lengths)), > > add=TRUE, col=2, lwd = 2) > > > > > > > > with many thanks > > abou > > __ > > AbouEl-Makarim Aboueissa, PhD > > Professor of Statistics > > Department of Mathematics and Statistics > > University of Southern Maine > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > -- __ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] R Codes for Introduction to Data Mining
Dear All: good morning I am going to teach a course title "Introduction to Statistical Data Mining", and I am using the book titled "*Introduction to Data Mining (Second Edition)*" by Kumar and etal. I am wondering if someone have R codes/functions for examples and exercises given in this textbook. I thank you all in advance. with many thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] R Codes for Introduction to Data Mining
Dear David: Thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Aug 21, 2018 at 12:07 PM David L Carlson wrote: > There are some materials at > > https://www-users.cs.umn.edu/~kumar001/dmbook/index.php > > Michael Hahsler has code examples at > > https://mhahsler.github.io/Introduction_to_Data_Mining_R_Examples/ > https://github.com/mhahsler/Introduction_to_Data_Mining_R_Examples > > > David L. Carlson > Department of Anthropology > Texas A&M University > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > AbouEl-Makarim Aboueissa > Sent: Tuesday, August 21, 2018 10:48 AM > To: R mailing list > Subject: [R] R Codes for Introduction to Data Mining > > Dear All: good morning > > > I am going to teach a course title "Introduction to Statistical Data > Mining", and I am using the book titled "*Introduction to Data Mining > (Second Edition)*" by Kumar and etal. > > I am wondering if someone have R codes/functions for examples and exercises > given in this textbook. > > I thank you all in advance. > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Bar Graph
Dear All: I do need your help on how to add frequency to bar plot on the top of each bar. here is the R code. *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", "Other") * *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for Death Data", ylab="Number of Death", xlab="Cause of Death") * Thank you very much for your help in advance. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
Dear Bert: thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Sep 11, 2018 at 2:47 PM Bert Gunter wrote: > Not quite -- he wanted the frequencies not the counts. So something > like this (using the adj argument to center the frequencies above each > bar: > > bp <-barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar > Graph for Death Data", ylab="Number of Deaths", xlab="Cause of Death", > ylim = c(0,500) ) > > text(bp, y = Number.of.Death + 30, adj = .5, > lab = round(Number.of.Death/sum(Number.of.Death),2)) > > Cheers, > Bert > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Tue, Sep 11, 2018 at 11:02 AM AbouEl-Makarim Aboueissa > wrote: > > > > Dear All: > > > > > > I do need your help on how to add frequency to bar plot on the top of > each > > bar. > > > > > > here is the R code. > > > > > > *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* > > > > *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", > > "Other") * > > > > *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for > > Death Data", ylab="Number of Death", xlab="Cause of Death") * > > > > > > > > Thank you very much for your help in advance. > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor of Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
Dear Rui: thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Sep 11, 2018 at 2:24 PM Rui Barradas wrote: > Hello, > > Use function text() with the return of barplot() as x value and > Number.of.Death as y. > Note that the limits of the y axis are not the automatic ones. > > > > bp <- barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Graph > for > Death Data", ylab="Number of Death", xlab="Cause of Death", ylim = c(0, > 500)) > > text(x = bp, y = Number.of.Death, labels = Number.of.Death, pos = 3) > > > Hope this helps, > > Rui Barradas > > On 11-09-2018 19:02, AbouEl-Makarim Aboueissa wrote: > > Dear All: > > > > > > I do need your help on how to add frequency to bar plot on the top of > each > > bar. > > > > > > here is the R code. > > > > > > *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* > > > > *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", > > "Other") * > > > > *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for > > Death Data", ylab="Number of Death", xlab="Cause of Death") * > > > > > > > > Thank you very much for your help in advance. > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor of Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Remove plot axis values in dotplot graph
Dear All: One more thing. I want to Remove the plot x-axis values in dotplot graph. I am trying to use xaxt = "n", but it seems NOT working. Also after removing the x-axis values, I want to use the command axis(1, at=0:16, cex.axis=1) to add x-axis values from 0 to 16, but it seems not working as expect. Honey.Dosage<-c(12,11,15,11,10,13,10,4,15,16,9,14,10,6,10,8,11,12,12,8,12,9,11,15,10,15,9,13,8,12,10,8,9,5,12) DM.Dosage<-c(4,6,9,4,7,7,7,9,12,10,11,6,3,4,9,12,7,6,8,12,12,4,12,13,7,10,13,9,4,4,10,15,9) No.Dosage<-c(5,8,6,1,0,8,12,8,7,7,1,6,7,7,12,7,9,7,9,5,11,9,5,6,8,8,6,7,10,9,4,8,7,3,1,4,3) scores<-c(Honey.Dosage,DM.Dosage,No.Dosage) min(scores) max(scores) dotchart(scores,cex=1.5, pch = 18, col=c(1:3), xaxt = "n", main="Dot Plot child’s cough data", xlab="cough Scores") axis(1, at=0:16, cex.axis=1.5) with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Install R into mac
Dear All: One of my students has mac software OS X Yosemite, Version 10.10.5. He could not install R into his mac laptop. I am not familiar with mac at all. Any help will be appreciated. with thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Make Month variable be called “May”,“June” etc., instead of a numeric quantity 5,6, etc.
Dear All: *Re:* How to make the Month variable be called “May”,“June”, "July", "August", "September" instead of a numeric quantity (5,6,7,8,9) In the airquality data set, please see the code below; How to make the Month variable be called “May”,“June”, "July", "August", "September" instead of a numeric quantity (5,6,7,8,9) data(airquality) head(airquality) Making Day and Month categorical variables airquality$Day <- factor(airquality$Day) airquality$Month <- factor(airquality$Month) head(airquality) > head(airquality) Ozone Solar.R Wind Temp Month Day 141 190 7.4 67 5 1 236 118 8.0 72 5 2 312 149 12.6 74 5 3 418 313 11.5 62 5 4 5NA NA 14.3 56 5 5 628 NA 14.9 66 5 6 > Thank you very much for your help in advance with thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Make Month variable be called “May”,“June” etc., instead of a numeric quantity 5,6, etc.
Dear Jeff: thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Sep 20, 2018 at 1:37 PM Jeff Newmiller wrote: > airquality$Month <- factor(airquality$Month, levels=1:12, labels= > month.name ) > > On September 20, 2018 10:14:41 AM PDT, AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >Dear All: > > > >*Re:* How to make the Month variable be called “May”,“June”, "July", > >"August", "September" instead of a numeric quantity (5,6,7,8,9) > > > > > >In the airquality data set, please see the code below; How to make the > >Month variable be called “May”,“June”, "July", "August", "September" > >instead of a numeric quantity (5,6,7,8,9) > > > > > > > >data(airquality) > > > >head(airquality) > > > > > > Making Day and Month categorical variables > > > > > >airquality$Day <- factor(airquality$Day) > > > >airquality$Month <- factor(airquality$Month) > > > > > >head(airquality) > > > > > >> head(airquality) > > Ozone Solar.R Wind Temp Month Day > >141 190 7.4 67 5 1 > >236 118 8.0 72 5 2 > >3 12 149 12.6 74 5 3 > >418 313 11.5 62 5 4 > >5NA NA 14.3 56 5 5 > >628 NA 14.9 66 5 6 > >> > > > > > > > >Thank you very much for your help in advance > > > > > >with thanks > >abou > >__ > > > > > >*AbouEl-Makarim Aboueissa, PhD* > > > >*Professor of Statistics* > >*Graduate Coordinator* > > > >*Department of Mathematics and Statistics* > >*University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >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. > > -- > Sent from my phone. Please excuse my brevity. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] R Companion to Linear Statistical Models by KNNL
Dear All: I am wondering if there is An R Companion to Linear Statistical Models *by *Kutner, Nachtsheim, Neter, and Li. Any help would be appreciated. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Packages
Dear All: After installing the packages "car" and "alr3", I got the following error messages: > library(car) Error in library(car) : there is no package called ‘car’ > library(alr3) Error in library(alr3) : there is no package called ‘alr3’ any helps would be appreciated. with many thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Packages
here is the messages I got when I install the "car" package: > install.packages("car") Installing package into ‘C:/Users/aaboueissa/Documents/R/win-library/3.3’ (as ‘lib’ is unspecified) also installing the dependency ‘rio’ There are binary versions available but the source versions are later: binary source needs_compilation rio 0.5.10 0.5.16 FALSE car 3.0-0 3.0-2 FALSE installing the source packages ‘rio’, ‘car’ trying URL 'https://cran.case.edu/src/contrib/rio_0.5.16.tar.gz' Content type 'application/x-gzip' length 420489 bytes (410 KB) downloaded 410 KB trying URL 'https://cran.case.edu/src/contrib/car_3.0-2.tar.gz' Content type 'application/x-gzip' length 447952 bytes (437 KB) downloaded 437 KB * installing *source* package 'rio' ... ** package 'rio' successfully unpacked and MD5 sums checked ** R ** inst ** preparing package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called 'Rcpp' ERROR: lazy loading failed for package 'rio' * removing 'C:/Users/aaboueissa/Documents/R/win-library/3.3/rio' ERROR: dependency 'rio' is not available for package 'car' * removing 'C:/Users/aaboueissa/Documents/R/win-library/3.3/car' The downloaded source packages are in ‘C:\Users\aaboueissa\AppData\Local\Temp\RtmpK0MQ8V\downloaded_packages’ Warning messages: 1: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\aaboueissa\Documents\R\win-library\3.3" C:\Users\AABOUE~1\AppData\Local\Temp\RtmpK0MQ8V/downloaded_packages/rio_0.5.16.tar.gz' had status 1 2: In install.packages("car") : installation of package ‘rio’ had non-zero exit status 3: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\aaboueissa\Documents\R\win-library\3.3" C:\Users\AABOUE~1\AppData\Local\Temp\RtmpK0MQ8V/downloaded_packages/car_3.0-2.tar.gz' had status 1 4: In install.packages("car") : installation of package ‘car’ had non-zero exit status __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Wed, Jan 23, 2019 at 12:20 PM Duncan Murdoch wrote: > On 23/01/2019 12:13 p.m., AbouEl-Makarim Aboueissa wrote: > > Dear All: > > > > After installing the packages "car" and "alr3", I got the following error > > messages: > > > > > >> library(car) > > Error in library(car) : there is no package called ‘car’ > > > >> library(alr3) > > Error in library(alr3) : there is no package called ‘alr3’ > > > > any helps would be appreciated. > > > > You need to show us the messages you received when you installed them. > The usual cause of problems like this is that you don't have write > permission on the default location, and R has chosen an alternate; then > when you try to attach the packages, you haven't told R to look in the > alternate location. > > Duncan Murdoch > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Tukey Test
check this: https://www.r-graph-gallery.com/84-tukey-test/ abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Jan 24, 2019 at 10:51 PM wrote: > R-Help > > > > There is an R library that will perform a Tukey test which prints out the > Tukey groups (A, B, C, etc) and I don't recall the library. It was > agriculture or something like that. > > > > And is there a library that will product the Tukey, Bonferonni, Scheffe, > and > Dunnett comparison tables? > > > > Jeff Reichmqn > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Tukey Test
how about this one too? https://www.r-bloggers.com/anova-and-tukeys-test-on-r/ abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Jan 24, 2019 at 10:51 PM wrote: > R-Help > > > > There is an R library that will perform a Tukey test which prints out the > Tukey groups (A, B, C, etc) and I don't recall the library. It was > agriculture or something like that. > > > > And is there a library that will product the Tukey, Bonferonni, Scheffe, > and > Dunnett comparison tables? > > > > Jeff Reichmqn > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] How to rum Multiple ANOVA and Multiple T-test between the same groups?
Dear All: good morning *Re:* How to rum Multiple ANOVA and Multiple T-test between the same groups. Your help will be highly appreciated. *1.* is there a way to run multiple t-tests on different variables between the same two groups. *Data for t-tests:* The data frame “dataTtest” has 5 variables (x1,x2,x3,x4,x5) and one factor (factor1) with 2 levels (group1, group2). x1<-rnorm(20,1,1) x2<-rnorm(20,2,1) x3<-rnorm(20,3,1) x4<-rnorm(20,4,1) x5<-rnorm(20,5,1) factor1<-rep(c("group1", "group2"), each = 10) dataTtest<-data.frame(x1,x2,x3,x4,x5,factor1) dataTtest *2.* is there a way to run *multiple ANOVA* and multiple comparisons *Tukey tests* on different variables between the same groups. *Data for ANOVA tests:* The data frame “dataANOVA” has 6 variables (x1,x2,x3,x4,x5,x6) and one factor (factor2) with 5 levels (group1, group2, group3, group4, group5). x1<-rnorm(40,1,1) x2<-rnorm(40,2,1) x3<-rnorm(40,3,1) x4<-rnorm(40,4,1) x5<-rnorm(40,5,1) x6<-rnorm(40,6,1) factor2<-rep(c("group1", "group2", "group3", "group4", "group5"), each = 8) dataANOVA<-data.frame(x1,x2,x3,x4,x5,x6,factor2) dataANOVA with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] How to rum Multiple ANOVA and Multiple T-test between the same groups?
Dear Prof Kohl: I am trying to install the "genefilter" package, but I got the following error message(s). I am not sure which R version should be used for this package. *For R.3.5.2:* > install.packages("genefilter") Installing package into ‘C:/Users/aaboueissa/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) Warning message: package ‘genefilter’ is not available (for R version 3.5.2) *For R.3.3.2:* > install.packages("Bioconductor") Installing package into ‘C:/Users/aaboueissa/Documents/R/win-library/3.3’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- Warning message: package ‘Bioconductor’ is not available (for R version 3.3.2) with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sun, Feb 10, 2019 at 10:52 AM Prof. Dr. Matthias Kohl < matthias.k...@stamats.de> wrote: > Have a look at Bioconductor package genefilter, especially functions > colttests and colFtests. > Best Matthias > > Am 10.02.19 um 10:35 schrieb AbouEl-Makarim Aboueissa: > > Dear All: good morning > > > > > > > > > > > > *Re:* How to rum Multiple ANOVA and Multiple T-test between the same > groups. > > > > > > > > Your help will be highly appreciated. > > > > > > > > > > > > *1.* is there a way to run multiple t-tests on different variables > between > > the same two groups. > > > > > > > > > > > > *Data for t-tests:* > > > > > > > > The data frame “dataTtest” has 5 variables (x1,x2,x3,x4,x5) and one > factor > > (factor1) with 2 levels (group1, group2). > > > > > > > > > > > > x1<-rnorm(20,1,1) > > > > x2<-rnorm(20,2,1) > > > > x3<-rnorm(20,3,1) > > > > x4<-rnorm(20,4,1) > > > > x5<-rnorm(20,5,1) > > > > factor1<-rep(c("group1", "group2"), each = 10) > > > > dataTtest<-data.frame(x1,x2,x3,x4,x5,factor1) > > > > dataTtest > > > > > > > > > > > > > > > > > > > > *2.* is there a way to run *multiple ANOVA* and multiple comparisons > *Tukey > > tests* on different variables between the same groups. > > > > > > > > > > > > *Data for ANOVA tests:* > > > > > > > > The data frame “dataANOVA” has 6 variables (x1,x2,x3,x4,x5,x6) and one > > factor (factor2) with 5 levels (group1, group2, group3, group4, group5). > > > > > > > > > > > > > > > > x1<-rnorm(40,1,1) > > > > x2<-rnorm(40,2,1) > > > > x3<-rnorm(40,3,1) > > > > x4<-rnorm(40,4,1) > > > > x5<-rnorm(40,5,1) > > > > x6<-rnorm(40,6,1) > > > > factor2<-rep(c("group1", "group2", "group3", "group4", "group5"), each = > 8) > > > > dataANOVA<-data.frame(x1,x2,x3,x4,x5,x6,factor2) > > > > dataANOVA > > > > > > > > > > > > with many thanks > > > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Statistics and Data Science* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > > -- > Prof. Dr. Matthias Kohl > www.stamats.de > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Remove cases with -Inf from a data frame
Dear All: good morning I have a log-transformed data frame with some *-Inf* data values. *my question: *how to remove all rows with *-Inf* data value from that data frame? with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Remove cases with -Inf from a data frame
Dear Rui and All: thank you very much for your very helpful responses. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sat, Feb 16, 2019 at 11:36 AM Rui Barradas wrote: > Hello, > > An alternative, same dataset. > > df[apply(df, 1, function(x) all(is.finite(x))), ] > > > Hope this helps, > > Rui Barradas > > Às 16:14 de 16/02/2019, Martin Møller Skarbiniks Pedersen escreveu: > > On Sat, 16 Feb 2019 at 16:07, AbouEl-Makarim Aboueissa < > > abouelmakarim1...@gmail.com> wrote: > >> > >> I have a log-transformed data frame with some *-Inf* data values. > >> > >> *my question: *how to remove all rows with *-Inf* data value from that > > data > >> frame? > > > > > > Hi, > >Here is a solution which uses apply. > > > > First a data-frame as input: > > > > set.seed(1) > > df <- data.frame(w = sample(c(-Inf,1:20), 10), > > x = sample(c(-Inf,1:20), 10), > > y = sample(c(-Inf,1:20), 10), > > z = sample(c(-Inf,1:20), 10)) > > > > df <- df[-(unlist(apply(df, 2, function(x) which(x == -Inf,] > > > > Regards > > Martin > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] install the Bioconductor package “yeastExpData”
Dear All: I am trying to install the Bioconductor package “yeastExpData”. By the end I got an error message, please see below. I am not sure what is wrong. > source("http://bioconductor.org/biocLite.R";) Bioconductor version 3.0 (BiocInstaller 1.16.5), ?biocLite for help A new version of Bioconductor is available after installing the most recent version of R; see http://bioconductor.org/install > biocLite("yeastExpData") BioC_mirror: http://bioconductor.org Using Bioconductor version 3.0 (BiocInstaller 1.16.5), R version 3.1.2. Installing package(s) 'yeastExpData' also installing the dependency ‘graph’ trying URL ' http://bioconductor.org/packages/3.0/bioc/bin/windows/contrib/3.1/graph_1.44.1.zip ' Content type 'application/zip' length 2746668 bytes (2.6 Mb) opened URL downloaded 2.6 Mb trying URL ' http://bioconductor.org/packages/3.0/data/experiment/bin/windows/contrib/3.1/yeastExpData_0.11.1.zip ' Content type 'application/zip' length 1936545 bytes (1.8 Mb) opened URL downloaded 1.8 Mb package ‘graph’ successfully unpacked and MD5 sums checked package ‘yeastExpData’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\aaboueissa\AppData\Local\Temp\RtmpYNOhi3\downloaded_packages Old packages: 'boot', 'class', 'cluster', 'codetools', 'foreign', 'KernSmooth', 'lattice', 'MASS', 'Matrix', 'mgcv', 'nlme', 'nnet', 'rpart', 'spatial', 'survival' *Update all/some/none? [a/s/n]: a* *Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :* * 'lib = "C:/Program Files/R/R-3.1.2/library"' is not writable* *Error in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, : * * unable to install packages* > library("yeastExpData") Loading required package: graph > with thanks abou -- __ AbouEl-Makarim Aboueissa, PhD University of Southern Maine Department of Mathematics and Statistics [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Coefficient of Partial Determination
Dear All: Can the *Coefficient of Partial Determination* in multiple linear regression be computed in R? If so, could you please let me know how? fullmodel <- lm(Price ~ Size + Lotsize + Bedrooms + Bathrooms) *I found this in the internet, but I could find the package "rms"* *library(rms) # will also load Hmisc* *fit <- ols(y ~ x1 + x2, data=bf.dat) * *plt <- plot(anova(fit), what='partial R2')* *plt* Here is part of the data as an example: --- Taxes Bedrooms Bathrooms Price Size Lotsize 2963 3 795000 23715850 2424 3 399000 28184000 2424 3 545000 30323060 2224 4 909000 35406650 2223 1 109900 12496360 2223 3 324900 18004160 3114 2 192900 16033880 3113 2 215000 14504160 3114 3 999000 33604800 3113 2 319000 13235500 3113 2 35 17507200 3113 2 249000 14003000 3112 2 299000 12571700 3073 2 235900 14002880 3073 2 348000 16003600 3074 3 314000 17943185 3074 2 399000 18503300 3073 3 599000 29505200 3073 2 299000 17193450 3073 3 425000 14723986 3074 3 110 41684785 3073 3 150 38804510 3072 1 11 10004000 3073 2 20 11393934 3073 1 134900 10804960 3074 3 25 20003000 3073 4 95 19203800 3074 2 239950 13484960 3073 2 17 12803000 3073 2 285000 24004500 3073 3 279000 17003500 3073 2 219000 16003500 3073 2 155000 10504000 3073 2 389000 14154500 3073 1 34 11106360 2792 1 95000 7974500 2792 2 14 11004032 2793 3 110 26025170 2794 3 36 23515400 2523 3 415000 13503150 2524 2 25 12063745 2333 3 559000 26284520 2333 3 525000 23654640 2333 3 779000 29908580 2333 2 595000 17502000 2334 5 115 55002160 2333 2 55 18523040 2333 2 50 21003090 2334 3 279000 25804960 2334 2 375000 19633350 2433 3 33 19005300 2433 3 199000 14504100 2432 2 165000 10009166 2434 3 1399000 65004040 4693 2 255000 12183630 2262 2 325000 8933620 Thank you very much for your help and support abou ______ AbouEl-Makarim Aboueissa, PhD University of Southern Maine Department of Mathematics and Statistics [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Reverse the scoring of some Columns of a Data Set
Dear All: goods morning Is there is a way to reverse the scoring of the first three columns x1, x2, and x3 and keep the original scores for the fourth column x4. *Here is an example of the data set:* x1 x2 x3 x4 2 5 4 4 1 1 1 6 1 2 1 6 2 3 2 4 1 2 1 6 1 3 1 6 2 2 2 5 2 1 1 6 2 2 4 5 5 5 2 1 I am expecting the output to be: x1 x2 x3 x4 5 5 2 4 2 2 4 6 2 1 1 6 2 2 2 4 1 3 1 6 1 2 1 6 2 3 2 5 1 2 1 6 1 1 1 5 2 5 4 1 thank you very much for your help and support abou __ AbouEl-Makarim Aboueissa, PhD Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Canonical Discriminant Function Analysis
Dear R users: Could you please help me out how to use R to get and interpret Standardized discriminant functions and structure coefficients for sex, Degree_Program, and Enrol_USM Please find the data file at: http://www.usm.maine.edu/~aaboueissa/Rhelps/Rhelps.html data files are (xls file: dataforRxlsor txt file: dataforRtxt) Output looks like this table. Standardized discriminant functions and structure coefficients for sex - Variable (scale) Function 1 Function 2 -- Coef rs rs-square Coef rs rs-square FAC1_OneComp FAC2_OneComp FAC3_OneComp FAC4_OneComp FAC5_OneComp FAC6_OneComp -- With the interpretation of the numbers. Standardized discriminant functions and structure coefficients for men - Variable (scale) Function 1 Function 2 -- Coef rs rs-square Coef rs rs-square FAC1_OneComp FAC2_OneComp FAC3_OneComp FAC4_OneComp FAC5_OneComp FAC6_OneComp -- With the interpretation of the numbers. and Wilksâ lambda and canonical correlation for sex Function 1Wilksâ lambdachi-square df p RcRc square --- Statistical anxiety â¦.. â¦.. ⦠.. â¦. â¦â¦.. With the interpretation of the numbers. Statistical anxiety are: FAC1_OneComp, FAC2_OneComp, FAC3_OneComp, FAC4_OneComp, FAC5_OneComp, FAC6_OneComp. With many thanks Abou == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 USA Tel: (207) 228-8389 Fax: (207) 780-5607 Email: aabouei...@usm.maine.edu aboue...@yahoo.com Web address: http://www.usm.maine.edu/~aaboueissa/ Office: 301C Payson Smith [[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.
[R] List
Dear Admins: Could you please add me to the r-h...@stat.math.ethz.ch mailing list. I prefere to use my yahoo account: aboue...@yahoo.com Thank you so much for your attention to this matter, and I look forward to hearing from you soon. My other contact information is: == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 USA Tel: (207) 228-8389 Fax: (207) 780-5607 Email: aabouei...@usm.maine.edu aboue...@yahoo.com Web address: http://www.usm.maine.edu/~aaboueissa/ Office: 301C Payson Smith ==== AbouEl-Makarim Aboueissa 326 Auburn Street, #3 Portland, ME 04103 USA Tel: (207) 797-2724 Email: aboue...@yahoo.com http://www.usm.maine.edu/~aaboueissa/ [[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.
[R] Comparing Points on Two Regression Lines
Dear R users: Suppose I have two different response variables y1, y2 that I regress separately on the different explanatory variables, x1 and x2 respectively. I need to compare points on two regression lines. These are the x and y values for each lines. x1<-c(0.5,1.0,2.5,5.0,10.0) y1<-c(204,407,1195,27404313) x2<-c(2.5,5.0,10.0,25.0) y2<-c(440,713,1520,2634) Suppose we need to compare the two lines at the common value of x=13. Please see attached the method as described in section 18.3 in Jerrold H. Zar. With many thanks Abou ====== AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: aabouei...@usm.maine.edu aboue...@yahoo.com http://www.usm.maine.edu/~aaboueissa/ Office: 301C Payson Smith__ 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.
[R] Bootstrap P-Value
*Dear All:* *I am trying to compute the p-value of the bootstrap test; please see below.* *In example 1 the p-value agrees with the confidence interval.* *BUT, in example 2 the p-value DOES NOT agree with the confidence interval. In Example 2, the p-value should be zero or close to zero.* *I am not sure what went wrong, or not sure if I missed something.* *any help would be appreciated.* *with many thanks* *abou* # Two - Sample Bootstrap # Source: http://www.ievbras.ru/ecostat/Kiril/R/Biblio_N/R_Eng/Chernick2011.pdf # Example 1: # -- set.seed(1) n1 <- 29 n1 x1 <- rnorm(n1, 1.143, 0.164) #some random normal variates: mean1 = 1.143 x1 n2 <- 33 n2 x2 <- rnorm(n2, 1.175, 0.169) #2nd random sample: mean2 = 1.175 x2 obs.diff.theta <- mean(x1) - mean(x2) obs.diff.theta theta <- as.vector(NULL) vector to hold difference estimates iterations <- 1000 for (i in 1:1000) {#bootstrap resamples xx1 <- sample(x1, n1, replace = TRUE) xx2 <- sample(x2, n2, replace = TRUE) theta[i] <- mean(xx1) - mean(xx2) } # Confidence Interval: # quantile(theta, probs = c(.025,0.975)) #Efron percentile CI on difference in means # 2.5% 97.5% # - 0.1248539 0.0137601 # P-Value # --- p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) # p.value <- (sum (theta >= obs.diff.theta) + 1)/ (iterations+1) p.value R OUTPUT > quantile(theta, probs = c(.025,0.975)) 2.5% 97.5% -0.12647744 0.02099391 > p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) > p.value [1] 1 # Example 2: # -- set.seed(5) n1 <- 29 ### n1 x1 <- rnorm(n1, 10.5, 0.15) ## sample 1 with mean1 = 10.5 ### x1 n2 <- 33 ### n2 x2 <- rnorm(n2, 1.5, 0.155) # Sample 2 with mean2 = 1.5 ### x2 obs.diff.theta <- mean(x1) - mean(x2) obs.diff.theta theta <- as.vector(NULL) vector to hold difference estimates iterations <- 1000 # bootstrap resamples for (i in 1:1000) { xx1 <- sample(x1, n1, replace = TRUE) xx2 <- sample(x2, n2, replace = TRUE) theta[i] <- mean(xx1) - mean(xx2) } # Confidence Interval: # ## CI on difference in means quantile(theta, probs = c(.025,0.975)) # P-Value # --- p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) # p.value <- (sum (theta >= obs.diff.theta) + 1)/ (iterations+1) p.value # R OUTPUT > ## CI on difference in means > > quantile(theta, probs = c(.025,0.975)) 2.5%97.5% 8.908398 9.060601 > # P-Value > p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) > p.value [1] 0.4835165 __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bootstrap P-Value
Dear Greg: H0: Mean 1- Mean 2 = 0 Ha: Mean 1 - Mean 2 ! = 0 with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Fri, Nov 6, 2020 at 12:35 PM Greg Snow <538...@gmail.com> wrote: > A p-value is for testing a specific null hypothesis, but you do not > state your null hypothesis anywhere. > > It is the null value that needs to be subtracted from the bootstrap > differences, not the observed difference. By subtracting the observed > difference you are setting a situation where the p-value will always > be about 0.5 or about 1 (depending on 1 tailed or 2 tailed). If > instead you subtract a null value (such as 0), then the p-values will > be closer to what you are expecting. > > On Fri, Nov 6, 2020 at 9:44 AM AbouEl-Makarim Aboueissa > wrote: > > > > *Dear All:* > > > > *I am trying to compute the p-value of the bootstrap test; please see > > below.* > > > > *In example 1 the p-value agrees with the confidence interval.* > > *BUT, in example 2 the p-value DOES NOT agree with the confidence > > interval. In Example 2, the p-value should be zero or close to zero.* > > > > *I am not sure what went wrong, or not sure if I missed something.* > > > > *any help would be appreciated.* > > > > > > *with many thanks* > > *abou* > > > > > > > > # Two - Sample Bootstrap > > > > # Source: > > http://www.ievbras.ru/ecostat/Kiril/R/Biblio_N/R_Eng/Chernick2011.pdf > > > > # Example 1: > > # -- > > > > > > > > set.seed(1) > > > > n1 <- 29 > > n1 > > x1 <- rnorm(n1, 1.143, 0.164) #some random normal variates: mean1 = 1.143 > > x1 > > > > n2 <- 33 > > n2 > > x2 <- rnorm(n2, 1.175, 0.169) #2nd random sample: mean2 = 1.175 > > x2 > > > > obs.diff.theta <- mean(x1) - mean(x2) > > obs.diff.theta > > > > theta <- as.vector(NULL) vector to hold difference estimates > > > > iterations <- 1000 > > > > for (i in 1:1000) {#bootstrap resamples > > xx1 <- sample(x1, n1, replace = TRUE) > > xx2 <- sample(x2, n2, replace = TRUE) > > theta[i] <- mean(xx1) - mean(xx2) > > } > > > > > > > > # Confidence Interval: > > # > > > > > > quantile(theta, probs = c(.025,0.975)) #Efron percentile CI on difference > > in means > > > > # 2.5% 97.5% > > # - 0.1248539 0.0137601 > > > > > > # P-Value > > # --- > > > > p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) > > > > # p.value <- (sum (theta >= obs.diff.theta) + 1)/ (iterations+1) > > > > p.value > > > > > > > > R OUTPUT > > > > > quantile(theta, probs = c(.025,0.975)) > > 2.5% 97.5% > > -0.12647744 0.02099391 > > > > > p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ > (iterations+1) > > > p.value > > [1] 1 > > > > # Example 2: > > # -- > > > > > > set.seed(5) > > > > n1 <- 29 > > ### n1 > > x1 <- rnorm(n1, 10.5, 0.15) ## sample 1 with mean1 = 10.5 > > ### x1 > > > > n2 <- 33 > > ### n2 > > x2 <- rnorm(n2, 1.5, 0.155) # Sample 2 with mean2 = 1.5 > > ### x2 > > > > obs.diff.theta <- mean(x1) - mean(x2) > > obs.diff.theta > > > > theta <- as.vector(NULL) vector to hold difference estimates > > > > iterations <- 1000 > > > > # bootstrap resamples > > > > for (i in 1:1000) { > > xx1 <- sample(x1, n1, replace = TRUE) > > xx2 <- sample(x2, n2, replace = TRUE) > > theta[i] <- mean(xx1) - mean(xx2) > > } > > > > > > > > # Confidence Interval: > > # > > > > > > ## CI on difference in means > > > > quantile(theta, probs = c(.025,0.975)) > > > > > > > > # P-Value > > # --- > > > > p.value <- (sum (abs(theta) >= obs.diff.theta) + 1)/ (iterations+1) > > > > # p.value <- (sum (theta >= obs.diff.theta) + 1)/ (iterations+1) > > > > p.value > > > > # R OUTPUT > > > >
[R] Sample size Determination to Compare Three Independent Proportions
Dear All: good morning *Re:* Sample Size Determination to Compare Three Independent Proportions *Situation:* Three Binary variables (Yes, No) Three independent populations with fixed sizes (*say:* N1 = 1500, N2 = 900, N3 = 1350). Power = 0.80 How to choose the sample sizes to compare the three proportions of “Yes” among the three variables. If you know a reference to this topic, it will be very helpful too. with many thanks in advance abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Sample size Determination to Compare Three Independent Proportions
Hi Marc: First, thank you very much for your help in this matter. Will perform an initial omnibus test of all three groups (e.g. 3 x 2 chi-square), possibly followed by all possible 2 x 2 pairwise comparisons (e.g. 1 versus 2, 1 versus 3, 2 versus 3), We can assume *either* the desired sample size in each group is the same *or* proportional to the population size. We can set p=0.25 and set p1=p2=p3=p so that the H0 is true. We can assume that the expected proportion of "Yes" values in each group is 0.25 For the alternative hypotheses, for example, we can set p1 = .25, p2=.25, p3=.35 Again thank you very much in advance. abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Mon, Aug 9, 2021 at 10:53 AM Marc Schwartz wrote: > Hi, > > You are going to need to provide more information than what you have > below and I may be mis-interpreting what you have provided. > > Presuming you are designing a prospective, three-group, randomized > allocation study, there is typically an a priori specification of the > ratios of the sample sizes for each group such as 1:1:1, indicating that > the desired sample size in each group is the same. > > You would also need to specify the expected proportions of "Yes" values > in each group. > > Further, you need to specify how you are going to compare the > proportions in each group. Are you going to perform an initial omnibus > test of all three groups (e.g. 3 x 2 chi-square), possibly followed by > all possible 2 x 2 pairwise comparisons (e.g. 1 versus 2, 1 versus 3, 2 > versus 3), or are you just going to compare 2 versus 1, and 3 versus 1, > where 1 is a control group? > > Depending upon your testing plan, you may also need to account for p > value adjustments for multiple comparisons, in which case, you also need > to specify what adjustment method you plan to use, to know what the > target alpha level will be. > > On the other hand, if you already have the data collected, thus have > fixed sample sizes available per your wording below, simply go ahead and > perform your planned analyses, as the notion of "power" is largely an a > priori consideration, which reflects the probability of finding a > "statistically significant" result at a given alpha level, given that > your a priori assumptions are valid. > > Regards, > > Marc Schwartz > > > AbouEl-Makarim Aboueissa wrote on 8/9/21 9:41 AM: > > Dear All: good morning > > > > *Re:* Sample Size Determination to Compare Three Independent Proportions > > > > *Situation:* > > > > Three Binary variables (Yes, No) > > > > Three independent populations with fixed sizes (*say:* N1 = 1500, N2 = > 900, > > N3 = 1350). > > > > Power = 0.80 > > > > How to choose the sample sizes to compare the three proportions of “Yes” > > among the three variables. > > > > If you know a reference to this topic, it will be very helpful too. > > > > with many thanks in advance > > > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Statistics and Data Science* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Sample size Determination to Compare Three Independent Proportions
Hi Marc: Thank you for your help in this matter. With thanks Abou On Tue, Aug 10, 2021, 9:28 AM Marc Schwartz wrote: > Hi, > > A search would suggest that there may not be an R function/package that > provides power/sample size calculations for the specific scenarios that > you are describing. There may be something that I am missing, and there > is also other dedicated software such as PASS > (https://www.ncss.com/software/pass/) which is not free, but provides a > large library of possibly relevant functions and support. > > That being said, you can run Monte Carlo simulations in R to achieve the > results you want, while providing yourself with options relative to > study design, intended tests, and adjustments for multiple comparisons > as apropos. Many prefer this approach, since it gives you specific > control over this process. > > Taking the simple case, where you are going to run a 3 x 2 chi-square as > your primary endpoint, and want to power for that, here is a possible > function, with the same sample size in each group: > > ThreeGroups <- function(n, p1, p2, p3, R = 1, power = 0.8) { > >MCSim <- function(n, p1, p2, p3) { > ## Create a binary distribution for each group > G1 <- rbinom(n, 1, p1) > G2 <- rbinom(n, 1, p2) > G3 <- rbinom(n, 1, p3) > > ## Create a 3 x 2 matrix containing the 3 group counts > MAT <- cbind(table(G1), table(G2), table(G3)) > > ## Perform a chi-square and just return the p value > chisq.test(MAT)$p.value >} > >## Replicate the above R times, and get >## a distribution of p values >MC <- replicate(R, MCSim(n, p1, p2, p3)) > >## Get the p value at the desired "power" quantile >quantile(MC, power) > } > > Essentially, the above internal MCSim() function generates 3 random > samples of size 'n' from the binomial distribution, at the 3 proportions > desired. For each run, it will perform a chi-square test of the 3 x 2 > matrix of counts, returning the p value for each run. The main function > will then return the p value at the quantile (power) within the > generated distribution of p values. > > You can look at the help pages for the various functions that I use > above, to get a sense for how they work. > > You increase the sample size ('n') until you get a p value returned <= > 0.05, if that is your desired alpha level. > > You also want 'R', the number of replications within each run, to be > large enough so that the returned p value quantile is relatively stable. > Values for 'R', once you get "close to" the desired p value should be on > the order of 1,000,000 or higher. Stay with lower values for 'R' until > you get in the ballpark of your target, since larger values take much > longer to run. > > Thus, using your example proportions of 0.25, 0.25, and 0.35: > > ## 250 per group, 750 total - Not enough > > ThreeGroups(250, 0.25, 0.25, 0.35, R = 1) > 80% > 0.08884723 > > ## 350 per group, 1050 total - Too high > > ThreeGroups(350, 0.25, 0.25, 0.35, R = 1) >80% > 0.0270829 > > ## 300 per group, 900 total - Close! > > ThreeGroups(300, 0.25, 0.25, 0.35, R = 1) > 80% > 0.04818842 > > > So, keep tweaking the sample size until you get a returned p value at > your target alpha level, with a large enough 'R', so that you get > consistent sample sizes for multiple runs. > > If I run 300 per group again, with 10,000 replicates: > > > ThreeGroups(300, 0.25, 0.25, 0.35, R = 1) > 80% > 0.05033933 > > the returned p value is slightly higher. So, again, increase R to > improve the stability of the returned p value and run it multiple times > to be comfortable that the p value change is less than an acceptable > threshold. > > Now, the tricky part is to decide if the 3 x 2 is your primary endpoint, > and want to power only for that, or, if you also want to power for the > other two-group comparisons, possibly having to account for p value > adjustments for the multiple comparisons, resulting in the need to power > for a lower alpha level for those tests. In that scenario, you would end > up taking the largest sample size that you identify across the various > hypotheses, recognizing that while you are powering for one hypothesis, > you may be overpowering for others. > > That is something that you need to decide, and perhaps consider > consulting with other local statistical expertise, as may be apropos, in > the prospective study design, possibly influenced by other > relevant/similar research in your domain. > > Yo
[R] R codes/functions for test procedures
Dear All: I am wondering if someone have an R codes (R functions) to run the test procedures described in the paper titled “ESTIMATION AND COMPARISON OF LOGNORMAL PARAMETERS IN THE PRESENCE OF CENSORED DATA” by STAVROS POULOUKAS 2004, Journal of Statistical Computation & Simulation, Vol. 74, No. 3, March 2004, pp. 157–169. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Splitting a data column randomly into 3 groups
Dear All: How to split a column data *randomly* into three groups. Please see the attached data. I need to split column #2 titled "Data" with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* ID Data 1 366 2 394 3 222 4 396 5 399 6 158 7 361 8 426 9 255 10 32 11 31 12 53 13 377 14 405 15 448 16 362 17 260 18 90 19 95 20 8 21 385 22 306 23 154 24 345 25 136 26 39 27 472 28 19 29 404 30 463 31 134 32 72 33 477 34 22 35 240 36 389 37 482 38 287 39 180 40 140 41 456 42 403 43 81 44 425 45 57 46 251 47 421 48 343 49 310 50 62 51 412 52 93 53 111 54 148 55 311 56 430 57 12 58 100 59 437 60 363 61 126 62 367 63 165 64 272 65 171 66 167 67 234 68 113 69 315 70 175 71 484 72 379 73 474 74 216 75 250 76 177 77 293 78 133 79 203 80 408 81 150 82 155 83 223 84 381 85 336 86 368 87 290 88 359 89 333 90 219 91 455 92 427 93 444 94 178 95 302 96 221 97 248 98 160 99 304 100 56 101 25 102 400 103 485 104 89 105 254 106 186 107 283 108 431 109 188 110 354 111 119 112 67 113 415 114 346 115 319 116 344 117 121 118 34 119 288 120 416 121 308 122 340 123 166 124 443 125 388 126 286 127 245 128 406 129 253 130 395 131 274 132 428 133 329 134 410 135 127 136 420 137 187 138 244 139 125 140 137 141 206 142 205 143 327 144 211 145 7 146 192 147 317 148 60 149 54 150 4 151 434 152 233 153 47 154 280 155 76 156 398 157 320 158 347 159 453 160 465 161 382 162 476 163 213 164 418 165 409 166 230 167 3 168 229 169 436 170 262 171 77 172 207 173 118 174 99 175 243 176 27 177 479 178 438 179 152 180 109 181 330 182 17 183 179 184 323 185 124 186 296 187 435 188 225 189 128 190 84 191 316 192 195 193 74 194 138 195 149 196 63 197 249 198 104 199 35 200 228 201 44 202 275 203 259 204 356 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Splitting a data column randomly into 3 groups
Sorry, please forget about it. I believe that I am very serious when I posted my question. with thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Sep 2, 2021 at 9:42 PM Avi Gross via R-help wrote: > What is stopping you Abou? > > Some of us here start wondering if we have better things to do than > homework for others. Help is supposed to be after they try and encounter > issues that we may help with. > > So think about your problem. You supplied data in a file that is NOT in > CSV format but is in Tab separated format. > > You need to get it in to your program and store it in something. It looks > like you have 204 items so 1/3 of those would be exactly 68. > > So if your data is in an object like a vector or data.frame, you want to > choose random number between 1 and 204. How do you do that? You need 1/3 of > the length of the object items, in your case 68. > > Now extract the items with those indices into say A1. Extract all the > rest into a temporary item. > > Make another 68 random indices, with no overlap, and copy those items into > A2 and the ones that do not have those into A3 and you are sort of done, > other than some cleanup or whatever. > > There are many ways to do the above and I am sure packages too. > > But since you have made no visible effort, I personally am not going to > pick anything in particular. > > Had you shown some text and code along the lines of the above and just > wanted to know how to copy just the ones that were not selected, we could > easily ... > > > -Original Message- > From: R-help On Behalf Of AbouEl-Makarim > Aboueissa > Sent: Thursday, September 2, 2021 9:30 PM > To: R mailing list > Subject: [R] Splitting a data column randomly into 3 groups > > Dear All: > > How to split a column data *randomly* into three groups. Please see the > attached data. I need to split column #2 titled "Data" > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor, Statistics and Data Science* *Graduate Coordinator* > > *Department of Mathematics and Statistics* *University of Southern Maine* > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Splitting a data column randomly into 3 groups
Hi Avi: good morning Again, many thanks to all of you. I appreciate all what you are doing. You are good. I did it in Minitab. It cost me a little bit more time, but it is okay. It was a little bit confusing for me to do it in R. Because in *Step 1: *I have to select a random sample of size n=204 (say) out of N=700 (say). Then in Step 2: I have to allocate the 204 randomly selected obs. into three groups of equal sample sizes. Again, thank you very much, and sorry if I bothered you. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Sep 2, 2021 at 10:42 PM Avi Gross via R-help wrote: > Abou, > > > > I am not trying to be negative. Assuming you are a professor of > Statistics, your request seems odd as what you are asking about is very > routine in much of statistical work where you want to make a model or > something using just part of your data and need to reserve some to check if > you perhaps trained an algorithm too much for the original data used. > > > > A simple online search before asking questions here is appreciated. I did > a quick search for something like “R split data into three parts” and see > several applicable answers. > > > > There are people on this forum who actually get paid to do nontrivial > tasks and do not mind help in spots but feel sort of used if expected to > write a serious amount of code and perhaps then be asked to redo it with > more bells and whistles added. A recent badly phrased request comes to mind > where several of us provided and answer only to find out it was for a > different scenario, … > > > > So let me continue with a serious answer. May we assume you KNOW how to > read the data in to something like a data.frame? If so, and if you see no > need or value in doing this the hard way, then your question could have > been to ask if there is an R built-in function or perhaps a pacjkage > already set to solve it quickly. Again, a simple online search can do > wonders. Here, for example is a package called caret and this page > discusses spliutting data multiple ways: > > > > https://topepo.github.io/caret/data-splitting.html > > > > There are other such pages suggesting how to do it using base R. > > > > Here is one that gives an example on how to make three unequal partitions: > > > > inds <- partition(iris$Sepal.Length, p = c(train = 0.6, valid = 0.2, test > = 0.2)) > > > > > > There is more to do below but in the above, you would use whatever names > you want instead of train/valid/test and set all three to 0.33 and so on. > > > > I repeat, that what you want to do strikes some of us as a fairly routine > thing to do and lots of people have written how they have done it and you > can pick and choose, or redo it on your own. If what you have is a homework > assignment, the appropriate thing is to have you learn to use some > technique yourself and perhaps get minor help when it fails. But if you > will be doing this regularly, use of some packages is highly valuable. > > > > Good Luck. > > > > > > > > > > > > From: AbouEl-Makarim Aboueissa > Sent: Thursday, September 2, 2021 9:51 PM > To: Avi Gross > Cc: R mailing list > Subject: Re: [R] Splitting a data column randomly into 3 groups > > > > Sorry, please forget about it. I believe that I am very serious when I > posted my question. > > > > with thanks > > abou > > > __ > > AbouEl-Makarim Aboueissa, PhD > > > > Professor, Statistics and Data Science > > Graduate Coordinator > > Department of Mathematics and Statistics > > University of Southern Maine > > > > > > > > On Thu, Sep 2, 2021 at 9:42 PM Avi Gross via R-help <mailto:r-help@r-project.org> > wrote: > > What is stopping you Abou? > > Some of us here start wondering if we have better things to do than > homework for others. Help is supposed to be after they try and encounter > issues that we may help with. > > So think about your problem. You supplied data in a file that is NOT in > CSV format but is in Tab separated format. > > You need to get it in to your program and store it in something. It looks > like you have 204 items so 1/3 of those would be exactly 68. > > So if your data is in an object like a vector or data.frame, you want to > choose random number between 1 and 204. How do you do that? You need 1/3 of > the length of the object items, in your case 68. > > Now extract the items with those indices into say A1. Extract
Re: [R] Splitting a data column randomly into 3 groups
Hi Richard: Thank you very much for your help in this matter. with thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Fri, Sep 3, 2021 at 10:25 AM Richard O'Keefe wrote: > Your question is ambiguous. > One reading is > n <- length(table$Data) > m <- n %/% 3 > s <- sample(1:n, n) > X <- table$Data[s[1:m]] > Y <- table$Data[s[(m+1):(2*m)]] > Z <- table$Data[s[(m*2+1):(3*m)]] > > > > > On Fri, 3 Sept 2021 at 13:31, AbouEl-Makarim Aboueissa > wrote: > > > > Dear All: > > > > How to split a column data *randomly* into three groups. Please see the > > attached data. I need to split column #2 titled "Data" > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Statistics and Data Science* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Splitting a data column randomly into 3 groups
Dear Thomas: Thank you very much for your input in this matter. The core part of this R code(s) (please see below) was written by *Richard O'Keefe*. I had three examples with different sample sizes. *First sample of size n1 = 204* divided randomly into three groups of sizes 68. *No problems with this one*. *The second sample of size n2 = 112* divided randomly into three groups of sizes 37, 37, and 38. BUT this R code generated three groups of equal sizes (37, 37, and 37). *How to fix the code to make sure that the output will be three groups of sizes 37, 37, and 38*. *The third sample of size n3 = 284* divided randomly into three groups of sizes 94, 95, and 95. BUT this R code generated three groups of equal sizes (94, 94, and 94). *Again*, h*ow to fix the code to make sure that the output will be three groups of sizes 94, 95, and 95*. With many thanks abou ### # N1 <- 485 population1.IDs <- seq(1, N1, by = 1) population1.IDs n1<-204# in this case the size of each group of the three groups = 68 sample1.IDs <- sample(population1.IDs,n1) sample1.IDs n1 <- length(sample1.IDs) m1 <- n1 %/% 3 s1 <- sample(1:n1, n1) group1.IDs <- sample1.IDs[s1[1:m1]] group2.IDs <- sample1.IDs[s1[(m1+1):(2*m1)]] group3.IDs <- sample1.IDs[s1[(m1*2+1):(3*m1)]] groups.IDs <-cbind(group1.IDs,group2.IDs,group3.IDs) groups.IDs ### -- N2 <- 266 population2.IDs <- seq(1, N2, by = 1) population2.IDs n2<-112 # in this case the sizes of the three groups are(37, 37, and 38) # BUT this codes generate three groups of equal sizes (37, 37, and 37) sample2.IDs <- sample(population2.IDs,n2) sample2.IDs n2 <- length(sample2.IDs) m2 <- n2 %/% 3 s2 <- sample(1:n2, n2) group1.IDs <- sample2.IDs[s2[1:m2]] group2.IDs <- sample2.IDs[s2[(m2+1):(2*m2)]] group3.IDs <- sample2.IDs[s2[(m2*2+1):(3*m2)]] groups.IDs <-cbind(group1.IDs,group2.IDs,group3.IDs) groups.IDs ### -- N3 <- 674 population3.IDs <- seq(1, N3, by = 1) population3.IDs n3<-284 # in this case the sizes of the three groups are(94, 95, and 95) # BUT this codes generate three groups of equal sizes (94, 94, and 94) sample2.IDs <- sample(population2.IDs,n2) sample3.IDs <- sample(population3.IDs,n3) sample3.IDs n3 <- length(sample2.IDs) m3 <- n3 %/% 3 s3 <- sample(1:n3, n3) group1.IDs <- sample3.IDs[s3[1:m3]] group2.IDs <- sample3.IDs[s3[(m3+1):(2*m3)]] group3.IDs <- sample3.IDs[s3[(m3*2+1):(3*m3)]] groups.IDs <-cbind(group1.IDs,group2.IDs,group3.IDs) groups.IDs __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sat, Sep 4, 2021 at 11:54 AM Thomas Subia wrote: > Abou, > > > > I’ve been following your question on how to split a data column randomly > into 3 groups using R. > > > > My method may not be amenable for a large set of data but it surely worth > considering since it makes sense intuitively. > > > > mydata <- LETTERS[1:11] > > > mydata > > [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" > > > > # Let’s choose a random sample of size 4 from mydata > > > random_grp1 > > [1] "J" "H" "D" "A" > > > > Now my next random selection of data is defined by > > data_wo_random <- setdiff(mydata,random_grp1) > > # this makes sense because I need to choose random data from a set which > is defined by the difference of the sets mydata and random_grp1 > > > > > data_wo_random > > [1] "B" "C" "E" "F" "G" "I" "K" > > > > This is great! So now I can randomly select data of any size from this set. > > Repeating this process can easily generate subgroups of your original > dataset of any size you want. > > > > Surely this method could be improved so that this could be done > automatically. > > Nevertheless, this is an intuitive method which I believe is easier to > understand than some of the other methods posted. > > > > Hope this helps! > > > > Thomas Subia > > Statistician > > > > > > > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Splitting a data column randomly into 3 groups
Hi Bert and All: good morning I promise this would be the last time to write about this topic. I come up with this R function (please see below), for sure with your help. It works for all sample sizes. I also provided three different simple examples. with many thanks abou ##Here it is### Random.Sample.IDs <- function (N,n, ngroups){ N = population size, and n = sample size, ngroups = number of groups population.IDs <- seq(1, N, by = 1) sample.IDs <- sample(population.IDs,n) # to print sample.IDs in a column format # -- sample.IDs.in.column<-data.frame(sample.IDs) print(sample.IDs.in.column) reminder.n<-n%%ngroups reminder.n n.final<-n-reminder.n n.final m <- n %/% 3 m s <- sample(1:n, n) if (reminder.n == 0) { group1.IDs <- sample.IDs[s[1:m]] group2.IDs <- sample.IDs[s[(m+1):(2*m)]] group3.IDs <- sample.IDs[s[(m*2+1):(3*m)]] } else if(reminder.n == 1){ group1.IDs <- sample.IDs[s[1:(m+1)]] group2.IDs <- sample.IDs[s[(m+2):(2*m+1)]] group3.IDs <- sample.IDs[s[(m*2+2):(3*m+1)]] } else if(reminder.n == 2){ group1.IDs <- sample.IDs[s[1:(m+1)]] group2.IDs <- sample.IDs[s[(m+2):(2*m+2)]] group3.IDs <- sample.IDs[s[(m*2+3):(3*m+2)]] } nn<-max(length(group1.IDs),length(group2.IDs),length(group3.IDs)) nn length(group1.IDs) <- nn length(group2.IDs) <- nn length(group3.IDs) <- nn groups.IDs <-cbind(group1.IDs,group2.IDs,group3.IDs) groups.IDs } # Examples # Random.Sample.IDs (100,12,3) group sizes are equal (n1=n2=n3=4) Random.Sample.IDs (100,13,3) group sizes are NOT equal (n1=5, n2=4, n3=4) Random.Sample.IDs (100,17,3) group sizes are NOT equal (n1=6, n2=6, n3=5) __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sun, Sep 5, 2021 at 6:50 PM Bert Gunter wrote: > In case anyone is still interested in my query, note that if there are > n total items to be split into g groups as evenly as possible, if we > define this as at most two different size groups whose size differs by > 1, then: > > if n = k*g + r, where 0 <= r < g, > then n = k*(g - r) + (k + 1)*r . > i.e. g-r groups of size k and r groups of size k+1 > > So using R's modular arithmetic operators, which are handy to know > about, we have: > > r = n %% g and k = n %/% g . > > (and note that you should disregard my previous stupid remark about > numerical analysis). > > Cheers, > Bert > > > On Sat, Sep 4, 2021 at 3:34 PM Bert Gunter wrote: > > > > I have a more general problem for you. > > > > Given n items and 2 <=g < > groups that are as "equal as possible." > > > > First, operationally define "as equal as possible." > > Second, define the algorithm to carry out the definition. Hint: Note > > that sum{m[i]} for i <=g must sum to n, where m[i] is the number of > > items in the ith group. > > Third, write R code for the algorithm. Exercise for the reader. > > > > I may be wrong, but I think numerical analysts might also have a > > little fun here. > > > > Randomization, of course, is trivial. > > > > Cheers, > > Bert > > > > > > Bert Gunter > > > > "The trouble with having an open mind is that people keep coming along > > and sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > On Sat, Sep 4, 2021 at 2:13 PM AbouEl-Makarim Aboueissa > > wrote: > > > > > > Dear Thomas: > > > > > > > > > Thank you very much for your input in this matter. > > > > > > > > > The core part of this R code(s) (please see below) was written by > *Richard > > > O'Keefe*. I had three examples with different sample sizes. > > > > > > > > > > > > *First sample of size n1 = 204* divided randomly into three groups of > sizes > > > 68. *No problems with this one*. > > > > > > > > > > > > *The second sample of size n2 = 112* divided randomly into three > groups of > > > sizes 37, 37, and 38. BUT this R code generated three groups of equal > sizes > > > (37, 37, and 37). *How to fix the code to make sure that the output > will be > > > three groups of sizes 37, 37, and 38*. > > > > > > > > > > > > *The third sample of size n3 = 284* divided randomly into three groups > of > > &g
[R] Confidence Interval for p1-p2 and plot the CI with bar chart
Dear All: I do have a binary data set with multiple variables, event = 1 in all variables. As an example, I attached a data set with 6 variables. The first column is the grouping variable. Then the next 5 columns are the binary data for 5 variables. - Can we compute the confidence interval for the difference between the two proportions of the event = 1 in both groups (say: G1 – G2) for the 5 variables in one shut. - I also need to create the Bar plot of individual proportions (both groups side-by-side) and add the confidence intervals bar for the 5 variables in one graph. Example.Data <- read.table(file="F/Example_Data_for_R.csv", header=T, sep=",") Example.Data attach(Example.Data) For example, this is how I use the prop.test() function to get the CI for p1-p2 x12 <- c(x1, x2) n12 <- c(n1, n2) prop.test(x12, n12, conf.level = 0.95)$conf.int But, I am not sure how to use it for raw data, and for multiple pairs of data in one shut if possible. With many thanks in advance Abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Confidence Interval for p1-p2 and plot the CI with bar chart
Hi Jim: Thank you very much for your help in this topic. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sat, Nov 13, 2021 at 8:47 PM Jim Lemon wrote: > Hi Abou, > Perhaps this will be helpful. Be aware that you will cop some flak for > putting error bars on a bar plot. > > aadat<-data.frame(group=c(rep("Exp",50),rep("Con",50)), > v1=sample(0:1,100,TRUE), > v2=sample(0:1,100,TRUE), > v3=sample(0:1,100,TRUE), > v4=sample(0:1,100,TRUE), > v5=sample(0:1,100,TRUE)) > ggps<-function(x,group) { > gns<-as.vector(table(group)) > return(by(x,group,sum)/gns) > } > testggps<-data.frame( > group=c("A","A","A","B","B","B","B","C","C","C","C","C"), > x=c(1,0,1,1,0,1,0,1,1,0,0,0)) > aaprop<-sapply(aadat[,2:6],ggps,aadat[,1]) > library(plotrix) > barpos<-barp(aaprop,ylim=c(0,0.65),col=c(2,3),names.arg=colnames(aaprop)) > legend(2.5,0.65,c("Con","Exp"),fill=c(2,3)) > dispersion(barpos$x,barpos$y,ulim=aaprop/10) > > Jim > > On Sun, Nov 14, 2021 at 11:01 AM AbouEl-Makarim Aboueissa > wrote: > > > > Dear All: > > > > > > > > I do have a binary data set with multiple variables, event = 1 in all > > variables. As an example, I attached a data set with 6 variables. The > first > > column is the grouping variable. Then the next 5 columns are the binary > > data for 5 variables. > > > > > > > > - Can we compute the confidence interval for the difference between the > two > > proportions of the event = 1 in both groups (say: G1 – G2) for the 5 > > variables in one shut. > > > > > > > > - I also need to create the Bar plot of individual proportions (both > groups > > side-by-side) and add the confidence intervals bar for the 5 variables in > > one graph. > > > > > > > > > > > > Example.Data <- read.table(file="F/Example_Data_for_R.csv", header=T, > > sep=",") > > > > Example.Data > > > > attach(Example.Data) > > > > > > > > > > > > > > > > For example, this is how I use the prop.test() function to get the > CI > > for p1-p2 > > > > > > > > x12 <- c(x1, x2) > > > > n12 <- c(n1, n2) > > > > prop.test(x12, n12, conf.level = 0.95)$conf.int > > > > > > > > But, I am not sure how to use it for raw data, and for multiple pairs of > > data in one shut if possible. > > > > > > > > With many thanks in advance > > > > Abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Statistics and Data Science* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Confirmatory Factor Analysis
Dear All: I am conducting a Confirmatory Factor Analysis (CFA) for the attached data. Here is what I did. please see below I do need your help with the structure of the model. I believe that what I used is the correlated CFA model. If I am wrong, please fix me. I need your help with the structure of the CFA uncorrelated model. Thank you very much for your help in advance Abou datacfa<-read.table("G:/data_for_R.txt", header=TRUE) head(datacfa) install.packages("lavaan") library(lavaan) install.packages("semPlot") library(semPlot) install.packages("parameters") library(parameters) model structure CAF.Factors <- 'Factor1 =~ X11 + X13 + X14 + X15 + X17 Factor2 =~ X6 + X7 + X12 + X16 + X19 Factor3 =~ X9 + X18 + X21 Factor4 =~ X19 + X20 + X22' fourfactors.model.a <- cfa(CAF.Factors, data=datacfa,std.lv=TRUE) summary(fourfactors.model.a, fit.measures=TRUE,standardized=TRUE) semPaths(fourfactors.model.a, ncharNodes = 0, style = "lisrel", rotation = 2) # model_parameters(fourfactors.model.a) model_parameters(fourfactors.model.a, standardize = TRUE) __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 5 NA 2 1 4 4 5 5 5 5 5 5 2 5 5 1 4 4 NA 3 2 4 5 5 NA 5 4 5 4 2 5 5 1 4 5 5 5 1 5 3 5 3 4 4 5 4 1 5 5 2 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 4 2 4 3 3 4 4 4 4 4 1 4 4 2 2 3 4 5 2 2 4 3 4 4 4 4 5 2 3 4 2 3 4 NA 5 2 3 5 5 3 4 3 5 3 2 5 4 3 5 4 NA 3 1 2 4 5 4 4 3 5 5 2 5 4 3 4 5 NA 5 1 1 5 5 5 5 5 5 3 3 5 3 3 5 3 NA 4 2 4 4 4 3 4 4 4 4 4 4 2 2 2 3 NA 4 2 2 4 4 2 5 2 4 4 2 4 4 3 4 3 4 4 3 3 3 3 3 3 3 4 4 NA 3 3 3 3 4 5 5 1 3 4 5 4 5 4 4 4 2 4 4 3 4 5 5 5 2 3 5 5 3 4 5 5 2 1 5 5 1 4 4 4 4 2 2 4 4 3 4 4 4 4 2 5 4 2 5 NA 5 4 1 1 3 4 3 5 NA 3 4 2 4 4 NA 4 5 4 3 1 2 3 4 4 4 3 4 3 2 4 4 2 4 4 4 4 2 1 4 4 4 4 4 4 3 1 5 4 1 5 5 5 3 1 3 5 5 3 5 4 4 4 1 5 5 1 5 4 5 5 2 3 4 5 5 5 5 5 5 1 5 5 3 5 4 5 4 2 NA 5 5 5 5 5 5 5 1 5 5 NA 5 5 5 4 1 3 4 5 5 5 5 5 5 1 5 5 1 4 5 5 4 2 4 5 5 5 5 4 5 5 1 5 5 2 5 5 5 5 1 NA 4 5 5 5 NA 5 5 1 5 5 1 5 4 4 3 2 4 4 4 4 4 3 4 4 2 4
[R] Post-hoc pairwise Fisher’s exact tests
Dear All: Re: Post-hoc pairwise Fisher’s exact tests with confidence Intervals I am trying to conduct a Post-hoc pairwise comparison for comparing the proportions of the ones in the 7 groups using the fisher exact test. I have a data with 7 variables, data = (0,1). Event = 1. *Q1.* Is there a way to have the confidence intervals of Pi-Pj in the R output of the R function “*pairwise_fisher_test()*”. Also, R yields only the p values of the first 10 pairs (Pi,Pj). *Q2.* I used the summary of the raw data, please see below. Is there a way to use the raw data instead, please see the attached file? *Q3.* I got an error message when I tried to use the R function “ *fisher_test()*” R codes Data1 <- as.table(rbind( c(24,9,28,37,18,10,28), # number of ones c(65,80,61,52,71,79,61) # number of zeros )) dimnames(Data1) <- list( cases = c("yes", "no"), vars = c("x1", "x2", "x3", "x4", "x5", "x6", "x7") ) Data1 install.packages("rstatix") library(rstatix) fisher_test(Data1, detailed = TRUE) # pairwise fisher test: Compare the proportion of ones between groups pairwise_fisher_test(Data1) With many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* X1 X2 X3 X4 X5 X6 X7 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0
Re: [R] R for Linear Algebra
Dear Avi: Thank you very much, it is very helpful. with thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Jun 23, 2022 at 10:31 PM Avi Gross wrote: > R is a language specially made to do many things with vectors and matrices > and arrays with any reasonable > number of dimensions and also has a host of functions that do things like > make diagonal matrices, calculate > determinants and multiply them in several ways, invert them, get > eigenvalues and much more if you look for > packages. > > So the question becomes, what else do you feel you need for a Linear > Algebra course that a simple web > search would not have found like this: > > https://towardsdatascience.com/intro-to-r-linear-algebra-2a4de2506c93 > > > https://towardsdatascience.com/intro-to-r-linear-algebra-2a4de2506c93#:~:text=R%20is%20especially%20handy%20with,solvers%20and%20dynamic%20indexing%20capabilities > . > > Unless I missed something, yes, R is more easily able to be used to do > such things than many other languages albeit > just about any language tends to have access to a variety of functions > that may do these things but are not > built in. > > > > -Original Message- > From: AbouEl-Makarim Aboueissa > To: R mailing list > Sent: Thu, Jun 23, 2022 10:39 am > Subject: [R] R for Linear Algebra > > Re: R for Linear Algebra > > > > Dear All: > > > > > > In my STA 591 topics in Biostatistics Fall 2022, I am planning to spend > about 5 weeks on Linear Algebra. > > > > I am wondering if someone has or knows the source for some R > functions/programs written for linear algebra calculations. > > > > Also if you know a book in Linear Algebra with R, will be a good help too. > > > Any help in this matter is highly appreciated in advance. > > > > > > With many thanks > > Abou > > > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor, Statistics and Data Science* > *Graduate Coordinator* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] detect and replace outliers by the average
Dear All: *Re:* detect and replace outliers by the average The dataset, please see attached, contains a group factoring column “ *factor*” and two columns of data “x1” and “x2” with some NA values. I need some help to detect the outliers and replace it and the NAs with the average within each level (0,1,2) for each variable “x1” and “x2”. I tried the below code, but it did not accomplish what I want to do. data<-read.csv("G:/20-Spring_2023/Outliers/data.csv", header=TRUE) data replace_outlier_with_mean <- function(x) { replace(x, x %in% boxplot.stats(x)$out, mean(x, na.rm=TRUE)) , na.rm=TRUE NOT working } data[] <- lapply(data, replace_outlier_with_mean) Thank you all very much for your help in advance. with many thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] detect and replace outliers by the average
Dear All: *please discard my previous email* *Re:* detect and replace outliers by the average The dataset, please see attached, contains a group factoring column “ *factor*” and two columns of data “x1” and “x2” with some NA values. I need some help to detect the outliers and replace it and the NAs with the average within each level (0,1,2) for each variable “x1” and “x2”. I tried the below code, but it did not accomplish what I want to do. data<-read.csv("G:/20-Spring_2023/Outliers/data.csv", header=TRUE) data replace_outlier_with_mean <- function(x) { replace(x, x %in% boxplot.stats(x)$out, mean(x, na.rm=TRUE)) , na.rm=TRUE NOT working } data[] <- lapply(data, replace_outlier_with_mean) Thank you all very much for your help in advance. with many thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] detect and replace outliers by the average
Hi Rui: here is the dataset factor x1 x2 0 700 700 0 700 500 0 470 470 0 710 560 0 520 0 610 720 0 710 670 0 610 1 690 620 1 580 540 1 690 690 1 NA 401 1 450 580 1 700 700 1 400 1 600 1 500 400 1 680 650 2 117 63 2 120 68 2 130 73 2 120 69 2 125 54 2 999 70 2 165 62 2 130 987 2 123 70 2 78 2 98 2 5 2 321 NA with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Thu, Apr 20, 2023 at 2:44 PM Rui Barradas wrote: > Às 19:36 de 20/04/2023, AbouEl-Makarim Aboueissa escreveu: > > Dear All: > > > > > > > > *Re:* detect and replace outliers by the average > > > > > > > > The dataset, please see attached, contains a group factoring column “ > > *factor*” and two columns of data “x1” and “x2” with some NA values. I > need > > some help to detect the outliers and replace it and the NAs with the > > average within each level (0,1,2) for each variable “x1” and “x2”. > > > > > > > > I tried the below code, but it did not accomplish what I want to do. > > > > > > > > > > > > data<-read.csv("G:/20-Spring_2023/Outliers/data.csv", header=TRUE) > > > > data > > > > replace_outlier_with_mean <- function(x) { > > > >replace(x, x %in% boxplot.stats(x)$out, mean(x, na.rm=TRUE)) , > > na.rm=TRUE NOT working > > > > } > > > > data[] <- lapply(data, replace_outlier_with_mean) > > > > > > > > > > > > Thank you all very much for your help in advance. > > > > > > > > > > > > with many thanks > > > > abou > > > > > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Mathematics and Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > Hello, > > There is no data set attached, see the posting guide on what file > extensions are allowed as attachments. > > As for the question, try to compute mean(x, na.rm = TRUE) first, then > use this value in the replace instruction. Without data I'm just guessing. > > Hope this helps, > > Rui Barradas > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] detect and replace outliers by the average
Dear All: the attached file in the .txt format *Re:* detect and replace outliers by the average The dataset, please see attached, contains a group factoring column “ *factor*” and two columns of data “x1” and “x2” with some NA values. I need some help to detect the outliers and replace it and the NAs with the average within each level (0,1,2) for each variable “x1” and “x2”. I tried the below code, but it did not accomplish what I want to do. The average within each level should be computed after discard the outliers. data<-read.csv("G:/20-Spring_2023/Outliers/data.csv", header=TRUE) data replace_outlier_with_mean <- function(x) { replace(x, x %in% boxplot.stats(x)$out, mean(x, na.rm=TRUE)) , na.rm=TRUE NOT working } data[] <- lapply(data, replace_outlier_with_mean) Thank you all very much for your help in advance. with many thanks abou __________ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* factor x1 x2 0 700 700 0 700 500 0 470 470 0 710 560 0 520 0 610 720 0 710 670 0 610 1 690 620 1 580 540 1 690 690 1 NA 401 1 450 580 1 700 700 1 400 1 600 1 500 400 1 680 650 2 117 63 2 120 68 2 130 73 2 120 69 2 125 54 2 999 70 2 165 62 2 130 987 2 123 70 2 78 2 98 2 5 2 321 NA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] grubbs test to detect all outliers
*R: *Grubbs Test to detect all outliers Per group for all columns in a data frame Dear All: good morning I have a dataset (as an example) with two column factors (factor1 and factor2) and 5 numerical columns (X,Y,Z,U,V). The X and Y columns have same length as factor1; and Z, U, and V have same length as factor2. Please see dataset is copied below. Please note that all dataset columns have NAs values. *Need help on this:* Can we use the grubbs.test() function to detect all outliers and replace it by NA in X and Y datasets per group in factor1; and in Z, U, and V datasets per group in factor2. Columns in the dataframe have different lengths, but when I read the .csv file, R added NA values for the shorter columns. If you need the .csv data file, please let me know. Thank you very much for your help in advance. install.packages("outliers") library(outliers) datafortest<-read.csv("G:/data_for_test.csv", header=TRUE) datafortest datafortest<-data.frame(datafortest) datafortest$factor1<-as.factor(datafortest$factor1) datafortest$factor2<-as.factor(datafortest$factor2) str(datafortest) # tried to use grubbs.test() on a single column of the dataframe, but still not working tests.for.outliers.X<- grubbs.test(datafortest$X, na.rm = TRUE, type=11) *grubbs.test() on a single dataset: but this can only detect if the min and the max are outliers.* xx999<-c(0.088,1,2,3,4,5,6,7,8,9,88,98,99) grubbs.test(xx999, type=11) With many thanks Abou factor1 XY factor2 Z U V 1 4455.077 888 1 999 NA 999 1 4348.031 333 1 475NA 240 1.789 618 1 507 252 394 13813.139 417 1 603 332 265 1 7512.65 344 1 442 216 NA 1 5642.667NA 1 486 217 275 1 6684.386 341 1 927 698 479 2 5165.731 999 1 971 311 562 2 NA 265 1 388 999 512 2 3259.241 557 2 888 444 777 2 3288.383 234 2 514NA 322 2 1997.878 383 2 409 311 NA 2 0.61 NA 2 546 327 728 2 2655.977 NA 2 523 228 653 3 3189.49 2 313 456 450 3 1826.851 287 2 296 412 576 3 4386.002 352 2 320 251 NA 3 3295.091 308 2 388 888 396.5 3 2120.902 526 3 398 888 3 NA 489 3 677 438 307 3 2056.123 291 3 555 428 219 3 1995.088 444 3 NA 319 NA 3 NA 349 3 479 NA 321 3 2539.873 333 3 257 406 417 3 313 334 409 3 296 465 546 3 320 180 523 3 388 999 313 ______ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] grubbs test to detect all outliers
Hi Rui: good morning I forgot to cc my previous email to the R mailing list. Please find below the the output of *dput(datafortest)*. Also, please see below the printed dataset. Thank you very much for your help abou > dput(datafortest) structure(list(factor1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, NA, NA, NA, NA), levels = c("1", "2", "3"), class = "factor"), X = c(4455.077, 4348.031, .789, 3813.139, 7512.65, 5642.667, 6684.386, 5165.731, NA, 3259.241, 3288.383, 1997.878, 0.608, 2655.977, 3189.49, 1826.851, 4386.002, 3295.091, 2120.902, NA, 2056.123, 1995.088, NA, 2539.873, NA, NA, NA, NA), Y = c(888L, 333L, 618L, 417L, 344L, NA, 341L, 999L, 265L, 557L, 234L, 383L, NA, NA, L, 287L, 352L, 308L, 526L, 489L, 291L, 444L, 349L, 333L, NA, NA, NA, NA), factor2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c("1", "2", "3"), class = "factor"), Z = c(999L, 475L, 507L, 603L, 442L, 486L, 927L, 971L, 388L, 888L, 514L, 409L, 546L, 523L, 313L, 296L, 320L, 388L, L, 677L, 555L, NA, 479L, 257L, 313L, 296L, 320L, 388L), U = c(NA, NA, 252L, 332L, 216L, 217L, 698L, 311L, 999L, 444L, NA, 311L, 327L, 228L, 456L, 412L, 251L, 888L, 398L, 438L, 428L, 319L, NA, 406L, 334L, 465L, 180L, 999L), V = c(999, 240, 394, 265, NA, 275, 479, 562, 512, 777, 322, NA, 728, 653, 450, 576, NA, 396.5, 888, 307, 219, NA, 321, 417, 409, 546, 523, 313)), row.names = c(NA, -28L), class = "data.frame") > > datafortest<-read.csv("G:/data_for_test.csv", header=TRUE) > datafortest factor1 XY factor2Z U V 11 4455.077 888 1 999 NA 999.0 21 4348.031 333 1 475 NA 240.0 31 .789 618 1 507 252 394.0 41 3813.139 417 1 603 332 265.0 51 7512.650 344 1 442 216NA 61 5642.667 NA 1 486 217 275.0 71 6684.386 341 1 927 698 479.0 82 5165.731 999 1 971 311 562.0 92NA 265 1 388 999 512.0 10 2 3259.241 557 2 888 444 777.0 11 2 3288.383 234 2 514 NA 322.0 12 2 1997.878 383 2 409 311NA 13 2 0.608 NA 2 546 327 728.0 14 2 2655.977 NA 2 523 228 653.0 15 3 3189.490 2 313 456 450.0 16 3 1826.851 287 2 296 412 576.0 17 3 4386.002 352 2 320 251NA 18 3 3295.091 308 2 388 888 396.5 19 3 2120.902 526 3 398 888.0 20 3NA 489 3 677 438 307.0 21 3 2056.123 291 3 555 428 219.0 22 3 1995.088 444 3 NA 319NA 23 3NA 349 3 479 NA 321.0 24 3 2539.873 333 3 257 406 417.0 25 NANA NA 3 313 334 409.0 26 NANA NA 3 296 465 546.0 27 NA NA NA 3 320 180 523.0 28 NANA NA 3 388 999 313.0 > __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Fri, Apr 28, 2023 at 11:35 AM Rui Barradas wrote: > Às 14:09 de 28/04/2023, AbouEl-Makarim Aboueissa escreveu: > > *R: *Grubbs Test to detect all outliers Per group for all columns in a > data > > frame > > > > > > > > Dear All: good morning > > > > I have a dataset (as an example) with two column factors (factor1 and > > factor2) and 5 numerical columns (X,Y,Z,U,V). The X and Y columns have > same > > length as factor1; and Z, U, and V have same length as factor2. Please > see > > dataset is copied below. Please note that all dataset columns have NAs > > values. > > > > *Need help on this:* > > > > > > Can we use the grubbs.test() function to detect all outliers and replace > it > > by NA in X and Y datasets per group in factor1; and in Z, U, and V > datasets > > per group in factor2. Columns in the dataframe have different lengths, > but > > when I read the .csv file, R added NA values for the shorter columns. > > > > If you need the .csv data file, please let me know. > > > > > > Thank you very much for your help in advance. > > > > > > > > > > install.packages("outliers") > > library(outliers) > > > > datafortest<-read.csv("G:/data_for_test.csv", header=TRUE) > > datafortest > > > > datafortest<-data.frame(datafortest) > > > > datafortest$
Re: [R] grubbs test to detect all outliers
Hi Rui: How about this dataset, please see below. I included a few outliers in each column, as you can see in the printed dataset; please see below. Once again, thank you very much, and sorry if I bothered you all. abou > dput(datafortest) structure(list(factor1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, NA, NA, NA, NA), levels = c("1", "2", "3"), class = "factor"), X = c(994455.077, 4348.031, .789, 3813.139, 12.65, 5642.667, 876684.386, 5165.731, NA, 3259.241, 8.383, 1997.878, 0.608, 2655.977, 9.49, 1826.851, 4386.002, 883295.091, 2120.902, NA, 2056.123, 5.088, NA, 92539.873, NA, NA, NA, NA), Y = c(76888L, 333L, 618L, 10L, 344L, NA, 3L, 86999L, 265L, 557L, 7L, 383L, NA, NA, 8L, 287L, 352L, 308L, 999526L, 489L, 2L, 444L, 9L, 333L, NA, NA, NA, NA), factor2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), levels = c("1", "2", "3"), class = "factor"), Z = c(54999L, 475L, 15L, 603L, 442L, 79486L, 927L, 971L, 388L, 888L, 514L, 409L, 546L, 523L, 313L, 296L, 320L, 388L, 7L, 677L, 555L, NA, 479L, 257L, 313L, 21L, 320L, 4L), U = c(NA, NA, 1.5, 332, 216, 217, 1000, 10, , 444, NA, 5, 327, 5, 456, 412, 251, 6, 398, 438, 428, 15, NA, 406, 334, 465, 180, 88999), V = c(12, 240, 9000, 265, NA, 9, 1, 562, 13, 777, 322, NA, 99988, 653, 450, 576, NA, 396.5, 91888, 5, 219, NA, 321, 417, 409, 99, 523, 10)), row.names = c(NA, -28L), class = "data.frame") > > datafortest factor1 X Y factor2 Z UV 11 994455.077 76888 1 54999 NA 12.0 21 4348.031333 1 475 NA240.0 31 .789618 115 1.5 9000.0 41 3813.139 10 1 603 332.0265.0 51 12.650344 1 442 216.0 NA 61 5642.667 NA 1 79486 217.0 9.0 71 876684.386 3 1 927 1000.0 1.0 82 5165.731 86999 1 97110.0562.0 92 NA265 1 388 .0 13.0 10 2 3259.241557 2 888 444.0777.0 11 2 8.383 7 2 514 NA322.0 12 2 1997.878383 2 409 5.0 NA 13 2 0.608 NA 2 546 327.0 99988.0 14 2 2655.977 NA 2 523 5.0653.0 15 3 9.490 8 2 313 456.0450.0 16 3 1826.851287 2 296 412.0576.0 17 3 4386.002352 2 320 251.0 NA 18 3 883295.091308 2 388 6.0396.5 19 3 2120.902 999526 3 7 398.0 91888.0 20 3 NA489 3 677 438.0 5.0 21 3 2056.123 2 3 555 428.0219.0 22 3 5.088444 3NA15.0 NA 23 3 NA 9 3 479 NA321.0 24 3 92539.873333 3 257 406.0417.0 25 NA NA 3 313 334.0409.0 26 NA NA 321 465.0 99.0 27 NA NA 3 320 180.0523.0 28 NA NA 3 4 88999.0 10.0 > with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sat, Apr 29, 2023 at 8:05 AM Rui Barradas wrote: > Às 14:09 de 28/04/2023, AbouEl-Makarim Aboueissa escreveu: > > *R: *Grubbs Test to detect all outliers Per group for all columns in a > data > > frame > > > > > > > > Dear All: good morning > > > > I have a dataset (as an example) with two column factors (factor1 and > > factor2) and 5 numerical columns (X,Y,Z,U,V). The X and Y columns have > same > > length as factor1; and Z, U, and V have same length as factor2. Please > see > > dataset is copied below. Please note that all dataset columns have NAs > > values. > > > > *Need help on this:* > > > > > > Can we use the grubbs.test() function to detect all outliers and replace > it > > by NA in X and Y datasets per group in factor1; and in Z, U, and V > datasets > > per group in factor2. Columns in the dataframe have different lengths, > but > > when I read the .csv file, R added NA values for the shorter columns. > > > > If you need the .csv data file, please let me know. > > > > > > Thank you very much for your help in advance. > > > > > > > > > > install.packages("outliers")
[R] save() and load()
Dear ALL: I am teaching statistical packages class this semester, in R programing I am trying to explain the use of save() and load() with an example using the iris data. It seems that the save() function works, BUT when I tried to load the data back to R, it seems that there is a problem(s), I could not figure out what went wrong. Any help would be highly appreciated. I saved the iris data in my computer in the text format, "iris.with.head.txt ". Here are my R codes: > irisdata<-read.table("G:/iris.with.head.txt", header=T) > > head(irisdata) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa *# saving the data as an .rda* save(irisdata,file="G:/irisdataTest.rda") *# load the data back to R* load(file="G:/irisdataTest.rda") >head(irisdataTest) Error in head(irisdataTest) : object 'irisdataTest' not found > irisdataTest Error: object 'irisdataTest' not found with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] save() and load()
Hi Jeff: good morning Thank you very much for your detailed explanation. Got it now. With many thanks Abou On Mon, Sep 25, 2023, 9:46 PM Jeff Newmiller wrote: > You never created any object in R called irisdataTest. Objects in the > global environment have names that are unrelated to the names of files on > disk. > > The load function modifies an environment to create a variable named as it > was named in the environment from which it was saved. Thus, you cannot > simply load an object that was saved with one name into an object named > something else. It is possible to create a new environment to put the > loaded objects into, but I wouldn't recommend trying to explain how to do > that to a beginner. Rather, I would instead recommend using saveRDS and > readRDS instead to save/load exactly one object at a time without storing > the object name. > > saveRDS( mtcars, "my_mtcars.rds" ) > new_obj <- readRDS( "my_mtcars.rds" ) > > I would also guide them to never save their environment when prompted by > R... the .RData file this creates will remember mistakes made in previous > sessions making troubleshooting very difficult later. Instead they should > focus on making a top-to-bottom script that has all their analysis steps so > they can start from scratch. > > On September 25, 2023 6:23:01 PM PDT, AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >Dear ALL: > > > >I am teaching statistical packages class this semester, in R programing I > >am trying to explain the use of save() and load() with an example using > the > >iris data. It seems that the save() function works, BUT when I tried to > >load the data back to R, it seems that there is a problem(s), I could not > >figure out what went wrong. > > > >Any help would be highly appreciated. > > > > > >I saved the iris data in my computer in the text format, > "iris.with.head.txt > >". > > > >Here are my R codes: > > > >> irisdata<-read.table("G:/iris.with.head.txt", header=T) > >> > >> head(irisdata) > > Sepal.Length Sepal.Width Petal.Length Petal.Width Species > >1 5.1 3.5 1.4 0.2 setosa > >2 4.9 3.0 1.4 0.2 setosa > >3 4.7 3.2 1.3 0.2 setosa > >4 4.6 3.1 1.5 0.2 setosa > >5 5.0 3.6 1.4 0.2 setosa > >6 5.4 3.9 1.7 0.4 setosa > > > > > > > >*# saving the data as an .rda* > > > >save(irisdata,file="G:/irisdataTest.rda") > > > >*# load the data back to R* > > > >load(file="G:/irisdataTest.rda") > > > > > >>head(irisdataTest) > >Error in head(irisdataTest) : object 'irisdataTest' not found > > > >> irisdataTest > >Error: object 'irisdataTest' not found > > > > > > > >with many thanks > >abou > >__ > > > > > >*AbouEl-Makarim Aboueissa, PhD* > > > >*Professor, Mathematics and Statistics* > >*Graduate Coordinator* > > > >*Department of Mathematics and Statistics* > >*University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >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. > > -- > Sent from my phone. Please excuse my brevity. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] save() and load()
Hi Shu: good morning Thank you very much for your detailed explanation. Got it now. With many thanks Abou On Mon, Sep 25, 2023, 9:39 PM Shu Fai Cheung wrote: > Hi, > > You can try this: > > head(irisdata) > > Objects loaded by load() keep their names when being saved. In your > case, it is 'irisdata'. > > You can also use verbose = TRUE to show the names of objects loaded: > > load(file = "irisdataTest.RData", verbose = TRUE) > > Hope this helps. > > Regards, > Shu Fai > > On Tue, Sep 26, 2023 at 9:24 AM AbouEl-Makarim Aboueissa > wrote: > > > > Dear ALL: > > > > I am teaching statistical packages class this semester, in R programing I > > am trying to explain the use of save() and load() with an example using > the > > iris data. It seems that the save() function works, BUT when I tried to > > load the data back to R, it seems that there is a problem(s), I could not > > figure out what went wrong. > > > > Any help would be highly appreciated. > > > > > > I saved the iris data in my computer in the text format, > "iris.with.head.txt > > ". > > > > Here are my R codes: > > > > > irisdata<-read.table("G:/iris.with.head.txt", header=T) > > > > > > head(irisdata) > > Sepal.Length Sepal.Width Petal.Length Petal.Width Species > > 1 5.1 3.5 1.4 0.2 setosa > > 2 4.9 3.0 1.4 0.2 setosa > > 3 4.7 3.2 1.3 0.2 setosa > > 4 4.6 3.1 1.5 0.2 setosa > > 5 5.0 3.6 1.4 0.2 setosa > > 6 5.4 3.9 1.7 0.4 setosa > > > > > > > > *# saving the data as an .rda* > > > > save(irisdata,file="G:/irisdataTest.rda") > > > > *# load the data back to R* > > > > load(file="G:/irisdataTest.rda") > > > > > > >head(irisdataTest) > > Error in head(irisdataTest) : object 'irisdataTest' not found > > > > > irisdataTest > > Error: object 'irisdataTest' not found > > > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor, Mathematics and Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] save() and load(): *prefer* saveRDS() and readRDS()
Hi Martin: good morning Thank you very much for your detailed explanation. Got it now. With many thanks Abou On Tue, Sep 26, 2023, 3:24 AM Martin Maechler wrote: > >>>>> Jeff Newmiller via R-help > >>>>> on Mon, 25 Sep 2023 18:46:02 -0700 writes: > > > You never created any object in R called irisdataTest. Objects in > the global environment have names that are unrelated to the names of files > on disk. > > The load function modifies an environment to create a variable named > as it was named in the environment from which it was saved. Thus, you > cannot simply load an object that was saved with one name into an object > named something else. It is possible to create a new environment to put the > loaded objects into, but I wouldn't recommend trying to explain how to do > that to a beginner. Rather, I would instead recommend using saveRDS and > readRDS instead to save/load exactly one object at a time without storing > the object name. > > > saveRDS( mtcars, "my_mtcars.rds" ) > > new_obj <- readRDS( "my_mtcars.rds" ) > > > I would also guide them to never save their environment when > prompted by R... the .RData file this creates will remember mistakes made > in previous sessions making troubleshooting very difficult later. Instead > they should focus on making a top-to-bottom script that has all their > analysis steps so they can start from scratch. > > Yes! > > And just re-iterating what Jeff mentioned above: > Notably when teaching, the use of saveRDS() and readRDS() > should be emphasized as safer / self-documenting, ... > for the case where there's just one object to save/load. > > *and* you can always put several objects into a list and > saveRDS() / readRDS() that. > > Note: Our pkg {sfsmisc} nowadays contains a nice utility function > list_() ==> help page online e.g. here > > https://search.r-project.org/CRAN/refmans/sfsmisc/html/list_named.html > > which comes were handy when you want to easily create a *named* > list from a bunch of objects, as e.g. above to be able to nicely use > > saveRDS(list_(obj1, obj2, table3, grob4, data5), > file = "allthings.rds") > > The cute utility is very simply defined as > > ##' list_(a, b, cc) creates a *named* list using the actual arguments' > names > list_ <- function(...) `names<-`(list(...), vapply(sys.call()[-1L], > as.character, "")) > > > > On September 25, 2023 6:23:01 PM PDT, AbouEl-Makarim Aboueissa < > abouelmakarim1...@gmail.com> wrote: > >> Dear ALL: > >> > >> I am teaching statistical packages class this semester, in R > programing I > >> am trying to explain the use of save() and load() with an example > using the > >> iris data. It seems that the save() function works, BUT when I > tried to > >> load the data back to R, it seems that there is a problem(s), I > could not > >> figure out what went wrong. > >> > >> Any help would be highly appreciated. > >> > >> > >> I saved the iris data in my computer in the text format, > "iris.with.head.txt > >> ". > >> > >> Here are my R codes: > >> > >>> irisdata<-read.table("G:/iris.with.head.txt", header=T) > >>> > >>> head(irisdata) > >> Sepal.Length Sepal.Width Petal.Length Petal.Width Species > >> 1 5.1 3.5 1.4 0.2 setosa > >> 2 4.9 3.0 1.4 0.2 setosa > >> 3 4.7 3.2 1.3 0.2 setosa > >> 4 4.6 3.1 1.5 0.2 setosa > >> 5 5.0 3.6 1.4 0.2 setosa > >> 6 5.4 3.9 1.7 0.4 setosa > >> > >> > >> > >> *# saving the data as an .rda* > >> > >> save(irisdata,file="G:/irisdataTest.rda") > >> > >> *# load the data back to R* > >> > >> load(file="G:/irisdataTest.rda") > >> > >> > >>> head(irisdataTest) > >> Error in head(irisdataTest) : object 'irisdataTest' not found > >> > >>> irisdataTest > >> Error: object 'irisdataTest' not found > >> > >> > >> &g
[R] Normal Curve
Dear ALL: How I show the area under the normal curve for example for the following example: Assume X has N(100,15). How to show the area corresponding to the probability: P(90http://www.usm.maine.edu/~aaboueissa/ Office: 301C Payson Smith [[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.
[R] Help needed in R
Dear ALL: I have two quick questions about how to perform some steps in R. Could you please see the attached MS file if the data not clean enough in this email. Thank you so much for all your helps. Abou Here it is: = Consider the following matrix: data<-matrix(c(2,2,12,2,1,10,10,4,10,1,1,2,2,1,2,10,3,1,1,1,3,5,17,23,9,9,3,3,15,5, 4,5,5,5,4,8,1,15,3,3,1,6,3,6,3,4,5,14,4, 0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0),49,2) [,1] [,2] [1,]20 [2,]20 [3,] 120 [4,]20 [5,]10 [6,] 101 [7,] 101 [8,]40 [9,] 101 [10,]11 [11,]10 [12,]21 [13,]21 [14,]10 [15,]20 [16,] 101 [17,]30 [18,]11 [19,]10 [20,]10 [21,]30 [22,]51 [23,] 170 [24,] 230 [25,]90 [26,]90 [27,]30 [28,]30 [29,] 151 [30,]51 [31,]40 [32,]51 [33,]51 [34,]51 [35,]40 [36,]80 [37,]10 [38,] 150 [39,]30 [40,]30 [41,]10 [42,]60 [43,]30 [44,]60 [45,]30 [46,]40 [47,]50 [48,] 140 [49,]40 Q1. Column one is the data set, and column two is an indicator of 1 and 0. Some values in column one corresponding to indicator 1 in column two are different, and some are the same. There are 5 different groups of values in column one with indicator 1 in column two. (a) How I can choose only one value (only one observation) from each of these groups to develop a vector of length 5 as: (1 25 10 15). (b) How I can find number of observations in each of these groups as a vector as: (2 254 1). These are the values with indicator 1. [,1] [,2] [1,]11 [2,]11 [3,]21 [4,]21 [5,]51 [6,]51 [7,]51 [8,]51 [9,]51 [10,] 101 [11,] 101 [12,] 101 [13,] 101 [14,] 151 = == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith __ 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.
[R] Help needed in R
Dear ALL: How I can find the number of observations less than each value in column one with indicator 1 in column two. Please see the data below. For example: number of observations less than 1 with indicator 1 (including those 1 with indicator 1) =2 number of observations less than 2 with indicator 1 (including those 2 with indicator 1) =11 number of observations less than 5 with indicator 1 (including those 5 with indicator 1) =33 number of observations less than 10 with indicator 1 (including those 10 with indicator 1) =43 number of observations less than 15 with indicator 1 (including those 15 with indicator 1) =46 (1, 2,5,10,15) are the values in column one with indicator 1 in column two. which means I need to create a vector(2,11,33,43,46) for the data in column one. With many thanks. Abou Here is the data: === Consider the following matrix: data<-matrix(c(2,2,12,2,1,10,10,4,10,1,1,2,2,1,2,10,3,1,1,1,3,5,17,23,9,9,3,3,15,5, 4,5,5,5,4,8,1,15,3,3,1,6,3,6,3,4,5,14,4, 0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0),49,2) [,1] [,2] [1,]20 [2,]20 [3,] 120 [4,]20 [5,]10 [6,] 101 [7,] 101 [8,]40 [9,] 101 [10,]11 [11,]10 [12,]21 [13,]21 [14,]10 [15,]20 [16,] 101 [17,]30 [18,]11 [19,]10 [20,]10 [21,]30 [22,]51 [23,] 170 [24,] 230 [25,]90 [26,]90 [27,]30 [28,]30 [29,] 151 [30,]51 [31,]40 [32,]51 [33,]51 [34,]51 [35,]40 [36,]80 [37,]10 [38,] 150 [39,]30 [40,]30 [41,]10 [42,]60 [43,]30 [44,]60 [45,]30 [46,]40 [47,]50 [48,] 140 [49,]40 == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith __ 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.
Re: [R] Help needed in R
Dear Ellison: it did not do it. I edited my previous email to make my question more clear. The out put should be: (2,11,33,43,46) For example: number of all observations less than 1 with indicator 1 (including those 1 with indicator 1 but not 1 with indicator 0) =2 number of all observations less than 2 with indicator 1 (including those 2 with indicator 1 but not 2 with indicator 0) =11 number of all observations less than 5 with indicator 1 (including those 5 with indicator 1 but not 5 with indicator 0) =33 number of all observations less than 10 with indicator 1 (including those 10 with indicator 1 but not 10 with indicator 0) =43 number of all observations less than 15 with indicator 1 (including those 15 with indicator 1 but not 15 with indicator 0) =46 (1, 2,5,10,15) are the values in column one with indicator 1 in column two. which means I need to create a vector(2,11,33,43,46) for the data in column one. == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith >>> "S Ellison" <[EMAIL PROTECTED]> 3/3/2008 10:36 AM >>> table(data[data[,2]==1,1]) >>> "AbouEl-Makarim Aboueissa" <[EMAIL PROTECTED]> 03/03/2008 15:20:21 >>> Dear ALL: How I can find the number of observations less than each value in column one with indicator 1 in column two. Please see the data below. For example: number of observations less than 1 with indicator 1 (including those 1 with indicator 1) =2 number of observations less than 2 with indicator 1 (including those 2 with indicator 1) =11 number of observations less than 5 with indicator 1 (including those 5 with indicator 1) =33 number of observations less than 10 with indicator 1 (including those 10 with indicator 1) =43 number of observations less than 15 with indicator 1 (including those 15 with indicator 1) =46 (1, 2,5,10,15) are the values in column one with indicator 1 in column two. which means I need to create a vector(2,11,33,43,46) for the data in column one. With many thanks. Abou Here is the data: === Consider the following matrix: data<-matrix(c(2,2,12,2,1,10,10,4,10,1,1,2,2,1,2,10,3,1,1,1,3,5,17,23,9,9,3,3,15,5, 4,5,5,5,4,8,1,15,3,3,1,6,3,6,3,4,5,14,4, 0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0),49,2) [,1] [,2] [1,]20 [2,]20 [3,] 120 [4,]20 [5,]10 [6,] 101 [7,] 101 [8,]40 [9,] 101 [10,]11 [11,]10 [12,]21 [13,]21 [14,]10 [15,]20 [16,] 101 [17,]30 [18,]11 [19,]10 [20,]10 [21,]30 [22,]51 [23,] 170 [24,] 230 [25,]90 [26,]90 [27,]30 [28,]30 [29,] 151 [30,]51 [31,]40 [32,]51 [33,]51 [34,]51 [35,]40 [36,]80 [37,]10 [38,] 150 [39,]30 [40,]30 [41,]10 [42,]60 [43,]30 [44,]60 [45,]30 [46,]40 [47,]5 0 [48,] 14 0 [49,]40 == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith __ 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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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.
Re: [R] Help needed in R
Dear ALL: Please see below. I hope this will make it more clear. [1,]11 [2,]11 number of all observations less than 1 with indicator 1 (including those 1 with indicator 1 but not 1 with indicator 0)=2 [3,]10 [4,]10 [5,]10 [6,]10 [7,]10 [8,]10 [9,]10 [10,]21 [11,]21number of all observations less than 2 with indicator 1 (including those 2 with indicator 1 but not 2 with indicator 0)=11 [12,]20 [13,]20 [14,]20 [15,]20 [16,]30 [17,]30 [18,]30 [19,]30 [20,]30 [21,]30 [22,]30 [23,]30 [24,]40 [25,]40 [26,]40 [27,]40 [28,]40 [29,]51 [30,]51 [31,]51 [32,]51 [33,]51 number of all observations less than 5 with indicator 1 (including those 5 with indicator 1 but not 5 with indicator 0)=33 [34,]50 [35,]60 [36,]60 [37,]80 [38,]90 [39,]90 [40,] 101 [41,] 101 [42,] 101 [43,] 101 number of all observations less than 10 with indicator 1 (including those 10 with indicator 1 but not 10 with indicator 0)=43 [44,] 120 [45,] 140 [46,] 151 number of all observations less than 15 with indicator 1 (including those 15 with indicator 1 but not 15 with indicator 0)=46 [47,] 150 [48,] 170 [49,] 230 How I can write an R code to do this. Thanks Abou == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith >>> "Henrique Dallazuanna" <[EMAIL PROTECTED]> 3/3/2008 11:38 AM >>> For me is not very clear, but if I understand: sapply(sort(unique(data[data[,2]==1,1])), function(x)sum(data[data[,2]==1 & data[,1] <= x, 1])) But the output is: 2 6 31 71 86 On 03/03/2008, AbouEl-Makarim Aboueissa <[EMAIL PROTECTED]> wrote: > Dear Ellison: > > it did not do it. > > I edited my previous email to make my question more clear. > > > The out put should be: (2,11,33,43,46) > > For example: > > number of all observations less than 1 with indicator 1 (including those 1 with indicator 1 but not 1 with indicator 0) =2 > > number of all observations less than 2 with indicator 1 (including those 2 with indicator 1 but not 2 with indicator 0) =11 > > number of all observations less than 5 with indicator 1 (including those 5 with indicator 1 but not 5 with indicator 0) =33 > > number of all observations less than 10 with indicator 1 (including those 10 with indicator 1 but not 10 with indicator 0) =43 > > number of all observations less than 15 with indicator 1 (including those 15 with indicator 1 but not 15 with indicator 0) =46 > > > > (1, 2,5,10,15) are the values in column one with indicator 1 in column two. > > > which means I need to create a vector(2,11,33,43,46) for the data in column one. > > > > > > == > AbouEl-Makarim Aboueissa, Ph.D. > Assistant Professor of Statistics > Department of Mathematics & Statistics > University of Southern Maine > 96 Falmouth Street > P.O. Box 9300 > Portland, ME 04104-9300 > > Tel: (207) 228-8389 > Fax: (207) 780-5607 > Email: [EMAIL PROTECTED] > [EMAIL PROTECTED] > Office: 301C Payson Smith > > > > >>> "S Ellison" <[EMAIL PROTECTED]> 3/3/2008 10:36 AM >>> > table(data[data[,2]==1,1]) > > > >>> "AbouEl-Makarim Aboueissa" <[EMAIL PROTECTED]> 03/03/2008 > 15:20:21 >>> > > Dear ALL: > > > How I can find the number of observations less than each value in > column one with indicator 1 in column two. Please see the data below. > > > For example: number of observations less than 1 with indicator 1 > (including those 1 with indicator 1) =2 > number of observations less than 2 with indicator 1 > (including those 2 with indicator 1) =11 > number of observations less than 5 with indicator 1 > (including those 5 with indicator 1) =33 > number of observations less than 10 with indicator > 1 (including those 10 with indicator 1) =43 > number of observations less than 15 with indicator > 1 (including those 15 with indicator 1) =46 > > (1, 2,5,10,15) are the values in column one with indicator 1 in column >
Re: [R] Help needed in R
It works. Thank you so much. Abou == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] Office: 301C Payson Smith >>> T.K. <[EMAIL PROTECTED]> 3/3/2008 3:25 PM >>> I guess you are looking for the number of rows satisfying the following condition. Assuming that you have a cutoff k = 1, 2, 5, 10, 15 1) x[i,1] < k regardless of the value of x[i,2], OR 2) x[i,1] == k and x[i,2] == 1 Here is my take on this problem. It is not elegant but it seems to do the job. > ## Data > data1 <-matrix(c(2,2,12,2,1,10,10,4,10,1,1,2,2,1,2,10,3,1,1,1,3,5,17,23,9,9,3,3,15,5, + 4,5,5,5,4,8,1,15,3,3,1,6,3,6,3,4,5,14,4, + 0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0),49,2) > > ## Function definition > find.n <- function(cutoff, x=data1){ + x1 <- x[,1] + x2 <- x[,2] + sum(x1 < cutoff | ((x1 == cutoff )& (x2==1))) + } > > ## Use the function > sapply(c(1, 2, 5, 10, 15), find.n) [1] 2 11 33 43 46 -- == T.K. (Tae-kyun) Kim Ph.D. student Department of Marketing Marshall School of Business University of Southern California == __ 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.
[R] ARMA models
Dear ALL: Could you please eamil me how to simulate Mixed Seasonal ARMA (p,q)x(P,Q)12 models [say ARMA(0,1)x(1,0)12 ]from R. With many thanks. Abou == AbouEl-Makarim Aboueissa, Ph.D. Assistant Professor of Statistics Department of Mathematics & Statistics University of Southern Maine 96 Falmouth Street P.O. Box 9300 Portland, ME 04104-9300 Tel: (207) 228-8389 Fax: (207) 780-5607 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] http://www.usm.maine.edu/~aaboueissa/ Office: 301C Payson Smith [[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.