similar to: Does a formula object have a "left hand side"

Displaying 20 results from an estimated 8000 matches similar to: "Does a formula object have a "left hand side""

2007 Aug 15
3
Formula in lm inside lapply
I am trying to run separate regressions for different groups of observations using the lapply function. It works fine when I write the formula inside the lm() function. But I would like to pass formulae into lm(), so I can do multiple models more easily. I got an error message when I tried to do that. Here is my sample code: #generating data x1 <- rnorm(100,1) x2 <- rnorm(100,1) y <-
2007 Oct 01
4
Disentagling formulas
I am writing a program in which I would like to take in a formula, change the response (Y) variable into something else, and then pass the formula, with the new Y variable to another function. That is, I am starting with formula <- Y~X1+X2+X3 and I'd like to do something like Y <- formula$Y newY <- f(Y) lm(newY~X1+X2+X3) So far, it seems that my
2010 Nov 08
7
How to rbind list of vectors with unequal vector lengths?
Hi, How to rbind these vectors from a list?: > l <- list(a = c(1, 2), b = c(1, 2, 3)) > l $a [1] 1 2 $b [1] 1 2 3 > do.call(rbind, l) [,1] [,2] [,3] a 1 2 1 b 1 2 3 Warning message: In function (..., deparse.level = 1) : number of columns of result is not a multiple of vector length (arg 1) > -J
2010 Aug 11
4
Arbitrary number of covariates in a formula
Hello! I have something like this: test1 <- data.frame(intx=c(4,3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x1=c(0,2,1,1,1,0,0), x2=c(1,1,0,0,2,2,0), sex=c(0,0,0,0,1,1,1)) and I can easily fit a cox model: library(survival) coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1) However, I want to
2006 Nov 01
3
matrix manipulation with a for loop
Hi, Having a matrix F.zoo (6575,189) with NA's in some columns I'm trying to extract from each column the percent of days within an specific range, so I've wrote this procedure: length(subset(F.zoo[,86],(F.zoo[,86]>=5) & (F.zoo[,86]<= 9)))/(length(F.zoo[,86])-length(subset(F.zoo[,86],is.na(F.zoo[,86]))))*100 But to do this for each column (189) is pretty hard, so I want
2010 May 23
4
creating a reverse geometric sequence
Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: > dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value in the sequence. There is of course: dg <- function(x) { res <- integer() while(x >= 1) { res <- c(res, x) x
2013 Mar 02
2
Multiple left hand side variables in a formula
The lattice package uses special logic to allow for multiple left-hand-side variables in a formula, e.g. y1 + y2 ~ x. Is there an elegant way to do this outside of lattice? I'm trying to implement a data summarization function that logically takes multiple dependent variables. The usual invocation of model.frame( ) causes R to try to do arithmetic addition to create a single dependent
2010 Sep 18
3
How to check the available of a package on R repo
Hi folks, Debian 504 64-bit What is the correct syntax to check the available of a package on R repo? > available.packages("emacs", "OS_type=linux") Warning: unable to access index for repository emacs Package Version Priority Depends Imports LinkingTo Suggests Enhances OS_type License File Repository > available.packages("emacs") Warning: unable
2010 May 31
0
Put two plots side by side
Two different ways: library(ggplot2) x=5 size=50 A=data.frame(X=sample(x, size, replace=T), Y=sample(x, size, replace=T),a=rep(1:2,each=25));A # Facetting qplot(X,Y,data=A) + geom_jitter(position=position_jitter(width=.03)) + facet_grid(.~a) # Or with vp p=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.03)) ggsave(p, file='main.png') p1=qplot(X, Y, data=A) +
2010 Oct 25
2
Question on passing the subset argument to an lm wrapper
Hello, How would you go about handling the following situation? This is on R 2.12.0 on Ubuntu 32-bit. I have a wrapper function to lm. I want to pass in a subset argument. First, I just thought I'd use "...". ## make example reproducible set.seed(123) df1 <- data.frame(age = rnorm(100, 50, 10), bmi = rnorm(100, 30, sd = 2)) ## create a wrapper using
2010 Feb 16
3
Keyboard
All, I installed R-2.10.1 with Readline=no. Now for some reason R does not recognize some key strokes like the directional arrows. I am not sure if Readline is the problem or not. I have tried .Cofigure with Readline = yes but it doesn't fix the problem nor do I really know if readline is the problem to start with. Has anybody else run into similar problems? Thanks, Steve [[alternative
2010 Oct 05
4
R editor in ubuntu!
Hello R-Users! I am looking for an editor to be able to execute commands into R in Linux ubuntu. Is there any suggestion? Thanks. [[alternative HTML version deleted]]
2010 Jun 16
3
Function argument as string
Hi, Suppose a write a function a_fn<-function(arg1) { return(table(arg1)); } I have a column called AGE. Now I call the function c = a_fn(AGE); When a_fn is called, AGE is received in arg1. My question is, how do I access the actual name of the argument arg1? i.e, inside the function, i need to know that the actual name of arg1 is "AGE" in this case. Thanks in advance,
2011 Mar 23
3
Compare three or more values?
Is there a less cryptic way to compare three or more values? allTheSame<-c("red","red","red","red") notAllTheSame<-c(132,132,132,999) all.identical <- function(vectorToTest){ cIdentical=sum(vectorToTest %in% vectorToTest[1]) return(cIdentical==length(vectorToTest)) } all.identical(allTheSame) all.identical(notAllTheSame) Thanks in
2010 Aug 21
3
problems with merge() - the output has many repeated lines
Hi everyone, I have been merging many big dataframes (about 80000 rows each) and I never had this problem, but now it happened to me and I want to know if someone knows what could be happening. The final dataframe has many rows, an impossible number! I have done edit(dataframe) and I saw that there are many repeated rows (all equal). Thanks for any help, Cec?lia Carmo Universidade de
2006 Jul 14
1
Splitting the left and right hand terms of a formula
Let's say I have the following formula: a.formula <- x ~ y + z I want to extract the left and right-hand sides of the function so that I have two character vectors like the ones you would create using the following assignments: left.hand.side <- "x" right.hand.side <- c("y", "z") One way to do this follows: left.hand.side <-
2005 Dec 19
0
has_one mapping with arbitrary right and left hand side keys
I have two tables: table_1: tab1_id, other_id table_2: id, tab2_id, something_else I would like to specify a has_one mapping from table_1 to table_2 but specifying that the join is based on (table_2.tab2_id = table_1.other_id). I am half way there with: class Table1 < ActiveRecord::Base set_table_name "table_1" set_primary_key "tab1_id" has_one :Table2, :class_name
2013 May 21
0
Arules: getting rules with only one item in the left-hand side
Hello, I am using the package arules to generate association rules. I would like to restrict the rules so that in the left-hand side there's only one particular element, let's call it "potatoe". If I do this: rules <- apriori(dtm.mat, parameter = list(sup = 0.4, conf = 0.9,target="rules"), appearance = list(lhs = c("potatoe"))) I get "potatoe"
1999 Dec 13
1
Superscript or subscript on Left hand side of symbol
Is there a way to get subscripts and superscripts on the left hand side of a symbol? For example, oC or oF (degree Celsius or Fahrenheit) TIA Partha -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the
2010 Apr 15
0
[LLVMdev] How to extract Left Hand side of Instruction
ambika wrote: > Hi, > > Suppose I have llvm Instruction as : > > %9 = load i32* %b, align 4 > > and I want to extract the name of temporary value used here ie 9. > Can any body tell that how can I do that? > I believe it's the getNameStr() method. Note that not all instructions have names (i.e., getNameStr() might give you an empty string). I think the LLVM