Dear Guy,
Have a look at cast() from the reshape package. You'll need something
like
cast(fldsampleid ~ Analysis, value = "Result", data = your.data.frame)
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor na
Such things are very easy with the ggplot2 package
install.packages("ggplot2")
library(ggplot2)
Dataset <- data.frame(A = c(10,20,40,80), B = c(30,40,100,200))
ggplot(data = Dataset, aes(x = A, y = B)) + geom_point() +
geom_smooth(method = "lm")
More info and example on the ggplot2 website: http:
Pierre,
You did not look hard enough. You need FAQ 7.22
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur-
Dear Pierre,
A more elegant solution is to use ggsave()
library(ggplot2)
for (i in 1:2) {
p <-
qplot(carat, data=diamonds,
fill=color,geom='histogram')+scale_y_continuous(i)
ggsave(filename = paste('test ',i,'.png',sep=''), plot = p)
}
Best regards,
Thierry
--
Here is a more elegant solution using the plyr package.
my.data <- expand.grid(Thesis = 1:3, Day = c(0, 14), Run = 1:10)
my.data$A <- rpois(nrow(my.data), 10)
my.data$B <- rpois(nrow(my.data), 10)
my.data$C <- rpois(nrow(my.data), 10)
library(plyr)
ddply(my.data, .(Thesis, Day), function(x){
Denis,
Have a look at paste(), aggregate(), ddply() (from the plyr package) and melt()
and cast() (both from the reshape package).
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team
This is FAQ 7.31:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat
Does this works? (Untested)
library(plyr)
ddply(your_dataframe, "var1", function(x){
x[which.max(x$var2), ]
})
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstr
Dear Will,
residuals() should take both the fixed and random effects into account.
Can you give us a reproducible example if you get something different?
Use residuals(model, type = "normalized") if you also want to account
for the correlation structure.
What do you want to do with the residuals
Dear Tim,
Are mydat$Date and mydat$Time what you think they are? What output do you get
from str(mydat)?
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverst
Dear Donald,
I'm not sure what the meaning of '3G' and '4G' is. You should take a
look at Sweave() which is a very powerfull tool for generating reports
in R.
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- e
You need sapply
max(sapply(myList, nrow))
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and
Have a look at switch() and which.min()
x <- c(a = 3, b = 1, c = 5)
switch(which.min(x), "a is lowest", "b is lowest", "c is lowest")
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biome
Dear Greg,
First convert your data.frame to a long format using melt(). Then use
ddply() to calculate the averages. Once you get at this point is should
be rather straightforward.
library (ggplot2)
v1 <- c(1,2,3,3,4)
v2 <- c(4,3,1,1,9)
v3 <- c(3,5,7,2,9)
gender <- c("m","f","m","f","f")
d.da
Dear Dennis,
cast() is in this case much faster.
> system.time(bigtab <- ddply(big, .(study, subject, cycle, day),
function(x) xtabs(obs ~ type, data = x)))
user system elapsed
35.360.12 35.53
> system.time(bigtab2 <- cast(data = big, study + subject + cycle + day
~type, value = "ob
Dear Mikkel,
You need to do some reading on terminology.
In your model the fixed effects are channel 1, 2 and 3. samplenumber is
a random effect and the error term is an error term
The model you described has the notation below. You do not need to
create the grouped data structure.
lme(channel0
Dear Edward,
You have no degrees of freedom left to estimate those p-values. Your
design does not allows for the model your implemented. We need a brief
summary of your design in order to help you further.
HTH,
Thierry
---
This will give a matrix with 0 rows.
data.frame(matrix(nrow = 0, ncol = 22, dimnames = list(NULL,
LETTERS[1:22])))
But you should avoid growing dataframes is the final dataframe is going
to be large. You are very likely to get memory problems. It is much to
better to create a large enough datafr
data.
~ John Tukey
Van: Edward Patzelt [mailto:patze...@umn.edu]
Verzonden: dinsdag 7 september 2010 0:25
Aan: ONKELINX, Thierry
CC: r-help@r-project.org
Onderwerp: Re: [R] nlme Output
The design is a repeat
Dear Abhijit,
In ggplot you can use facetting (facet_grid() or facet_wrap()) to create
subplot based on the same dataset. Or you can work with viewport() if
you want several independent plots.
HTH,
Thierry
ir. Thierr
Dear Alex,
I think you want to use apply()
ij <- expand.grid(i = seq_len(dimx),j = seq_len(dimy))
Powermap <- apply(ij, 1, function(x){
Pr(x, c(PRX, PRY), f)
})
Best regards,
Thierry
ir. Thierry Onkelinx
Insti
an answer does not ensure
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
> -Oorspronkelijk bericht-
> Van: Alaios [mailto:ala...@yahoo.com]
> Verzonden: woensdag 27 april 2011 12:14
> Aan: R-help@r-project.org; ONKELINX, Thierry
> Onde
Dear all,
I'm working on a design with rotating panels. Each site is sampled every X
year. Have a look at the code below the get an idea of the design. In reality
the number of sites will be (much) higher.
However I'm not sure if I coded the design correctly in svydesign(). Can
someone confirm
Dear Ben,
Are site, transect and plot factors? And do they have unique id's?
You could try this
rws30.UL$site <- factor(rws30.UL$site)
rws30.UL$transect <- interaction(rws30.UL$site, rws30.UL$transect, drop = TRUE)
rws30.UL$plot <- interaction(rws30.UL$site, rws30.UL$transect, rws30.UL$plot,
d
Dear Victor,
Here is a basic solutions using ggplot2
library(ggplot2)
dataset <- data.frame(Main = c("A", "A", "A", "B", "B"), Detail = c("a", "b",
"c", "1", "2"), value = runif(5, min = 0.5, max = 1))
ggplot(dataset, aes(x = Detail, y = value)) + geom_bar() + facet_grid(.~Main,
scales = "free_
Dear Miya,
Notice the very strong negative correlation between the random intercept and
the random slope in the lme() model. That is usually an indication of problems
(in this case overfitting). If you drop the random slope, then both models
yield the same parameters.
Plotting the data reviels
Something like this?
a=1:10
b=20:30
c=40:50
x=c(a,b,c)
borders <- which(diff(x) != 1)
seqs <- data.frame(start = c(1, borders + 1), end = c(borders, length(x)))
Best regards,
Thierry
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> N
Dear Joshua,
You can accomplish that by setting the position argument in geom_bar to
position_dodge(width = 0).
ggplot(plot.means, aes(x=index, y=means, fill=factor(hilow))) +
geom_bar(position = position_dodge(width = 0.1), stat="identity")
But such a plot can be very misleading. Therefore I
Dear Dave,
I think you want this model.
lme(value~condition:diff - 1,random=~1|subject)
Note that I removed the replicate ID from the model. Include it in the model
makes only sense if you can expect a similar replication effects the
first/second/thirth time that a subject performs your test.
of some data and an aching desire for an answer does not ensure
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
> -Oorspronkelijk bericht-
> Van: der...@gmail.com [mailto:der...@gmail.com] Namens Dave Deriso
> Verzonden: donderdag 20 mei 2010
Have a look at ?varClasses. You could you something like varIdent(form =
~ 1|areatrai) or varExp(form = ~areatrai)
R-sig-mixed-models is a better list for this kind of questions.
Thierry
ir. Thierry Onkelinx
Instituut
Dear Kristina,
Use ifelse(). Note that you must use '==' to test for equality. '=' is
an assignment.
Freqg$condition <- with(freqg, ifelse(mat==1 & flank==1, 1, ifelse(mat
== 2 & flank == 1, 2, NA)))
HTH,
Thierry
ir.
Dear Faiz,
Maybe the xtable package can be helpfull for you. It adds markup tags to
a table. You can choose between LaTeX and HTML. Microsoft can open HTML
files.
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuu
You can use round(value, 2)
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics
Dear Daisy,
This is easy woth ggplot2. Use geom_crossbar() and set the middle bar at
the minimum of maximum.
library(ggplot2)
dataset <- data.frame(catg = (c(1,2,3,2,4,3,2,1,4,3,1)),
min = (c(1,2,3,3,4,5,6,6,3,2,1)),
max = (c(10,6,8,6,7,3,10,9,10,8,9)))
ggplot(dataset, aes(x = catg, y = min, ym
Dear Bert,
The easiest thing would be to merge both datasets and then multiply the
corresponding columns.
both <- merge(df1, df2)
both[, 3:22] * both[, 23:42]
HTH,
Thierry
-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org namens Bert Jacobs
Verzonden: ma 7-6-2010 20:29
Aan: r
Have a look at ?scale_size_manual()
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and
Have a look at the ggplot2 package
x <- 1:6
y <- c(.01,.09,.08,.03,.001,.02)
dataset <- data.frame(x, y)
library(ggplot2)
ggplot(data = dataset, aes(x = x , y = y)) + geom_smooth()
ggplot(data = dataset, aes(x = x , y = y)) + geom_smooth() +
geom_point()
ggplot(data = dataset, aes(x = x , y = y))
Hi Florian,
Have you tried to replace each '\n' with '\r\n'. That did the trick for
me.
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraa
Dear Ann,
The easiest way is to seperate both plots into two subplots. And then use
viewport to paste them together.
Best regards,
Thierry
p1 <-
ggplot(subset(data.melt, pos = "FALSE"),aes(value,ID)) +
geom_point(aes(groups=time,colour=time,shape=time)) +
facet_grid(type~.,scales="fr
You need two logical test and then combine them with & (AND) or | (OR)
i[quantile(i,.25) >= i & i <= quantile(i,.75)]
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & K
It is also a one-liner with ggplot2
dataset <- data.frame(Factor = rep(factor(letters[1:4]), each = 10),
Size = runif(40) * 100)
library(ggplot2)
ggplot(dataset, aes(x = Size)) + geom_histogram() + facet_wrap(~Factor)
--
Dear Sacha,
Do you revisit the same locations per site? If so, use (1|site/location) as
random effect. Otherwise use just (1|site). You might want to add a crossed
random effect (1|date) if you can expect an effect of phenology.
Best regards,
Thierry
PS R-sig-mixed-models is a better list for
library(sos)
findFn("Zero Inflated Lognormal")
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Fores
Have a look at the examples of geom_errorbar() at the website:
http://had.co.nz/ggplot2/geom_errorbar.html
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszo
Dear Johan,
A few remarks.
- R-sig-mixed models is a better list for asking questions about mixed model.
- I presume that Nymphs is the number of insects? In that case you need a
generalised linear (mixed) model with poisson family
- What are you interessed in? The variability among genotypes or
Something like this?
my_data=read.table("clipboard", header=TRUE)
my_data$s_name <- factor(my_data$s_name)
library(plyr)
ddply(my_data, .(s_name), function(x){
x$Im_looking <- x$Depth + as.numeric(x$s_name) / 100
x
})
Best regards,
Thierry
---
Dear Mark,
You cannot compare lm() with lme() because the likelihoods are not the same.
Use gls() instead of lm()
library(nlme)
data("sleepstudy", package = "lme4")
fm <- lm(Reaction ~ Days, sleepstudy)
fm0 <- gls(Reaction ~ Days, sleepstudy)
logLik(fm)
logLik(fm0)
fm1 <- lme(Reaction ~ Days, r
Dear Mark,
I'm cc'ing this to the mixed models list to get some input from other experts.
For them a link to the entire thread:
http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-tp3384054p3384823.html
My comment was based on what I have read in Zuur et al. (2009).
What worries me i
Dear Russ,
Why not use simply
pH <- c(area1 = 4.5, area2 = 7, mud = 7.3, dam = 8.2, middle = 6.3)
That notation is IMHO the most readable for students.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur
Large snip.
> Absolutely vector - no jpeg, png, ... although it takes
> sometimes some convincing of co-authors...
>
That depends on the kind of graph. I aggree that you should try vector at
first. But when it generates very larges files (e.g. scatterplots with
thousands of points) then you
Dear JP,
Please do not cross post between lists.
Here is a possible solution.
library(ggplot2)
p <- rep(c(rep("condition_a", 4), rep("condition_b", 4)), 2)
q <- c(rep("grp_1", 8), rep("grp_2", 8))
r <- sample(1:5, 16, rep = T)
d <- data.frame(p, q, r)
ggplot(d, aes(x = r)) + geom_ribbon(aes(ymax
Dear Alexander,
Instead of testing 'somevector > 0.4', test 'abs(somevector - 0.4) <
some.small.number'
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Dear January,
Have a look at Eclipse with the STAT-ET plugin http://www.walware.de/goto/statet
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstra
Dear Paul,
The command
RSiteSearch("nearest neighbour")
Will give you the answer that you need. (The second hit is the function you
want).
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonde
Dear Remko,
Here is a working example on what Duncan suggested.
Best regards,
Thierry
<>=
TheObject <- "Something"
ls()
rm("TheObject")
@
%outputs the R code but does not execute it. So no error
<>=
TheObject
@
% executes the code but displays only the error
<>=
cat(try(TheObject))
@
> -
Just type glm at the prompt.
> glm
function (formula, family = gaussian, data, weights, subset,
na.action, start = NULL, etastart, mustart, offset, control = list(...),
model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, contrasts = NULL,
...)
{
call <- match.call()
if (
Can't you use sapply?
sapply(seq_len(10), function(i){SomeExpression(i)})
Best regards,
Thierry
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens David Winsemius
> Verzonden: woensdag 10 augustus 2011 15:50
> Aan: Anthony Ching
Without a reproducilbe example, it is hard to give you good advise...
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens ashz
> Verzonden: maandag 22 augustus 2011 23:53
> Aan: r-help@r-project.org
> Onderwerp: [R] Time series and
Dear Tom,
I think you failed to generate simulated outcome from the correct model. Hence
the zero variance of your random effects. Here is a better working example.
library(lme4)
fake2 <- expand.grid(Bleach = c("Control","Med","High"), Temp =
c("Cold","Hot"), Rep = factor(seq_len(3)), ID = seq
Have you tried adding print() statements? e.g. changing summary(x) to
print(summary(x))
Posting a reproducible example would help us.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
t
You did not search hard enough.
RSiteSearch("sign test")
or
library(sos)
findFn("sign test")
Both gives you plenty of possible functions.
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Paul Smith
> Verzonden: maandag 19 sep
Just use the logical operators.
Counts <- c(1,0,21,2,0,0,234,2,0)
Counts > 0
1 *(Counts > 0)
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlec
Dear Helios,
I think you rather want a mixed model with shoe as random effect.
library(lme4)
lmer(Y ~ Ground + (1|Shoe)) #the effect of shoe is independent of the ground
effect
or
lmer(Y ~ Ground + (0 + Ground|Shoe)) #the effect of shoe is different per
ground.
Best regards,
Thierry
ir. Thie
Is this homework? If it is, please read the posting guide.
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54
Dear John,
R-sig-mixed-models is a better list for this kind of questions.
It looks like the model finds no evidence for a random slope. Notice the very
small variance of the random slope. In the model without random intercept, the
random slope tries to mimic the effect of a random intercept.
Dear Christof,
You want the predict() function. See ?predict.lme for the details.
Best regards,
Thierry
PS Questions on lme() can be asked at r-sig-mixed models.
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitsz
You can use a combination of the outer() and apply() functions
n <- 10
p <- 9
dataset <- data.frame(matrix(rep(seq_len(p), each = n), nrow = n, ncol = p))
colnames(dataset) <- paste("p", seq_len(p), sep = "")
test <- t(apply(dataset, 1, function(x){ x %o% x}))
colnames(test) <- paste("p", rep(seq_
Dear Laurent,
An R proces uses only one core. It is possible to use multiple cores. Have a
look at he Hig-Performance and Parallel Computing task view
(http://cran.freestatistics.org/web/views/HighPerformanceComputing.html)
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en
Have a look at the MCMCglmm package.
http://www.freestatistics.org/cran/web/packages/MCMCglmm/vignettes/Overview.pdf
Best regards,
Thierry
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Xiongqing Zhang
> Verzonden: dinsdag 1
Dear Sigrid,
This is very easy with the ggplot2 package
install.packages("ggplot2")
library(ggplot2)
ggplot(data = Your.Data.Frame, aes(x = YEAR, y = YIELD, colour = TREATMENT)) +
geom_point() + geom_smooth(method = "lm") + facet_wrap(~Country)
Best regards,
Thierry
> -Oorspronkelijk beri
Reading the helpfile (as the posting guide asks you to do) of write.table will
solve your problem.
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Paolo Rossi
> Verzonden: woensdag 15 juni 2011 16:52
> Aan: r-help@r-project.org
Dear Philip,
If the values are not important, then you don't need different Y-axes. Why not
standardise the seven datasets so they have a common scale?
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur-
This is probably due to a numerical value that is coded as a factor. Have a
look at the example below.
In ggplot2 one line per group is plotted. The default grouping is the
combination of all factors. In the first example only B, in the second and
third example both A and B. This leaves just one
Dear Mark,
I think you want glm(DV ~ log10(IV), family=poisson)
Note that the poisson family uses the log-link by default. Hence you don't need
to log-transform DV yourself.
Best regards,
Thierry
ir. Thierry Onkelinx
Dear John,
You can get pretty close with ggplot2.
Best regards,
Thierry
library(ggplot2)
dataset <- data.frame(Name = LETTERS[1:26])
dataset$Score <- runif(nrow(dataset))
dataset$Category <- cut(dataset$Score, breaks = c(-Inf, 0.33, 0.66, Inf),
labels = c("Bad", "Neutral", "Good"))
dataset$Nam
Dear Vikas,
Have at look at ?merge()
Best regards,
Thierry
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Bansal, Vikas
> Verzonden: dinsdag 5 juli 2011 16:51
> Aan: David Winsemius
> CC: r-help@r-project.org
> Onderwerp: Re
help("%%")
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assuranc
Dear Mark,
Interpreting one of the main effects when they are part of an interaction is,
AFAIK, not possible.
Your statement about comparing treatments when Year is continuous is not
correct. The parameters of treatment assume that Year == 0! Which might lead to
very strange effect when year is
Dear Ben,
Maybe the model converges more slowy than other models. Running more iterations
might solve the problem. Have a look at ?lme and ?lmeControl.
Best regards,
Thierry
PS R-sig-mixedmodels is a better list for questions on lme().
-
Dear Joe,
You need to use offset()
lm(y ~ a + offset(b) + c)
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Something like this?
dataset <- data.frame(x = x, y = y)
dataset$Group <- cumsum(c(0, diff(!is.na(dataset$y) & dataset$y == 0)) == 1)
library(plyr)
tmp <- ddply(subset(dataset, y == 0), .(Group), function(z){c(Mean = mean(z$x,
na.rm = TRUE))})
result <- merge(dataset, tmp)
result$Mean[is.na(resul
Dear Bruce,
It's doable with ggplot2, but image() is probably a better solution.
To use ggplot2, you will need to convert your array into a data.frame where
each row has the information for one cell (x, y and colour)
library(ggplot2)
#create some dummy data
dataset <- expand.grid(x = seq_len(10
Dear Mario,
Have a look at Eclipse with the StatET plugin. One of the benefits is that is
available for both Linux and Windows which simplifies things when you need to
switch often between Windows and Linux (e.g. Windows at work and Linux at home).
Best regards,
Thierry
--
Dear Chandra,
You're on the wrong track. You don't need for loops as you can do this
vectorised.
as.numeric(interaction(data$Groups, data$Dates, drop = TRUE))
Best regards,
Thierry
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> N
Dear Caroline,
Here is a faster and more elegant solution.
> n <- 1
> exampledata <- data.frame(orderID = sample(floor(n / 5), n, replace = TRUE),
> itemPrice = rpois(n, 10))
> library(plyr)
> system.time({
+ ddply(exampledata, .(orderID), function(x){
+ data.frame(itemPr
How about this?
Andpleasemakeusofthelargekeyatthebottomofyourkeyboard.Itmakescodemuchmorereadable.
library(ggplot2)
spd <- factor(c("s","f","f","s","f","s","s","s","f","f","s","f"))
r <- c(4.9,3.2,2.1,.2,3.8,6.4,7.5,1.7,3.4,4.1,2.2,5)
dataset <- data.frame(spd, r)
dataset <- rbind(cbind(dataset,
Dear Babs,
This is how I would present the model, if I had enough data to support the
model. The model is too complicated for your data and leads to a perfect fit.
Is this the aggregated dataset, or does your design has no replicates?
Best regards,
Thierry
dataset$combinatie <- dataset$proefo
Dear Johan,
Why should it be complicated? You have a very simple model, thus a very simple
formula. Isn't that great?
Your formula matches the model. Though Trust~Culture + Structure *
Speed_of_Integration is another option. The model fit is the same, the only
difference is the parameterizatio
Dear Albert-Jan,
The easiest way is to create extra variables with the corresponding aggregation
level. substr() en strsplit() can be your friends. Once you have those
variables you can use aggregate() or any other aggregating function. You don't
need loops.
Best regards,
Thierry
> -Oors
Something like this?
library(plyr)
ddply(df, .(group), function(x){
x[sample(nrow(x), 1), ]
})
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverst
Giovanni,
Have you tried Bert suggestion 2)? Because his log(R) ~ A*B + C + D is NOT the
same as your log(R)~A+B+I(A*B)+C+D
Note that I(A * B) means: create a new variable that is the product of A and B.
Which is not meaningfull if A and B are factors (hence the warning you got).
So I(A * B) is
Dear Alessio,
A few remarks.
- R-sig-mixed models is a better list for this kind of questions
- use the glmer() function if you want logistic or poisson regression
- the error you are getting is an indication that the model is too complex for
the data
- watch for colinearity in the covariates
B
Dear all,
I'm trying to use data.table to summarise a table and merge it to another
table. Here is what I would like to do, but by using data.table() in a proper
way.
library(data.table)
tab1 <- data.table(ID = 11:20, A = rnorm(10), D = 1:10, key = "ID")
tab2 <- data.table(ID2 = 1:10, D = rep(1
Dear Michael,
Did you measure newborns? If not center age to a value that makes sense in
relation with the range of age in your dataset. Then the intercept will be the
height at the reference age. And most likeli non-negative.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur-
Dear Alfreda,
anova(area_grass) will tell you IF the average grass area is different among
areas.
If you want to know WHICH areas are different from each other, then you have to
do some multiple comparisons. You can use the multcomp package: e.g.
library(multcomp)
glht(area_grass, linfct = mc
2011 at 2:17 PM, ONKELINX, Thierry
wrote:
> Dear Alfreda,
>
> anova(area_grass) will tell you IF the average grass area is different among
> areas.
>
> If you want to know WHICH areas are different from each other, then you have
> to do some multiple comparisons. You ca
Dear Michael,
Our current work flow is to use Sweave and LaTeX. If Word output is needed we
convert the LaTeX files to html using htlatex (installed with MikTex). Those
html files can be opened with ms word.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek /
Dear Richard,
You can do this with some nested ifelse statements.
Assuming variable2.num has only positive integers and variable1.fac is only 0
or 1
Variable3 <- ifelse(variable1.fac == 0, ifelse(variable2.num == 0, 1, 2),
ifelse(variable2.num == 0; 3; 4))
A more fancy solution
as.numeric(fac
Nameless,
http://had.co.nz/ggplot2/geom_histogram.html has a few examples
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
thierry.
301 - 400 of 618 matches
Mail list logo