search for: datf

Displaying 5 results from an estimated 5 matches for "datf".

Did you mean: data
2011 Aug 02
1
update.default: fall back on model.frame in case that the data frame is not in the parent environment
Dear all, Suppose the following code: --------------8<-------------- mm <- function(datf) { lm(y ~ x, data = datf) } mydatf <- data.frame(x = rep(1:2, 10), y = rnorm(20, rep(1:2, 10))) l <- mm(mydatf) -------------->8-------------- If I want to update l now without providing the data argument an error occurs: --------------8<-------------- > update(l, . ~ .) Error i...
2012 Mar 20
1
overriding "summary.default" or "summary.data.frame". How?
...# FIXME: can we do better z[na] <- nchar(encodeString(z[na]), "b") } z } if (!is.data.frame(dat)) dat <- as.data.frame(dat) ##treat any nonnumeric as a factor factors <- sapply(dat, function(x) {!is.numeric(x) }) ##If only one factor, need drop=FALSE. datf <- dat[ , factors, drop = FALSE] if (alphaSort) datf <- datf[ , sort(colnames(datf)), drop = FALSE] z <- lapply(datf, summary.factor, numLevels=numLevels) nv <- length(datf) nm <- names(datf) lw <- numeric(nv) nr <- max(unlist(lapply(z, NROW))) for(i in 1L:nv) {...
2011 Nov 03
1
Select columns of a data.frame by name OR index in a function
...s 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 <- (cols %in% nc) | (cols %in% cn) if (!all(colOK)) { badc <- paste(sQuote(cols[!colOK]), collapse = ", ") msg <- sprintf(ngettext(sum(!colOK), "%s is not a valid colu...
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 suspect this should be fixed in the stats package. A pro...
2018 Jul 20
0
Should there be a confint.mlm ?
...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 confint.lm() which is called here and fails. > 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 > suspect thi...