similar to: update.default: fall back on model.frame in case that the data frame is not in the parent environment

Displaying 20 results from an estimated 10000 matches similar to: "update.default: fall back on model.frame in case that the data frame is not in the parent environment"

2011 Nov 03
1
Select columns of a data.frame by name OR index in a function
Dear all, Sometimes I have the situation where a function takes a data.frame and an additional argument describing come columns. For greater flexibility I want to allow for either column names or column indices. What I usually do then is something like the following: -------------8<------------- f <- function(datf, cols) { nc <- seq_along(datf) cn <- colnames(datf) colOK <-
2012 Mar 20
1
overriding "summary.default" or "summary.data.frame". How?
I suppose everybody who makes a package for the first time thinks "I can change anything!" and then runs into this same question. Has anybody written out information on how a package can override functions in R base in the R 2.14 (mandatory NAMESPACE era)? Suppose I want to alphabetize variables in a summary.data.frame, or return the standard deviation with the mean in summary output.
2018 Jul 20
3
Should there be a confint.mlm ?
It seems that confint.default returns an empty data.frame for objects of class mlm. For example: ``` nobs <- 20 set.seed(1234) # some fake data datf <- data.frame(x1=rnorm(nobs),x2=runif(nobs),y1=rnorm(nobs),y2=rnorm(nobs)) fitm <- lm(cbind(y1,y2) ~ x1 + x2,data=datf) confint(fitm) # returns: 2.5 % 97.5 % ``` I have seen proposed workarounds on stackoverflow and elsewhere, but
2011 Jul 29
1
Environment of a LM created in a function
Dear all, Quite often I have the situation that I've multiple response variables and I create Linear Models for them in a function. The following code illustrates my usual approach: ---------------8<--------------- set.seed(123) dat <- data.frame(x = rep(rep(1:3, each = 3), 4), y = rep(1:3, 12)) dat$z1 <- rnorm(36, dat$x + dat$y) dat$z2 <- rnorm(36, dat$x + 2*dat$y) dat$z3 <-
2011 Mar 08
1
Replacing values in a data.frame/matrix
Hi all, Suppose we have the following matrix m <- matrix(c(1,2,3,2,1,3,3,1,2), ncol = 3, byrow=T) where in each row each number occurs only once. I'd like to define a permutation, e.g. 1 -> 2, 2 -> 1, 3 -> 3 and apply it to the matrix. Thus, the following matrix should result: m.perm <- matrix(c(2,1,3,1,2,3,3,2,1), ncol = 3, byrow=T) i.e. each 1 should map to 2 and vice
2011 Mar 08
1
Read data.frame from clipboard
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110308/5fcad543/attachment.pl>
2018 Jul 20
0
Should there be a confint.mlm ?
>>>>> steven pav >>>>> on Thu, 19 Jul 2018 21:51:07 -0700 writes: > It seems that confint.default returns an empty data.frame > for objects of class mlm. For example: > It seems that confint.default returns an empty data.frame for objects of > class mlm. Not quite: Note that 'mlm' objects are also 'lm' objects, and so it is
2010 Aug 15
1
parent.frame(1) of a S4 method is not a calling environment.
Dear Developers, I wonder what are the parent.frame rules for methods. For ordinary functions one can call parent.frame() and be sure that it is the environment of a calling function. With S4 aparently it is not the case. Here is what I have discovered by trial and error so far: > setClass("A", contains="vector") [1] "A" > setGeneric("foo",
2014 Jun 16
1
model.frame and parent environment
Someone has reported a problem with predict.coxph that I can't seem to solve. The underlying issue is with model.frame.coxph; the same issue is also found in lm so I'll use that for the example. -------------------------- > test <- data.frame(y = 1:10 + runif(10), x=1:10) > myfun <- function(formula, nd) { fit <- lm(formula, data=nd, model=FALSE)
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
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
2001 Feb 04
4
Grim Fandango in wine
Hey all, It's a thorn in my side, I had monkey island 3 running in wine, but this one just doesn't cooperate. The setup program exits with a problem copying install files (error 112, if it means anything). If anyone has got it working, let me know. Thanks
2017 Oct 05
3
working with ordinal predictor variables?
I'm trying to develop a linear model for crop productivity based on variables published as part of the SSURGO database released by the USDA. My default is to just run lm() with continuous predictor variables as numeric, and discrete predictor variables as factors, but some of the discrete variables are ordinal (e.g. drainage class, which ranges from excessively drained to excessively poorly
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 Jul 06
3
Speed up code, profiling, optimization, lapply vs. loops
High everybody, currently I'm writinig a package that, for a given family of variance functions depending on a parameter theta, say, computes the extended quasi likelihood (eql) function for different values of theta. The computation involves a couple of calls of the 'glm' routine. What I'm doing now is to call 'lapply' for a list of theta values and a function, that
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
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,
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] <
2005 Jan 06
4
ices config problems
*** the following config: <input> <module>playlist</module> <param name="type">script</param> <param name="file">/radio/getnextsongpath</param> </input> gets me: Could not find a valid playlist file. Ices Exiting... *** the following header of the config file: <?xml
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