[R] calling exists function inside another function is not working

2011-05-14 Thread utkarshsinghal
Hi all, I want to define a function such that one of its argument if passed do one thing and if not passed do the second thing. So basically, I have to check whether the argument is passed or not inside the function. I am trying to use 'exists' function to do this. f =

Re: [R] calling exists function inside another function is not working

2011-05-14 Thread utkarshsinghal
Thanks David. Big help, problem solved. Regards, Utkarsh Original Message Subject: Re: [R] calling exists function inside another function is not working From: David Winsemius dwinsem...@comcast.net To: utkarshsinghal utkarsh.sing...@global-analytics.com Cc: r help r

[R] adding more columns in big.matrix object of bigmemory package

2010-12-16 Thread utkarshsinghal
Hi all, Is there any way I can add more columns to an existing filebacked big.matrix object. In general, I want a way to modify an existing big.matrix object, i.e., add rows/columns, rename colnames, etc. I tried the following: library(bigmemory) x =

[R] [Fwd: adding more columns in big.matrix object of bigmemory package]

2010-12-16 Thread utkarshsinghal
Dec 2010 18:29:38 +0530 From: utkarshsinghal [1]utkarsh.sing...@global-analytics.com To: r help [2]r-h...@stat.math.ethz.ch Hi all, Is there any way I can add more columns to an existing filebacked big.matrix object. In general, I want a way to modify an existing big.matrix

Re: [R] FUN argument to return a vector in aggregate function

2010-05-05 Thread utkarshsinghal
A H24.6221 9 4B L28.2254 9 5B M28.8259 9 6B H18.8169 9 On Mon, Nov 23, 2009 at 3:15 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote

[R] FUN argument to return a vector in aggregate function

2009-11-23 Thread utkarshsinghal
Hi All, I am currently doing the following to compute summary statistics of aggregated data: a = aggregate(warpbreaks$breaks, warpbreaks[,-1], mean) b = aggregate(warpbreaks$breaks, warpbreaks[,-1], sum) c = aggregate(warpbreaks$breaks, warpbreaks[,-1], length) ans = cbind(a, b[,3], c[,3])

[R] setting plotting device

2009-09-14 Thread utkarshsinghal
Hi All, I have recently *re*-installed R-2.9.1 in my Linux machine. Since then, I am unable to plot using the usual interactive device. plot(1:10) This plots in a pdf file Rplots.pdf in my working directory. sessionInfo() R version 2.9.1 (2009-06-26) i686-pc-linux-gnu locale:

[R] merging two rpart objects

2009-09-14 Thread utkarshsinghal
Hi All, I am using rpart function to model my data: library(rpart) set.seed(1) x1 = sample(c(a,b),100,T) x2 = runif(100) y = ifelse((x1==a x2=0.5)|(x1==b x20.5), 0, 1) data = data.frame(x1,x2,y) fit = rpart(y~x1+x2) plot(fit); text(fit, use.n=TRUE) Now I want to use variable x1 for the first

[R] dimnames in class by object

2009-08-27 Thread utkarshsinghal
Hi All, d = data.frame(a=1:10,b=1:10) by1 = rep(c(a,b),5) by(d, by1, function(z) z[,,drop=F]) by1: a a b 1 1 1 3 3 3 5 5 5 7 7 7 9 9 9 by1: b a b 2 2 2 4 4 4 6 6 6 8 8 8 10 10 10 by(d, by1, function(z)

Re: [R] bigglm() results different from glm()+Another question

2009-07-09 Thread utkarshsinghal
...@imail.org 801.408.8111 *From:* utkarshsinghal [mailto:utkarsh.sing...@global-analytics.com] *Sent:* Wednesday, July 08, 2009 2:24 AM *To:* Greg Snow *Cc:* Thomas Lumley; r help *Subject:* Re: [R] bigglm() results different from glm()+Another question Hi Greg, Many thanks for your

Re: [R] bigglm() results different from glm()+Another question

2009-07-08 Thread utkarshsinghal
. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 *From:* utkarshsinghal [mailto:utkarsh.sing...@global-analytics.com] *Sent:* Tuesday, July 07, 2009 12:10 AM *To:* Greg Snow *Cc:* Thomas

Re: [R] bigglm() results different from glm()+Another question

2009-07-07 Thread utkarshsinghal
801.408.8111 *From:* utkarshsinghal [mailto:utkarsh.sing...@global-analytics.com] *Sent:* Monday, July 06, 2009 8:58 AM *To:* Thomas Lumley; Greg Snow *Cc:* r help *Subject:* Re: [R] bigglm() results different from glm()+Another question The AIC of the biglm models is highly dependent

Re: [R] bigglm() results different from glm()

2009-07-06 Thread utkarshsinghal
Thank you Mr. Lumley and Mr. Greg. That was helpful. Regards Utkarsh Thomas Lumley wrote: On Fri, 3 Jul 2009, utkarshsinghal wrote: Hi Sir, Thanks for making package available to us. I am facing few problems if you can give some hints: Problem-1: The model summary and residual

Re: [R] bigglm() results different from glm()+Another question

2009-07-06 Thread utkarshsinghal
26647.79 500021647.79 1 11647.79 Regards Utkarsh utkarshsinghal wrote: Thank you Mr. Lumley and Mr. Greg. That was helpful. Regards Utkarsh Thomas Lumley wrote: On Fri, 3 Jul 2009, utkarshsinghal wrote: Hi Sir, Thanks for making package available to us. I am facing

Re: [R] bigglm() results different from glm()

2009-07-03 Thread utkarshsinghal
Hi Sir, Thanks for making package available to us. I am facing few problems if you can give some hints: Problem-1: The model summary and residual deviance matched (in the mail below) but I didn't understand why AIC is still different. AIC(m1) [1] 532965 AIC(m1big_longer) [1] 101442.9

[R] R version-2.9.1 for Linux

2009-06-30 Thread utkarshsinghal
Hi All, I am currently using R version 2.8.1 on linux cent os 4.4 (i386) and want to upgrade to version 2.9.1. It seems to me that version-2.9.1 is it not for my OS. Am I right? Regards Utkarsh [[alternative HTML version deleted]] __

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-19 Thread utkarshsinghal
values, but not necessarily true. On Fri, Jun 19, 2009 at 8:18 AM, Petr PIKAL petr.pi...@precheza.cz mailto:petr.pi...@precheza.cz wrote: Hi utkarshsinghal utkarsh.sing...@global-analytics.com mailto:utkarsh.sing...@global-analytics.com napsal dne 17.06.2009 15:29:34

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-17 Thread utkarshsinghal
, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi Jim, What you are saying is correct. Although, my computer might not have same speed and I am getting the following for 10M entries: user system elapsed 0.559 0.038 0.607 Moreover, in the case of character

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread utkarshsinghal
Hi All, There are several replies to the question below, but I think there must exist a better way of doing so. I just want to check whether all the elements of a vector are same. My vector has one million elements and it is highly likely that there are distinct elements in the first few

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread utkarshsinghal
] == x))) [1] FALSE user system elapsed 0.180.000.19 This was for 10M entries. On Tue, Jun 16, 2009 at 7:42 AM, utkarshsinghal utkarsh.sing...@global-analytics.com mailto:utkarsh.sing...@global-analytics.com wrote: Hi All, There are several replies

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread utkarshsinghal
(1,1000)) # 10,000,000 system.time(print(all(x[1] == x))) [1] FALSE user system elapsed 0.180.000.19 This was for 10M entries. On Tue, Jun 16, 2009 at 7:42 AM, utkarshsinghal utkarsh.sing...@global-analytics.com mailto:utkarsh.sing...@global-analytics.com

[R] glm binomial logit - removing extra computations

2009-06-12 Thread utkarshsinghal
Hi all, I am using glm function with family binomial(logit) to fit logistic regression model. My data is very big and the algorithm is such that it has to run glm function hundreds of times. Now *I need only the **estimates of the coefficients and std. error in my output, *but apparently

[R] Defining functions - an interesting problem

2009-05-27 Thread utkarshsinghal
I define the following function: (Please don't wonder about the use of this function, this is just a simplified version of my actual function. And please don't spend your time in finding an alternate way of doing the same as the following does not exactly represent my function. I am only

Re: [R] Defining functions - an interesting problem

2009-05-27 Thread utkarshsinghal
Yeah, seems so obvious now. What a blunder, poor me. Perfect explanation. Thanks Thomas Lumley wrote: On Wed, 27 May 2009, utkarshsinghal wrote: I define the following function: (Please don't wonder about the use of this function, this is just a simplified version of my actual function

[R] intermediate iterations of stepwise regression

2009-05-18 Thread utkarshsinghal
Hi all, I am performing a stepwise regression by running the step function on an lm object. Now I want to save the intermediate iterations. I know the argument trace=T will print it on the console, but I rather want to assign it to some R object or may be output it in a CSV or text file.

Re: [R] intermediate iterations of stepwise regression

2009-05-18 Thread utkarshsinghal
can have all the intermediate iterations also as R objects. Thanks in advance. Gabor Grothendieck wrote: Try this: out - capture.output(example(step)) On Mon, May 18, 2009 at 9:11 AM, utkarshsinghal utkarsh.sing...@global-analytics.com wrote: Hi all, I am performing a stepwise

[R] extracting residuals from glm object

2009-05-12 Thread utkarshsinghal
Hi All, Can anybody explain why the following three ways of extracting residuals from a glm object are giving me different outputs: idv = runif(1000,0,1) dv = rbinom(1000,1,0.5) d = data.frame(idv,dv) fit = glm(dv~idv, data=d, family=binomial) head(residuals(fit)) 1 2

[R] Age Calculation in years, months and days

2009-05-06 Thread utkarshsinghal
Hi All, Is there any way in R to calculate the difference between two dates in years, months days. date1 = as.Date(1993-11-23) date2 = as.Date(2009-04-15) I want my output to be:15 years 4 months 27 days Any hint would be helpful. Regards Utkarsh [[alternative HTML

[R] Splitting a vector into equal groups

2009-05-04 Thread utkarshsinghal
Hi All, I have vector of length 52, say, x=sample(30,52,replace=T). I want to sort x and split into five *nearly equal groups*. Note that the observations are repeated in x so in case of a tie I want both the observations to fall in same group. This seems a very common task to do, but still I

[R] problem in as.date

2009-04-30 Thread utkarshsinghal
I never understood that why is the value returned by as.date function in the library(survival) never matches with the description given in the help file: Following is the extract from ?as.date Description: Converts any of the following character forms to a Julian date: 8/31/56, 8-31-1956,

[R] how to access file backed big matrix (package bigmemory)

2009-04-20 Thread utkarshsinghal
__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

[R] splitting vector into equal sets

2009-04-16 Thread utkarshsinghal
Hi R, I have explored R archives a lot but couldn't find an efficient way of doing the following: I want to split a vector into sets of equal sizes. Is there any inbuilt function of doing so with the option of specifying how to treat the remaining observations. For example: suppose I want

Re: [R] Odp: splitting vector into equal sets

2009-04-16 Thread utkarshsinghal
__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.