Dear Kepler,
Yes, R can do this all. But this is is to help you when you get stuck, not
to do all the work for you... You are asking basic stuff, so any
introduction book on R should contain sufficient information to get you
going. So please do read on of those first.
Best regards,
ir. Thierry O
Dear Paul,
R's power is that is works vectorised. Unlike SAS which is rowbased. Using
R in a SAS way will lead to very slow code.
Your examples can be written vectorised
d1 %>%
rownames_to_column("ID") %>%
mutate(
test1 = ifelse(gender == "f" & workshop == 1, 7, 0),
test2 = ifelse(ge
Dear Nick,
The best solution is not to use which() but directy use the logical test.
This will work in case the condition is always FALSE and which() returns a
integer(0). And it is much faster too.
z <- y > 3
y[!z]
library(microbenchmark)
microbenchmark(
y[!y > 3],
y[-which(y > 3)]
)
Best r
You could use kable() from the knitr package.
kable(mytable, format = "latex", escape = FALSE)
\begin{tabular}{l}
\hline
$\beta_0$\\
\hline
aa\\
\hline
bb\\
\hline
cc$\alpha_1$\\
\hline
\end{tabular}
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INST
Dear Bruce,
I think this should be straightforward with tidyverse. If not please
provide a small reproducible data set with dput().
library(tidyverse)
count(Active, Time)
count(Active, Date, Time)
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Fl
The second y-axis in ggplot2 is only intended to relabel an axis with a
fixed transformation. E.g. one axis in degree Celcius and one in Kelvin,
km and miles, ...
It does not rescale the variables.
It looks like you want to display two variables with unrelated units on the
same y-axis. That is not
eth is not a dataframe but of the class rxlsx. You'll need to convert eth
into a dataframe.
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg /
Dear Tracy,
Maybe a workshop of Data Carpentry (https://datacarpentry.org/) might be
relevant.
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie
Dear Debbie,
Have a look at the vignette of the ordinal package. Look for the equation
that defines \eta. And note the minus sign associated with \beta. You'll
need to find the equation used in HLM and compare it with the equation from
ordinal.
Best regards,
ir. Thierry Onkelinx
Statisticus / St
Dear Kelly,
Have a look at the renv package (https://CRAN.R-project.org/package=renv).
Once setup, your code reduces to renv::restore()
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTI
Dear Sacha,
use glm() in this case. I'd rather code the covariable as TRUE / FALSE or
as a factor.
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biome
Dear Patrick,
This is not easy to debug without a reprex
I would check the content of zzz and wide.i in the loop
str(wide.i)
zzz <- rbind(zzz, wide.i)
str(zzz)
Note that the Rmd always runs in a clean environment. This might explain
the difference
Best regards,
ir. Thierry Onkelinx
Statistic
Dear Sripriya,
Step 1. generate random values from a multivariate normal distribution
Step 2. convert the random values into probabilities
Step 3. convert the probabilities into values from the target distribution
library(mvtnorm)
n <- 1e3
correl <- 0.9
lambda <- c(10, 50)
sigma <- matrix(correl,
Dear Helmut,
The mixed models list is more suitable for this kind of question. I'm
forwarding it to that list. Please send any follow-up to that list instead
of the general R help list.
If I understand correctly, you'll need a different variance term for both
treatments (the within subject for T
Dear all,
I'm using this in a function inside a package. The code works fine when I
run it directly.
df %>%
mutate(!!id_column := row_number())
When I run the function I get this error:
Error in mutate(., `:=`(!!id_column, row_number())) :
argument "mutate" is missing, with no default
df is
Think about this. What is the null hypothesis? What is the alternative?
What are their distributions? What is the probability that you get a value
from the alternative when the null hypothesis holds and vice versa? Then
think again about the relevance of your alternative hypothesis. You'll get
a be
Dear Srinidhi,
You are trying to fit 1 random intercept and 2 random slopes per
individual, while you have at most 3 observations per individual. You
simply don't have enough data to fit the random slopes. Reduce the random
part to (1|ID).
Best regards,
Thierry
ir. Thierry Onkelinx
Statisticus
Dear Ding,
It seems that you are looking for the ifelse() function. Clear use of
pmax() and pmin() reduces the number of if statements.
m1 <- c(12, 23, 22, 23)
m2 <- c(23, 23, 3, 5)
Ravg <- ifelse(
pmax(m1, m2) == 23,
pmin(m1, m2),
(m1 + m2) / 2
)
Best regards,
ir. Thierry Onkelinx
Stati
Dear Ben,
I think that you first need to go to your project and then start Rscript
from that location. renv() needs to pick up the .Renviron file located at
the root of your project.
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUU
Dear Luigi,
This is rather an RStudio problem than an R problem. I suggest contacting
RStudio or their community help forum at https://community.rstudio.com/
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDE
Dear Catalin,
use scale_fill_gradient() and set fixed limits
ggplot(df1, aes(x=as.factor(spei), y=as.factor(month), fill = cut(cor,
zCuts))) +
geom_tile() +
scale_fill_gradient(limits = c(-0.7, 0.7))
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Governmen
~ John Tukey
///
<https://www.inbo.be>
Op di 7 jul. 2020 om 18:42 schreef Rasmus Liland :
> On 2020-07-07 12:44 +0200, Thierry Onkelinx via R-help wrote:
> > Op di 7 jul. 2020 om 12:02 schreef Catalin Roibu >:
> > >
&
Dear Axel,
A few quick remarks.
1) This question is more suitable for r-sig-mixed-models.
2) A mixed model needs much more than two groups. If you have only a few
groups, consider a glm with group interactions.
3) Setting the value of a covariate to zero for a set of observations has
the same eff
You are looking for tidyr::pivot_longer()
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assuranc
> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
> ="direction",value.name="percentage")
>
> HTH,
> Eric
>
>
> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
> r-help@r-project.org>
25 matches
Mail list logo