Re: [R] Monte Carlo simulation for ratio and its CI

2019-03-26 Thread David L Carlson
I second the vote on needing a tutorial. You need to learn about how R does things and get familiar with vectorization and the apply() family of functions. You defined dat but not dat1 in your code so I'll just use dat. First, to get the ratios: (ratios <- colSums(dat[-3],

Re: [R] loop through columns in a data frame

2019-03-26 Thread Yuan, Keming (CDC/DDNID/NCIPC/DVP) via R-help
Thank you so much, Jim. That’s exactly what I need. Sorry for not providing the data frame. But you created the correct data structure. Thanks again! From: jim holtman Sent: Monday, March 25, 2019 2:07 PM To: Yuan, Keming (CDC/DDNID/NCIPC/DVP) Cc: R-help@r-project.org Subject: Re: [R] loop

[R] Quantile Density Contours

2019-03-26 Thread Bernard McGarvey
I want to see if I can reproduce the plot below in R. If I understand it correctly, i takes my bivariate data and creates quantile density contours. My interpretation of these contours is that they enclose a certain % of the total data. I am using the bkde2D function in library KernSmooth which

Re: [R] Substitution in expressions

2019-03-26 Thread Viechtbauer, Wolfgang (SP)
I initially had a loop, but wanted something vectorized (the vector of expressions is being used as an argument in a function call). But I am happy with sticking to mapply() (plus the slight simplification suggested by Peter Dalgaard). Best, Wolfgang -Original Message- From: Bert

Re: [ESS] Assignment operator "<-" not bound to "_" anymore (or any other default it seems).

2019-03-26 Thread Alex Branham via ESS-help
On Tue 26 Mar 2019 at 11:39, Marius Hofert via ESS-help wrote: > In 18.10.3snapshot (GNU Emacs 26.1, macOS 10.14.4) "_" is not the > assignment operator "<-" anymore (it still was in 18.10.2). This step, > especially the fact that there is no new default to obtain "<-" (or is > there?) might

Re: [R] Substitution in expressions

2019-03-26 Thread Bert Gunter
Perhaps something like this (apologies if beating a dead horse): plot(NA,NA, xlim = c(-1,5),ylim = c(-1,5), xlab = "", ylab = "") for(i in 1:3) text(i,i,labels =bquote(2^.(i))) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things

[ESS] Assignment operator "<-" not bound to "_" anymore (or any other default it seems).

2019-03-26 Thread Marius Hofert via ESS-help
Hi, In 18.10.3snapshot (GNU Emacs 26.1, macOS 10.14.4) "_" is not the assignment operator "<-" anymore (it still was in 18.10.2). This step, especially the fact that there is no new default to obtain "<-" (or is there?) might scare away users... I'm also posting this so that others can find it as

[R] [R-pkgs] arsenal v3.0.0: An Arsenal of 'R' Functions for Large-Scale Statistical Summaries

2019-03-26 Thread Heinzen, Ethan P. via R-packages
I'm pleased to announce the release of the "arsenal" package v3.0.0 on CRAN (https://cran.r-project.org/package=arsenal)! "arsenal" has experienced some major growth in the last few months, starting with the release of v2.0.0 in January. We tried to maintain backwards compatibility wherever

Re: [R] Substitution in expressions

2019-03-26 Thread Viechtbauer, Wolfgang (SP)
Hi Bert, I am indeed creating a mathematical expression, but ?plotmath doesn't cover how to do such a vectorized substitution. Best, Wolfgang -Original Message- From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Tuesday, 26 March, 2019 15:52 To: Viechtbauer, Wolfgang (SP) Cc:

Re: [R] Substitution in expressions

2019-03-26 Thread Viechtbauer, Wolfgang (SP)
Ok, thanks. Happy to stick with mapply() then. Best, Wolfgang -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Tuesday, 26 March, 2019 15:40 To: Viechtbauer, Wolfgang (SP) Cc: r-help mailing list Subject: Re: [R] Substitution in expressions I think mapply() is

Re: [R] Substitution in expressions

2019-03-26 Thread Bert Gunter
I believe you're going about this the wrong way. You seem to want mathematical expressions. Fot this, see ?plotmath. 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"

Re: [R] Substitution in expressions

2019-03-26 Thread peter dalgaard
I think mapply() is fine. You could do > Vectorize(function(x,y) as.expression(bquote(.(x)^.(y(base,expo) expression(1L^2, 2L^2, 3L^3, 4L^3, 5L^4) but it is really not that much clearer and does mapply() internally anyway. There's no automatic vectorization in substitute/bquote, so you do

Re: [R] Monte Carlo simulation for ratio and its CI

2019-03-26 Thread Jeff Newmiller
Do you really not know how to use a for loop? The tutorial recommendation seems apropos... On March 26, 2019 5:57:17 AM PDT, Marna Wagley wrote: >Dear Bert, >Thank you very much for the response. >I did it manually but I could not put them in a loop so that I created >the >table manually with

Re: [R] Substitution in expressions

2019-03-26 Thread Viechtbauer, Wolfgang (SP)
Apologies for not being clearer. The code does what I want, but I was wondering if there is a simpler way of doing this, using substitute()/bquote() directly without the mapply(). Best, Wolfgang -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Tuesday, 26 March,

Re: [R] Substitution in expressions

2019-03-26 Thread peter dalgaard
Er, I'm confused. You post some code, the code does something. In which sense is this not what you want? This is slightly more direct: > mapply(function(x,y) as.expression(bquote(.(x)^.(y))), base, expo) expression(1L^2, 2L^2, 3L^3, 4L^3, 5L^4) but I sense that you are looking for something

[R] Substitution in expressions

2019-03-26 Thread Viechtbauer, Wolfgang (SP)
Hi All, I am trying to create a vector of expressions, where the elements in the expressions are contained in other vectors (i.e., they should be substituted). I made some attempts with substitute() and bquote(), but couldn't get this to work. My solution so far is: base <- 1:5 expo <-

Re: [R] Monte Carlo simulation for ratio and its CI

2019-03-26 Thread Marna Wagley
Dear Bert, Thank you very much for the response. I did it manually but I could not put them in a loop so that I created the table manually with selecting the rows randomly several times. Here what I have done so far, please find it. I want to create the table 100 times and calculate its mean and

Re: [R-es] Uso de merge

2019-03-26 Thread jose luis via R-help-es
Antonio, yo creo que con la instrucción full_join te deberían aparecer todos los años(los que no estén presentes en ambas matrices saldrán con muchos NAs). El mensaje que te sale (Column `Country` joining factors with different levels, coercing to character vector) creo que es porque la