similar to: Select columns of a data.frame by name OR index in a function

Displaying 20 results from an estimated 3000 matches similar to: "Select columns of a data.frame by name OR index in a function"

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 in
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)) {
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
2014 Sep 10
1
install.packages misleads about package availability?
In the context of installing a Bioconductor package using our biocLite() function, install.packages() warns > install.packages("RUVSeq", repos="http://bioconductor.org/packages/2.14/bioc") Installing package into '/home/mtmorgan/R/x86_64-unknown-linux-gnu-library/3.1-2.14' (as 'lib' is unspecified) Warning message: package 'RUVSeq' is not available
2011 Nov 29
1
Problems with Raster and clim.pact packages with large netcdf files (2.7G) in x64 bit R
I normally use the raster or clim.pact pckages to read netcdf (.nc) files. This has always worked out for me until this weekend every time i try to read a .nc file i get the following error Program: C:\Program Files\RStudio\bin\x64\rsession.exe File: posixio.c, Line 417 Expression: offset >= 0 This application has requested the Runtime to terminate it in an unusual way.Please contact the
2013 Apr 25
1
lsfit: Error in formatting error message
Hi, in R-3.0 I get the following error when calling lsfit with more observations than variables, which seems to come from an error in the formatting of the error message (note that this was not happening in 2.15.3): > nobs <- 5; nvar <- 6; lsfit(matrix(runif(nobs*nvar), ncol=nvar), runif(nobs), intercept=FALSE) Error in sprintf(ngettext(nry, "%d response", "%d
2009 Apr 07
1
typo in R-ints.texi's description of P_ macro
I think there are some missing words in "R Internals"'s description of the P_ macro. It currently has "A macro as a wrapper for ngettext", which I think ought to be something like "The macro P_ may be used as a wrapper for ngettext". The following patch also makes the 2 alternate definitions of P_ have the same argument names, StringS and StringP. Expanding the
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
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
2013 Dec 05
6
[PATCH 0/3] Small improvements to i18n extraction/handling
Hi, here there are few patches to improve the extraction of translatable messages, and the usage of messages with plural forms. Pino Toscano (3): po: fix broken message extraction po: fix dependencies for libguestfs.pot extraction fish: improve the command error messages generator/fish.ml | 20 ++++++++++++++++---- po/Makefile.am | 24 +++++++----------------- 2 files changed, 23