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], na.rm=TRUE)/colSums(d
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 thro
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
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 Gunte
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 i
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 po
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: r-he
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 fi
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"
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 n
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 se
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,
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 el
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 <- c(2,2,3
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 CI
15 matches
Mail list logo