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],
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
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
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
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
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
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
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:
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
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
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
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
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 <-
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
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
18 matches
Mail list logo