Your query is too basic to reply to -- that's what tutorials are for! But DO NOT HIJACK OLD THREADS! -- start a new one for new queries.
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 Tue, Jul 16, 2019 at 7:03 AM Thevaraja, Mayooran < m.thevar...@massey.ac.nz> wrote: > Hello Everyone > > I am trying to draw the smooth curve for my simulation > and theoretical result. Anyone has any suggestion to me. Code given below. > > > > library(ggplot2) > > p <- c(0.0005,0.0025,0.0050,0.0075,0.0100,0.0200) > > p_ sim1 <- c(0.3030,0.8245,0.9730,0.9955,1.0000,1.0000) > > p_ the1 <- c(0.3935452,0.9181715,0.9933460,0.9994623,0.9999568,1.0000000) > > p_ sim2 <- c(0.2900,0.8200,0.9720,0.9935,1.0000,1.0000) > > p_ the2 <- c(0.2974667,0.8290809,0.9708782,0.9950537,0.9991625,0.9999993) > > x<-data.frame(p,p_ sim1 ,p _the1,p _sim2,p _the2) > > ggplot(x, aes(p, y = probability))+ > > geom_line(aes(y = p_ sim1,col =" sim1"))+ > > geom_line(aes(y = p_ the1,col =" the1")) + > > geom_line(aes(y = p_ sim2,col =" sim2")) + > > geom_line(aes(y = p_ the2,col =" the2"))+ > > scale_colour_manual("",breaks = c("sim1"," the1"," sim2"," the2"), > > values = c(1:4)) > > > > Mayooran > > > > Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for > Windows 10 > > > > From: Richard O'Keefe<mailto:rao...@gmail.com> > Sent: Wednesday, July 17, 2019 01:33 AM > To: Jeff Newmiller<mailto:jdnew...@dcn.davis.ca.us> > Cc: R-help mailing list<mailto:r-help@r-project.org>; peter > dalgaard<mailto:pda...@gmail.com> > Subject: Re: [R] need help in if else condition > > > > I didn't communicate my problem to R-Sig-Debian because I had never > previously > heard of them. Thank you for the tip. > Poking through the recent archives there I see other people > have had (different) trouble with the Bionic repository. > > Fortunately, the instructions at > https://linuxize.com/post/how-to-install-r-on-ubuntu-18-04/ > worked, after I first removed the existing installation of R. > All I had to do after that was reinstall about 180 packages. > Is there a way to do this automatically? > > However, having installed "Action of the Toes" (are R releases named > by Culture AIs, by any chance?) I still find > > x <- runif(1000000) > > y <- runif(1000000) > > system.time(ifelse(x < y, x, y)) > user system elapsed > 0.087 0.047 0.135 > > system.time(y + (x < y)*(x-y)) > user system elapsed > 0.035 0.008 0.042 > > system.time(pmin(x,y)) > user system elapsed > 0.025 0.004 0.030 > > On Mon, 15 Jul 2019 at 12:04, Jeff Newmiller <jdnew...@dcn.davis.ca.us> > wrote: > > > Did you ask for assistance on R-Sig-Debian? you will need to be more > > explicit than below about what you actually did. FWIW I was able to do it > > [1]... you might have encountered a temporary network problem. > > > > [1] https://cran.r-project.org/bin/linux/ubuntu/README.html > > > > On July 14, 2019 4:55:25 PM CDT, Richard O'Keefe <rao...@gmail.com> > wrote: > > >Four-core AMD E2-7110 running Ubuntu 18.04 LTS. > > >The R version is the latest in the repository: > > >r-base/bionic,bionic,now 3.4.4-1ubuntu1 all [installed] > > > > > >Why not 3.6? Because when i followed the installation instructions, > > >adding > > > > > >deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ > > > > > >to /etc/apt/sources.list, sudo apt update reported > > > > > >W: GPG error: https://cloud.r-project.org/bin/linux/ubuntu > > >bionic-cran35/ > > >InRelease: The following signatures couldn't be verified because the > > >public > > >key is not available: NO_PUBKEY 51716619E084DAB9 > > >E: The repository 'https://cloud.r-project.org/bin/linux/ubuntu > > >bionic-cran35/ InRelease' is not signed. > > >N: Updating from such a repository can't be done securely, and is > > >therefore > > >disabled by default. > > >N: See apt-secure(8) manpage for repository creation and user > > >configuration > > >details. > > > > > >I just repeated the test. > > >> x <- runif(1000000) > > >> y <- runif(1000000) > > >> system.time(ifelse(x<y,x,y)) > > > user system elapsed > > > 0.359 0.043 0.404 > > >> system.time(pmin(x,y)) > > > user system elapsed > > > 0.015 0.008 0.023 > > >> system.time({r<-numeric(1000000);ix <- x < y; r[ix]<-x[ix]; > > >r[!ix]<-y[!ix]; r}) > > > user system elapsed > > > 0.077 0.028 0.105 > > > > > >On Mon, 15 Jul 2019 at 08:00, peter dalgaard <pda...@gmail.com> wrote: > > >> > > >> Er, what version is this? I have (on a late 2010 MB Air!) > > >> > > >> > system.time(ifelse(x < y, x, y)) > > >> user system elapsed > > >> 0.072 0.012 0.085 > > >> > > >> and even > > >> > > >> > system.time({r<-numeric(1000000);ix <- x < y; r[ix]<-x[ix]; > > >r[!ix]<-y[!ix]; r}) > > >> user system elapsed > > >> 0.082 0.053 0.135 > > >> > > >> -pd > > >> > > >> > > >> > On 12 Jul 2019, at 15:02 , Richard O'Keefe <rao...@gmail.com> > > >wrote: > > >> > > > >> > "ifelse is very slow"? Benchmark time. > > >> >> x <- runif(1000000) > > >> >> y <- runif(1000000) > > >> >> system.time(ifelse(x < y, x, y)) > > >> > user system elapsed > > >> > 0.403 0.044 0.448 > > >> >> system.time(y + (x < y)*(x - y)) > > >> > user system elapsed > > >> > 0.026 0.012 0.038 > > >> > > > >> > This appears to be a quality-of-implementation bug. > > >> > > > >> > > > >> > On Thu, 11 Jul 2019 at 04:14, Dénes Tóth <toth.de...@kogentum.hu> > > >wrote: > > >> > > > >> >> > > >> >> > > >> >> On 7/10/19 5:54 PM, Richard O'Keefe wrote: > > >> >>> Expectation: ifelse will use the same "repeat vectors to match > > >the > > >> >> longest" > > >> >>> rule that other vectorised functions do. So > > >> >>> a <- 1:5 > > >> >>> b <- c(2,3) > > >> >>> ifelse(a < 3, 1, b) > > >> >>> => ifelse(T T F F F <<5>>, 1 <<1>>, 2 3 <<2>>) > > >> >>> => ifelse(T T F F F <<5>>, 1 1 1 1 1 <<5>>, 2 3 2 3 2 <<5>>) > > >> >>> => 1 1 2 3 2 > > >> >>> and that is indeed the answer you get. Entirely predictable and > > >> >> consistent > > >> >>> with > > >> >>> other basic operations in R. > > >> >>> > > >> >>> The only tricky thing I see is that R has > > >> >>> a strict vectorised ifelse(logical.vector, some.vector, > > >another.vector) > > >> >>> AND > > >> >>> a non-strict non-vectorised if (logical.scalar) some.value else > > >> >>> another.value > > >> >>> AND > > >> >>> a statement form if (logical.scalar) stmt.1; else stmt.2; > > >> >> > > >> >> Just for the records, there is a further form: > > >> >> `if`(logical.scalar, stmt.1, stmt.2) > > >> >> > > >> >> The main problem with ifelse is that 1) it is very slow, and 2) > > >the > > >mode > > >> >> of its return value can be unintuitive or not too predictable (see > > >also > > >> >> the Value and Warning sections of ?ifelse). One has to be very > > >careful > > >> >> and ensure that 'yes' and 'no' vectors have the same class, > > >because > > >> >> ifelse will not warn you at all: > > >> >>> ifelse(c(TRUE, TRUE), 1:2, LETTERS[1:2]) > > >> >> [1] 1 2 > > >> >>> ifelse(c(TRUE, FALSE), 1:2, LETTERS[1:2]) > > >> >> [1] "1" "B" > > >> >> > > >> >> For options instead of base::ifelse, you might find this > > >discussion > > >> >> helpful: > > >> >> https://github.com/Rdatatable/data.table/issues/3657 > > >> >> > > >> >> > > >> >> Cheers, > > >> >> Denes > > >> >> > > >> >> > > >> >>> > > >> >>> > > >> >>> On Thu, 11 Jul 2019 at 01:47, Eric Berger <ericjber...@gmail.com> > > >wrote: > > >> >>> > > >> >>>> For example, can you predict what the following code will do? > > >> >>>>> a <- 1:5 > > >> >>>>> b <- c(2,3) > > >> >>>>> ifelse( a < 3, 1, b) > > >> >>>> > > >> >>>> > > >> >>>> On Wed, Jul 10, 2019 at 4:34 PM José María Mateos < > > >ch...@rinzewind.org> > > >> >>>> wrote: > > >> >>>> > > >> >>>>> On Wed, Jul 10, 2019, at 04:39, Eric Berger wrote: > > >> >>>>>> 1. The ifelse() command is a bit tricky in R. Avoiding it is > > >often > > >a > > >> >>>> good > > >> >>>>>> policy. > > >> >>>>> > > >> >>>>> You piqued my curiosity, can you elaborate a bit more on this? > > >> >>>>> > > >> >>>>> -- > > >> >>>>> José María (Chema) Mateos || https://rinzewind.org > > >> >>>>> > > >> >>>>> ______________________________________________ > > >> >>>>> 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. > > >> >>>> > > >> >>> > > >> >>> [[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. > > >> > > >> -- > > >> Peter Dalgaard, Professor, > > >> Center for Statistics, Copenhagen Business School > > >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark > > >> Phone: (+45)38153501 > > >> Office: A 4.23 > > >> Email: pd....@cbs.dk Priv: pda...@gmail.com > > >> > > >> > > >> > > >> > > >> > > >> > > >> > > >> > > > > > > [[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. > > [[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.