similar to: formula in function as text?

Displaying 20 results from an estimated 40000 matches similar to: "formula in function as text?"

2012 Jan 13
2
question: how to select a column from a dataframe in a function
Hi, I am creating a function and ran into the problem of selecting a column from a dataset. It seems as though the $ function (as in data$columnname) does not apply in the function. In simplified version: This works: testf2<-function(data,columnnumber){print(data[,columnnumber])} But this doesn't: testf<-function(data,column){print(data$column)} Even though the first solution works,
2009 Jun 11
1
formula for degrees of freedom for nonlinear mixed model in nlme
Dear forum members, What is the formula to calculate denominator degrees of freedom (den df) for nonlinear mixed-effect models with covariates? My model is similar to a CO2 uptake example from Pinheiro and Bates (2000, page 376). In this CO2 dataset, there are two treatments and two types (84 observations in total), but den df for each parameter of the model is 64. Isn’t it too high? Your
2010 Oct 07
3
quantile regression
Dear all, I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:
2010 Oct 13
4
loop
Dear all, I am trying to run a loop in my codes, but the software returns an error: "subscript out of bounds" I dont understand exactly why this is happenning. My codes are the following: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N
2012 Dec 19
1
confirming a formula for use with lmer
Hello, I recently began using R and the lme4 package to carry out linear mixed effects analyses. I am interested in the effects of variables 'prime','time', and 'mood' on 'reaction_time' while taking into account the random effect 'subjects.' I've read through documentation on lme4 and came up with the following formula for use with lmer:
2013 Jan 20
1
applying a formula from text
Dear Arun, I am a novice in R bu some my friends that use R for a long time were not able to help me. Thank you really. Concerning your question why I need it, I think that it can be situations where the condition, that I have to apply, depends on the data. May be you can advice me a good text to learn programming in R. Thank you again. Ilya Novikov Sat, Jan 19, 2013 at 8:02 PM, arun kirshna [via
2011 Nov 29
1
Help in determining the formula for a mixed model analysis
Dear R and statistics experts: I have data of a behavioral experiment with the aim to investigate the effect of a memory task on motor learning. Question: I would appreciate help in figuring out a possible formula to determine whether motor learning across sessions differs between 2 groups. Design: - 2 Groups: group A: n=10 subjects, group B: n=10 - 6 motor learning sessions: baseline;
2010 Oct 13
1
(no subject)
Dear all, I have just sent an email with my problem, but I think no one can see the red part, beacuse it is black. So, i am writing again the codes: rm(list=ls()) #remove almost everything in the memory set.seed(180185) nsim <- 10 mresultx <- matrix(-99, nrow=1000, ncol=nsim) mresultb <- matrix(-99, nrow=1000, ncol=nsim) N <- 200 I <- 5 taus <- c(0.480:0.520) h <-
2011 Jun 09
2
Reshape:cast; error using "..." in formula expression.
Whenever I use "..." in the formula of the cast function, from the reshape package, I get the following error: Error in `[.data.frame`(data, , variables, drop = FALSE) : undefined columns selected For example: data(french_fries) #available in the reshape package > head(french_fries) time treatment subject rep potato buttery grassy rancid painty 61 1 1 3 1
2005 Apr 20
2
Suggestions for manipulating formula objects
I'm trying to manipulate/change a formula prior to passing it to another function. A simplified example: User passes formula to my function: y~x My function does: lm(transform(y)~x) Here, transform() is added to the model's response. What is the best way to accomplish this?
2005 May 26
1
Simplify formula for heterogeneity
Dear R-ians, I'm looking for a computational simplified formula to calculate a measure for heterogeneity (let's say H ): H = sqrt [ (Si (Sj (Xi - Xj)?? ) ) /n ] where: sqrt = square root Si = summation over i (= 0 to n) Sj = summation over j (= 0 to n) Xi = element of X with index i Xj = element of X with index j I can simplify the formula to: H = sqrt [ ( 2 * n * Si (Xi) - 2 Si (Sj
2006 Mar 25
1
Suggest patch for princomp.formula and prcomp.formula
Dear all, perhaps I am using princomp.formula and prcomp.formula in a way that is not documented to work, but then the documentation just says: formula: a formula with no response variable. Thus, to avoid a lot of typing, it would be nice if one could use '.' and '-' in the formula, e.g. > library(DAAG) > res <- prcomp(~ . - case - site - Pop - sex, possum)
2020 Aug 10
3
lm() takes weights from formula environment
I wish I had started with "I am disappointed that lm() doesn't continue its search for weights into the calling environment" or "the fact that lm() looks only in the formula environment and data frame for weights doesn't seem consistent with how other values are treated." But I did not. So I do apologize for both that and for negative tone on my part. Simplified
2008 May 30
2
scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)
I've run into a scoping problem in R. I'm calling a function that * creates a formula * calculates a weight vector * calls lm with that formula and weights This fails. Here's a simplified reproduce example: # f works, g doesn't, h is a workaround rm(w) data <- data.frame(y=runif(20), x=runif(20), z=runif(20)) f <- function(k){ w <- data$z^k coef(lm(y~x, data
2009 Feb 23
2
Formula that includes previous row values
Hi R users, Is there an easy way in R to generate the results table below using table 1 and the formula (simplified version of the real problem)? It would be easy if I knew the R equivalent of SAS's retain function, but could not find one. Thanks in Advance for any help! table1: ID X2 X3 1.00 1.00 0 2.00 0.00 3.00 1.00 4.00 3058 5.00 0.00 6.00 6.00 Formula: X3 = x2 + (.24 *
2006 Sep 27
3
Converting text to numbers
Hi, I have Forecast Class and Observed Class in a data matrix as below. > Sample1 FCT OBS 1 1 5 2 2 4 3 3- 3+ 4 3 3 5 3+ 3- 6 4 2 7 5 1 I want to find the difference between Observed and Forecast Classes. How can I get this done? I tried to following to convert the 1 through 5 classes, to 1 through 7 for both OBS and FCT column. > Sample1$OBS2 <- Sample1$OBS
2017 Mar 10
2
named arguments in formula and terms
Hi, we came across the following unexpected (for us) behavior in terms.formula: When determining whether a term is duplicated, only the order of the arguments in function calls seems to be checked but not their names. Thus the terms f(x, a = z) and f(x, b = z) are deemed to be duplicated and one of the terms is thus dropped. R> attr(terms(y ~ f(x, a = z) + f(x, b = z)),
2003 Jan 30
1
as.formula(string) and augPred in lme
Using formulas constructed from strings only partially works for me in lme: library(nlme) data(Orthodont) fm2<-lme(as.formula("distance~age"),data=Orthodont,random=~1|Subject) summary(fm2) # works augPred(fm2) # fails #Error in inherits(object, "formula") : #Argument "object" is missing, with no default I assume that my use of as.formula is wrong, but
2005 Jun 03
2
Simplify formula for iterative programming
Dear R-ians, I am looking for the simplification of a formula to improve the calculation speed of my program. Therefore I want to simplify the following formula: H = Si (Sj ( sqrt [ (Ai - Aj)?? + (Bi - Bj)?? ] ) ) where: A, B = two vectors (with numerical data) of length n sqrt = square root Si = summation over i (= 0 to n) Sj = summation over j (= 0 to n) Ai = element of A with index i Aj
2007 Jun 18
1
Question about lmer
Hello, We have a problem with function lmer. This is our code: Get_values<-function(ff_count, fixed_factors, rf_count, random_factors, y_values) { SA<-matrix(as.array(c(fixed_factors, random_factors)), ncol=3) data<-as.data.frame(SA) y<-as.array(y_values) dd<-data.frame(SA) for(i in 1:(ff_count+rf_count)){ dd[,i]<-as.factor(data[,i]) }