similar to: Formula in lm inside lapply

Displaying 20 results from an estimated 3000 matches similar to: "Formula in lm inside lapply"

2010 Dec 13
2
Does a formula object have a "left hand side"
Hello, Does anyone know of a function that will determine whether or not a formula object has a left hand side? I.e., can differentiate between y ~ x + z and ~ x + z Perhaps I'm overlooking the obvious... Thanks!
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
2004 Jun 01
1
swapping with data.frame
Hi there, I have some data which are convenient to enter as lists. For example: t1<-list(fname="animal1",testname="hyla",dspkr="left",res1=39.7,res2=15.0) t2<-list(fname="animal1",testname="bufo",dspkr="left",res1=14.4,res2=56.1)
2006 Aug 18
1
multivariate analysis by using lme
Dear R users, I have a data structure as follows: id two res1 res2 c1 c2 inter 1 -0.786093166 1 0 1 2 6 3 -0.308495749 1 0 0 1 2 5 -0.738033048 1 0 0 0 1 7 -0.52176252 1 0
2013 Feb 01
29
cumulative sum by group and under some criteria
Thank you very much for your reply. Your code work well with this example. I modified a little to fit my real data, I got an error massage. Error in split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) : Group length is 0 but data length > 0 On Thu, Jan 31, 2013 at 12:21 PM, arun kirshna [via R] < ml-node+s789695n4657196h87@n4.nabble.com> wrote: > Hi, > Try this: >
2012 Jan 04
1
function in R for my exercise
Hi R helpers! I have a question. I'm trying to create a function for an exercise. Here are the arguments I should include: x and y are numeric z is a name ("plus","minus","multiply","divide") and swap is logical. Here is what the function should do: When z="plus", then x+y is performed and so on for the other z names. It should give a NA
2013 Jun 10
4
Combining CSV data
Hello R community, I am trying to combine two CSV files that look like this: File A Row_ID_CR, Data1, Data2, Data3 1, aa, bb, cc 2, dd, ee, ff File B Row_ID_N, Src_Row_ID, DataN1 1a, 1, This is comment 1 2a, 1, This is comment 2 3a,
2003 Aug 21
4
anova(lme object)
Hi, I use lme to fit models like R> res1 <- lme(y~A+B, data=mydata, random=~1|subject) R> res2 <- lme(y~B+A, data=mydata, random=~1|subject) (only difference between these two models are the sequence in which the indep variables are written in formula) where y is continuous and A, B, and subject are factors. To get ANOVA table I used R> anova(res1) R> anova(res2) and found
2000 Jul 05
1
Tukey.aov with split-plot designs
I am using R 1.1 with Redhat 6.2 and RW 1.001 with Win98 (the upkey doesn't work on my IBM either as has been previously reported by others). The function aov doesn't return either the residuals or the residual degrees of freedom for split-plot designs. If you use the following code from Baron and Li's "Notes on the use of R for psycology experiments and questionnaires"
2011 May 19
3
problem with optim()
Dear R-users, I would like to maximize the function g above which depends on 4 parameters (2 vectors, 1 real number, and 1 matrix) using optim() and BFGS method. Here is my code: # fonction to maximize g=function(x) { x1 = x[1:ncol(X)] x2 = x[(ncol(X)+1)] x3 = matrix(x[(ncol(X)+2):(ncol(X)+1+ncol(X)*ncol(Y))],nrow=ncol(X),ncol=ncol(Y)) x4 = x[(ncol(X)+1+ncol(X)*ncol(Y)+1):length(x)]
2012 Nov 08
5
map two names into one
Thanks. Yes. Your approach can identify: Glaxy ace S 5830 and S 5830 Glaxy ace But you can not identify using same program: Iphone 4S 16 G Iphone 4S 16G How should I solve both in same time. Kind regards,Tammy [[alternative HTML version deleted]]
2013 Feb 17
6
histogram
HI Elisa, You could use ?cut() vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i) paste(i[1],"<x<=",i[2],sep="")))
2012 Nov 10
4
help on date dataset
Hi everybody, I am beginer in R and I need your precious help. I want to create a small function in R as in sas to retrieve date. I have a file with data that import in R. DATE PAYS nb_pays.ILI. 1 24/04/2009 usa 0 2 24/04/2009 usa 0 3 24/04/2009 Mexique 0 4 24/04/2009
2013 Aug 26
4
transform variables
Dear all! I have a data frame composed by 13 columns (year, and 12 months). I want to transform this data base in another like this year month values 1901 1 1901 2 1901 3 ..... 1901 12 1902 1 1902 2 .... 1902 12 Is there a possibility to succeed that in R? Thank you! best regards! CR -- --- Catalin-Constantin ROIBU Lecturer PhD, Forestry engineer Forestry Faculty of Suceava Str.
2007 Nov 12
2
strange `nls' behaviour
I initially thought, this should better be posted to r-devel but alas! no response. so I try it here. sory for the lengthy explanation but it seems unavoidable. to quickly see the problem simply copy the litte example below and execute f(n=5) which crashes. called with n != 5 (and of course n>3 since there are 3 parameters in the model...) everything is as it should be. in detail:
2013 Apr 29
1
how to add new rows in a dataframe?
Hi, dat1<- read.table(text=" id??????????????? t???????????????????? scores 2???????????????? 0??????????????????????? 1.2 2???????????????? 2???????????????????????? 2.3 2???????????????? 3??????????????????????? 3.6 2???????????????? 4??????????????????????? 5.6 2???????????????? 6??????????????????????? 7.8 3???????????????? 0??????????????????????? 1.6 3????????????????
2012 Dec 25
2
splitting a long dataframe
Dear all...Merry Christmas I would like to split a long dataframe. The dataframe looks like this x<-c('0:00:00', '0:30:00', '1:00:00', '1:30:00', '2:00:00', '2:30:00', '3:00:00', '0:00:00', '0:30:00', '1:00:00', '1:30:00', '2:00:00', '2:30:00', '3:00:00', '3:30:00',
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
Hi, Suppose, if I create 15 files in my working directory. set.seed(48) lapply(1:15,function(i) {m1 <- matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)}) ?D <-dir() D1 <- D[order(as.numeric(gsub("\\D+","",D)))] D1 ?res <- t(sapply(D1,function(x) {x1<-
2010 Jul 20
1
p-values pvclust maximum distance measure
Hi, I am new to clustering and was wondering why pvclust using "maximum" as distance measure nearly always results in p-values above 95%. I wrote an example programme which demonstrates this effect. I uploaded a PDF showing the results Here is the code which produces the PDF file: ------------------------------------------------------------------------------------- s <-
2012 Oct 26
3
regression analysis in R
Dear useRs, i have vectors of about 27 descriptors, each having 703 elements. what i want to do is the following 1. i want to do regression analysis of these 27 vectors individually, against a dependent vector, say B, having same number of elements.2. i would like to know best 10 regression results, if i do regression analysis of dependent vector against the random combination of any 4