similar to: Checking formulae: are lower order terms included

Displaying 20 results from an estimated 4000 matches similar to: "Checking formulae: are lower order terms included"

2010 Jun 21
2
list() assigning the same value to two items
Hi everybody, I'd like to have a list with two elements, where both elements have the same value: z <- list(a=1, b=1) If it happens, that I've to change the value, I've to assure that I change both. This is error prone. Hence, a better way to achieve this is to define: tmp <- 1 z <- list(a=tmp, b=tmp) Now, I'm wondering if it is possible to make this more compact: z
2012 Oct 31
1
aggregate.formula: formula from string
Dear all, I want to use aggregate.formula to conveniently summarize a data.frame. I have quiet some variables in the data.frame and thus I don't want to write all these names by hand, but instead create them on the fly. This approach has the advantage that if there will be even more columns in the data.frame I don't have to change the code. I've hence tried to construct a formula
2011 May 11
0
stats:::biplot.prcomp: Scaling, typo in the help file?
Dear all, >From the documentation of biplot.prcomp: scale: The variables are scaled by 'lambda ^ scale' and the observations are scaled by 'lambda ^ (1-scale)' where 'lambda' are the singular values as computed by 'princomp'. >From the source code of prcomp: lam <- x$sdev[choices] n <- NROW(scores) lam <- lam * sqrt(n)
2012 Jul 03
2
ggplot2: legend
Dear all, I produced the following graph with ggplot which is almost fine, yet I don't like that the legend for "Means" and "Observations" includes a line, though no line is used in the plot for those two (the line for "Overall Mean" on the other hand is wanted): library(ggplot2) ddf <- data.frame(x = factor(rep(LETTERS[1:2], 5)), y = rnorm(10)) p <-
2012 Dec 10
1
Sweep out control
Dear all, Assume that I have the following data structure: d <- expand.grid(subj=1:5, time=1:3, treatment=LETTERS[1:3]) d$value <- 10 ^ (as.numeric(d$treatment) + 1) + 10 * d$subj + d$time d$value2 <- 100000 + d$value where d$treatment == "C" stands for my control group. What I want to achieve now is to subtract the values corresponding to d$treatment == "C" from
2012 Jul 02
5
ggplot: dodge positions
Dear all, I want to get a series of boxplots (grouped by two factors) and I want to overlay the original observations and the following code does almost what I want: library(ggplot) ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4))) ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point() Yet the position of the points
2013 Nov 04
1
ggplot2: Add '+' operator for aes (uneval) objects
Dear all, Is there a reason, why there is no +-operator for aes (i.e. uneval) objects (as there is for themes and gg objects)? I had a couple of cases where such an operator would be useful, for instance to combine the result of aes and aes_string in functions. Any flaws with the following proposition: `+.uneval` <- function(e1, e2) { dup <- names(e1) %in% names(e2) if (any(dup)) {
2010 Dec 13
1
predict.lm[e] with formula passed as a variable
Dear all, In a function I paste a string and convert it to a formula which I pass to lm[e]. The idea is to write a function which takes the name of the response variable and the explanatory variable and the data frame as an argument and calculates an lm[e]. (see example below) This works fine, but if I want to make a prediction on this model, R complains that the object holding the formula
2009 Jun 25
1
Rd: pdf manual: package information not on first page
Hi everybody, currently I'm working on two packages, where I've included a <package-name>-package.Rd documentation file (with \docType set to "package") in each case. When I run "R CMD check" everything works fine, and a call to "R CMD install" generates the appropriate html, text and pdf documentation. While the package documentation (generated
2003 Jul 03
2
Bug in plotting groupedData-objects
Dear Experts, May be the problem is still solved, however I tried to find the answer in the archives: I use: > R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.1 year 2003 month 06 day 16
2011 Jan 05
1
Minimum of an ordered factor
Hi everybody, Is there a particular reason, why this code does not work as intended: z <- factor(LETTERS[1:3], ordered = TRUE) u <- 4:6 min(z[u > 4]) Error in Summary.factor(2:3, na.rm = FALSE) : min not meaningful for factors I agree that min is indeed not meaningful for not ordered factors, but it makes sense for ordered factors. Especially since z[3] <
2010 Aug 30
1
lattice: limits in reversed order with relation="same"
Hi everybody, I want an x-axis which has xlim=c(max, min) rather than xlim=c(min, max) in order to reflect the type of the process (cooling): library(lattice) myprepanel <- function(x,y,...) list(xlim=rev(range(x))) x <- rep(1:10, 100) z <- factor(sample(10, 1000, T)) y <- rnorm(1000, x, as.numeric(z)) xyplot(y~x|z, scales=list(x="free"), prepanel=myprepanel) This works
2011 Oct 21
1
droplevels: drops contrasts as well
Dear all, Today I figured out that there is a neat function called droplevels, which, well, drops unused levels in a data frame. I tried the function with some of my data sets and it turned out that not only the unused levels were dropped but also the contrasts I set via "C". I had a look into the code, and this behaviour arises from the fact that droplevels uses simply factor to drop
2002 Nov 06
1
estimate statement?
Dear all, I have a question about linear models. Is there something comparable to the estimate statement in SAS? E.g. proc mixed data=test; class x1 x2; model y=x1|x2 /s; estimate 'x1' x1 -1 1 x1*x2 -0.5 -0.5 0.5 0.5; estimate 'x2' x2 -1 1 x1*x2 -0.5 0.5 -0.5 0.5; run; Thanks for the help, Dominik Dominik Grathwohl Biostatistician Nestl? Research
2010 May 04
1
Lazy evaluation in function call
Hi everybody, how is it possible to refer to an argument passed to a function in the function call? What I like to do, is something like f <- function(x,y) x+y f(2, x) # should give 4 The problem is of course that x is only known inside the function. Of course I could specify something like f(z<-2,z) but I'm just curious whether it is possible to use a fancy combination of eval,
2002 Sep 23
2
R crash with internet2.dll
Hi, I'm using: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 5.1 year 2002 month 06 day 17 language R and I would like to apply: > update.packages() trying URL
2010 Aug 23
2
Sum a list of tables
Hi all, In R it is possible to sum tables: > (a <- table(rep(1:3, sample(10,3)))) 1 2 3 2 5 7 > a+a 1 2 3 4 10 14 Now suppose that I have a list of tables, where each table counts the same things > k <- list(a,a,a) How can I sum all tables in k? > do.call(sum, k) [1] 42 does not work since it sums over each table. > do.call(`+`, list(a,a)) 1 2 3 4 10
2003 Jan 21
1
Orders of terms in formulae
Hi, Given that R reports Type I sums of squares, isn't it a bit anachronistic that it re-orders terms in formulae? > d <- expand.grid(y=rnorm(8), + A=factor(c(1,2)), + B=factor(c(1,2)), + C=factor(c(1,2))) > summary(aov(y ~ A+B+A:B+C,data=d)) Df Sum Sq Mean Sq F value Pr(>F) A 1 8.294e-34 8.294e-34 1.027e-33 1
2002 Nov 07
4
Preferable contrasts?
Dear all, I'm working with Cox-regression, because data could be censored. But in this particular case not. Now I have a simple example: PRO and PRE are (0,1) coded. The response is not normal distributed. We are interested in a model which could describe interaction. But my results are depending strongly in the choose of the contrast option. It is clear that there is some dependence in
2004 Oct 25
2
printing ISO/8859-1 characters
Hi, I ran into an odd problem with the print command for R-2.0 on a windows machine. The icelandic character thorn (??,??) which is included in in the Latin-1 character set [iso/8859-1 char# 222 (upper case) and #254 (lower case)] prints out incorrectly. Instead of getting the correct character I get the octal codes for upper and lower case thorn (\336 or \376). This only happens on a windows