[R] as.formula doesn't want to take a phrase

2011-04-18 Thread Dimitri Liakhovitski
Hello! I am trying to create a formula object using as.formula. But it's not working: examplephraze-for.my.example myformula-as.formula(paste(examplephraze,~group, sum, data=mydata,sep=)) What's the problem? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] using aggregate when variable names contain spaces

2011-04-18 Thread Dimitri Liakhovitski
That's great thanks a lot, David! On Mon, Apr 18, 2011 at 3:47 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 18, 2011, at 3:40 PM, Dimitri Liakhovitski wrote: That's helpful, thanks! Unfortunately, I cannot refer to all of my variables to the left of tilda one by one - I have

Re: [R] as.formula doesn't want to take a phrase

2011-04-18 Thread Dimitri Liakhovitski
Makes sense, Marc - thanks a lot! On Mon, Apr 18, 2011 at 3:54 PM, Marc Schwartz marc_schwa...@me.com wrote: On Apr 18, 2011, at 2:44 PM, Dimitri Liakhovitski wrote: Hello! I am trying to create a formula object using as.formula. But it's not working: examplephraze-for.my.example

[R] lookup not working properly

2011-04-12 Thread Dimitri Liakhovitski
) myref-data.frame(a=a, b=b) (myref) # my data: c-c(rep(ba ba,3),rep(ca ca,3),rep(da da,3),rep(lake lake, a,3), rep(lake lake, b,3),rep(lake of,3),rep(lama ca, a,3),rep(lama ca ,b,3),rep(ma ma,3)) temp-data.frame(c=c) (temp) ### Matching: temp$b-myref[temp$c,b] (temp) -- Dimitri Liakhovitski

Re: [R] lookup not working properly

2011-04-12 Thread Dimitri Liakhovitski
),rep(lama ca ,b,3),rep(ma ma,3)), stringsAsFactors=FALSE) newdata - merge(myref, temp, by.x=a, by.y=c, all.x=FALSE, all.y=TRUE) Sarah On Tue, Apr 12, 2011 at 11:17 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! Below is my exmample. myref is my reference data frame

[R] Assigning a larger number of levels to a factor that has fewer levels

2011-04-07 Thread Dimitri Liakhovitski
) to have the same number of entries as table(small.frame$myfactor) but with 5 zeros in it: A B C D E F G J I J 1 0 1 0 1 0 1 0 1 0 Thank you very much for your suggestions! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing

Re: [R] Assigning a larger number of levels to a factor that has fewer levels

2011-04-07 Thread Dimitri Liakhovitski
On Thu, Apr 7, 2011 at 11:47 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have larger and a smaller data frame with 1 factor in each - it's the same factor: large.frame-data.frame(myfactor=LETTERS[1:10]) small.frame-data.frame(myfactor=LETTERS[c(9,7,5,3,1)]) levels

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-04-06 Thread Dimitri Liakhovitski
, Henrique Dallazuanna www...@gmail.com wrote: Try this: library(zoo) wk - as.numeric(format(myframe$dates, '%W')) is.na(wk) - wk == 0 aggregate(value ~ group + na.locf(wk), myframe, FUN = sum) On Wed, Mar 30, 2011 at 4:35 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Henrique

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-04-06 Thread Dimitri Liakhovitski
Sorry - never mind. It turns out I did not load the zoo package. That was the reason. On Wed, Apr 6, 2011 at 12:14 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Guys, sorry to bother you again: I am running everything as before (see code below - before the line with a lot

Re: [R] merging 2 frames while keeping all the entries from the reference frame

2011-04-05 Thread Dimitri Liakhovitski
new.data-rbind(new.data,temp) } Dimitri On Mon, Apr 4, 2011 at 3:07 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this:  merge(mydata, cbind(reference, group = rep(unique(mydata$group), each = nrow(reference))), all = TRUE) On Mon, Apr 4, 2011 at 2:24 PM, Dimitri Liakhovitski

[R] merging 2 frames while keeping all the entries from the reference frame

2011-04-04 Thread Dimitri Liakhovitski
(new.data$group,new.data$mydate),] (new.data) # my new.data contains only 7 rows in Group 1 and 4 rows in Group 2 -- Dimitri Liakhovitski Ninah Consulting __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] merging 2 frames while keeping all the entries from the reference frame

2011-04-04 Thread Dimitri Liakhovitski
Group2 2.880393978 On Mon, Apr 4, 2011 at 1:09 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have my data frame mydata (below) and data frame reference - that contains all the dates I would like to be present in the final data frame. I am trying to merge them so

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-31 Thread Dimitri Liakhovitski
, as in sum.by.week - function(ff) {  by.day - split(ff$value,get.week.flag(ff$dates))  lapply(by.day,sum) } by.grp - split(myframe,myframe$group) lapply(by.grp,sum.by.week) Martyn -Original Message- From: Dimitri Liakhovitski [mailto:dimitri.liakhovit...@gmail.com] Sent: 30

Re: [R] Not all rows are being read-in

2011-03-30 Thread Dimitri Liakhovitski
Philipp, you are a savior! That's exactly what has been happening - and it was driving me crazy. quote= fixed things. Thank you very much! Dimitri On Wed, Mar 30, 2011 at 5:01 AM, Philipp Pagel p.pa...@wzw.tum.de wrote: On Tue, Mar 29, 2011 at 06:58:59PM -0400, Dimitri Liakhovitski wrote: I

[R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
(removed.group1,removed.group2);length(to.remove) to.remove-to.remove[order(to.remove)] myframe-myframe[-to.remove,] (myframe) -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

[R] optim and optimize are not finding the right parameter

2011-03-30 Thread Dimitri Liakhovitski
the same - wrong - result with optimize: opt2 - optimize(f=my.function,interval=c(0,0.1)) test3-my.function(opt2$minimum) What am I doing wrong? Thanks a lot for your recomendations! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-30 Thread Dimitri Liakhovitski
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: 30 March 2011 15:23 To: r-help Subject: [R] summing values by week - based on daily dates - but with somedates missing Dear everybody, I have the following

Re: [R] optim and optimize are not finding the right parameter

2011-03-30 Thread Dimitri Liakhovitski
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Wednesday, March 30, 2011 12:45 PM To: r-help Subject: [R] optim and optimize are not finding the right parameter Dear all, I have a function that predicts

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
~ group + format(dates, %Y.%W), myframe, FUN = sum) On Wed, Mar 30, 2011 at 11:23 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Dear everybody, I have the following challenge. I have a data set with 2 subgroups, dates (days), and corresponding values (see example code below

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
(format(myframe$dates, '%W')) is.na(wk) - wk == 0 aggregate(value ~ group + na.locf(wk), myframe, FUN = sum) On Wed, Mar 30, 2011 at 4:35 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Henrique, this is great, thank you! It's almost what I was looking for! Only one small thing

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
(myframe$dates, %Y.%W)) is.na(wk) - wk %% 1 == 0 solution-aggregate(value ~ group + na.locf(wk), myframe, FUN = sum) On Wed, Mar 30, 2011 at 6:10 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Yes, zoo! That's what I forgot. It's great. Henrique, thanks a lot! One question

[R] Not all rows are being read-in

2011-03-29 Thread Dimitri Liakhovitski
?). Any advice - any chance for me to read in the whole file? Thank you very much! -- Dimitri Liakhovitski Ninah Consulting __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

[R] nesting same set of values with each level of another set of values

2011-03-11 Thread Dimitri Liakhovitski
]]-data.frame(unit=rep(units[i],length(mydates)),Weeks=mydates) } myframe-do.call(rbind,myframe) str(myframe) head(myframe,110) -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] nesting same set of values with each level of another set of values

2011-03-11 Thread Dimitri Liakhovitski
Thanks a lot, David! Exactly what I was looking for! Dimitri On Fri, Mar 11, 2011 at 1:46 PM, David Winsemius dwinsem...@comcast.net wrote: On Mar 11, 2011, at 1:26 PM, Dimitri Liakhovitski wrote: Hello! The code below works and does what I need it to do. However, I think the way I create

[R] Vector of weekly dates starting with a given date

2011-03-09 Thread Dimitri Liakhovitski
for the pointer! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] Vector of weekly dates starting with a given date

2011-03-09 Thread Dimitri Liakhovitski
I realize I can do something like this: date-20081229 mydates-as.Date(as.character(date),%Y%m%d) for(i in 1:52){ # mydates-c(mydates,mydates[length(mydates)]+7) } I just thought maybe there is a more elegant way... Thank you! Dimitri On Wed, Mar 9, 2011 at 4:04 PM, Dimitri Liakhovitski

Re: [R] More appropriate optimization routine?

2011-03-08 Thread Dimitri Liakhovitski
to avoid. Thanks again! Dimitri On Mon, Mar 7, 2011 at 9:32 PM, Ben Bolker bbol...@gmail.com wrote: Dimitri Liakhovitski dimitri.liakhovitski at gmail.com writes: I have 2 variables - predictor pred and response variable DV: pred-c(439635.053, 222925.718, 668434.755, 194242.330, 5786.321, 115537.344

[R] More appropriate optimization routine?

2011-03-07 Thread Dimitri Liakhovitski
), boundary.enforcement=2) -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] part or semi-partial correlation in R

2011-02-27 Thread Dimitri Liakhovitski
-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] preventing repeat in paste

2011-02-26 Thread Dimitri Liakhovitski
This is great, thanks a lot, Gabor! On Fri, Feb 25, 2011 at 6:18 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Feb 25, 2011 at 5:21 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! s-start; e-end middle-as.character(c(1,2,3)) I would like to get

[R] preventing repeat in paste

2011-02-25 Thread Dimitri Liakhovitski
Hello! s-start; e-end middle-as.character(c(1,2,3)) I would like to get the following result: start 123 end or start 1 2 3 end or start 1,2,3 end How can I avoide this (undesired) result: paste(s,middle,e,sep= ) Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] preventing repeat in paste

2011-02-25 Thread Dimitri Liakhovitski
. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

[R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Dimitri Liakhovitski
the code: result=e/a I understand that I could write those 3 scripts as 3 functions and source them from another script. But maybe there is a way of having them run one by one as such? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R

Re: [R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Dimitri Liakhovitski
this to see if it worked?  :) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Thursday, February 24, 2011 10:22 AM To: r-help Subject: [R] Running code sequentially from separate scripts

Re: [R] create dummy variables by for loop

2011-02-24 Thread Dimitri Liakhovitski
/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. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list

Re: [R] Variable length datafile import problem

2011-02-15 Thread Dimitri Liakhovitski
-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. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] all.equal: subscript out of bounds

2011-02-15 Thread Dimitri Liakhovitski
. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

[R] Problems with Ctrl+r on Dell machines

2011-02-14 Thread Dimitri Liakhovitski
to higlight the code again and run it again. I also have R on an HP laptop and I never have the same problem on it. Has anyone encountered thisproblem on Dell machines? Any advice on how to fix it? Thank you very much! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

[R] Question about the covariate Z in rhierMnlRwMixture (bayesm)

2011-02-10 Thread Dimitri Liakhovitski
. Do those dummy variables have to be centered? Help file for rhierMnlRwMixture says: Z should not include an intercept and is centered for ease of interpretation. But I'd thought I'd check just in case: does it mean that it's OK if variables in Z are not centered? Thank you very much! -- Dimitri

[R] Chi square test of proprotions in 2 groups of different sizes

2011-02-10 Thread Dimitri Liakhovitski
Hello! Very sorry for a probably very simple question - I looked but did not find an answer in the archives. I have a table counts (below) that shows counts by Option within each of my 2 groups. However, my groups have different sizes (N1=255 and N2=68). Table prop shows the resulting proportions

[R] Question about checkTmvArgs function in rtmvnorm (package tmvtnorm)

2011-02-07 Thread Dimitri Liakhovitski
, lower, upper, ...) } else if (algorithm == gibbsR) { retval - rtmvnorm.gibbs(n, mean, sigma, lower, upper, ...) } return(retval) } -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r

Re: [R] Question about checkTmvArgs function in rtmvnorm (package tmvtnorm)

2011-02-07 Thread Dimitri Liakhovitski
I found a reason why I was getting the error that my var-covar matrix was not symmetric: because my column names and row names were different! Dimitri On Mon, Feb 7, 2011 at 12:39 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I was wondering if it's possible to see

[R] under what conditions would rtmvnorm (from package tmvtnorm) produce all NaNs

2011-02-07 Thread Dimitri Liakhovitski
really needs to see the data to answer my question, I'll be happy to provide btilde and my bounds. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] rgenoud for multiple chips: does a more recent special version of snow exist?

2011-02-03 Thread Dimitri Liakhovitski
way of running rgenoud on several chips simultaneously? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] rgenoud for multiple chips: does a more recent special version of snow exist?

2011-02-03 Thread Dimitri Liakhovitski
Just a small correction: the package snow does install. But once I try to load it: library(snow), I get an error: Error: package 'snow' was built before R 2.10.0: please re-install it Dimitri On Thu, Feb 3, 2011 at 3:57 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Dear everyone

Re: [R] Regularization of a matrix that has some tiny negative eigenvalues

2011-01-31 Thread Dimitri Liakhovitski
at 1:32 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Dear all: In what I am doing I sometimes get a (Hessian) matrix that has a couple of tiny negative eigenvalues (e.g. -6 * 10^-17). So, I can't run a Cholesky decomp on it - but I need to. Is there an established way

[R] Regularization of a matrix that has some tiny negative eigenvalues

2011-01-28 Thread Dimitri Liakhovitski
Dear all: In what I am doing I sometimes get a (Hessian) matrix that has a couple of tiny negative eigenvalues (e.g. -6 * 10^-17). So, I can't run a Cholesky decomp on it - but I need to. Is there an established way to regularize my (Hessian) matrix (e.g., via some transformation) that would

[R] setting up a genoud run

2011-01-13 Thread Dimitri Liakhovitski
, hard.generation.limit=TRUE,starting.values=rep(500,npredictors), Domains=matrix(rep(c(0,1000),npredictors),ncol=2,byrow=T),boundary.enforcement=2) -- Dimitri Liakhovitski Ninah Consulting __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] setting up a genoud run

2011-01-13 Thread Dimitri Liakhovitski
gradient is too large? Thanks a lot for explaining! Dimitri On Thu, Jan 13, 2011 at 11:10 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello - and sorry for a possibly stupid question, I'm just starting to learn rgenoud. I am defining a function with 5 parameters (p1, p2

[R] Merging data frames one of which is NULL

2010-11-09 Thread Dimitri Liakhovitski
! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

[R] How to program an error into an if-then statement

2010-11-09 Thread Dimitri Liakhovitski
) : cannot open the connection Question: I'd like to program an if-then statement in my code that says something like this: myfile-read.csv(myfilename) if cannot open the connection - then do X What statement should I use under if? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting

Re: [R] Merging data frames one of which is NULL

2010-11-09 Thread Dimitri Liakhovitski
- data.frame(a = 1, b = 2, c = i)  if (i == 1) {    y - x  } else {    y - merge(x, y, all.x = TRUE, all.y = TRUE)  } } On Tue, Nov 9, 2010 at 8:42 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I am running a loop. The result of each run of the loop is a data frame

Re: [R] How to program an error into an if-then statement

2010-11-09 Thread Dimitri Liakhovitski
Thanks a lot, everybody- it's very helpful! On Tue, Nov 9, 2010 at 12:20 PM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Dimitri Liakhovitski Sent: Tuesday, November 09

[R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Dimitri Liakhovitski
! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] Merging data frames one of which is NULL

2010-11-09 Thread Dimitri Liakhovitski
                                        spec...@stat.berkeley.edu On Tue, 9 Nov 2010, Dimitri Liakhovitski wrote: Hello! I am running a loop. The result of each run of the loop is a data frame. I am merging all the data frames. For exampe: The dataframe from run 1: x-data.frame(a=1,b=2,c=3

Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Dimitri Liakhovitski
On Tue, Nov 9, 2010 at 12:30 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this: gsub(\\.(\\d{1}$), .0\\1, x) On Tue, Nov 9, 2010 at 3:28 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello again! Sorry, if it's a simple question - I am very bad in working

[R] lookup in R - possible to avoid loops?

2010-11-08 Thread Dimitri Liakhovitski
it for hundreds and hundreds of names in 100 of huge files (tens of thousands of rows in each). Any way to speed it up? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] lookup in R - possible to avoid loops?

2010-11-08 Thread Dimitri Liakhovitski
the lookup table, and my.df$category = categories[my.df$names] creates the category column.                                           - Phil On Mon, 8 Nov 2010, Dimitri Liakhovitski wrote: Hello! Hope there is a nifty way to speed up my code by avoiding loops. My task is simple - analogous

[R] avoiding too many loops - reshaping data

2010-11-03 Thread Dimitri Liakhovitski
it. Thanks a lot for your hints! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Dimitri Liakhovitski
this:  xtabs(value ~ city + brand, mydf) On Wed, Nov 3, 2010 at 6:23 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have a data frame like this one: mydf-data.frame(city=c(a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,b),  brand=c(x,x,y,y,z,z,z,z,x,x,x,y,y,y,z,z),  value=c

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Dimitri Liakhovitski
In reshape2 this does the job: dcast(mydf,city~brand,sum) On Wed, Nov 3, 2010 at 4:37 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Thanks a lot! Yes - I just found the reshape package too - and guess what, my math was wrong! reshape2 seems like the more up-to-date

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Dimitri Liakhovitski
Want to thank everyone once more for pointing in reshape direction. Saved me about 16 hours of looping! Dimitri On Wed, Nov 3, 2010 at 4:38 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: In reshape2 this does the job: dcast(mydf,city~brand,sum) On Wed, Nov 3, 2010 at 4:37 PM

[R] biding rows while merging at the same time

2010-11-03 Thread Dimitri Liakhovitski
a b c d loc 1 1/1/2010 1 11 111 NA loc 2 1/1/2010 2 12 112 NA loc 3 1/1/2010 3 13 113 NA loc 1 2/1/2010 3 NA 114 1 loc 2 2/1/2010 5 NA 115 11 loc 3 2/1/2010 6 NA 116 111 Thanks a lot for your suggestions! -- Dimitri Liakhovitski Ninah

Re: [R] biding rows while merging at the same time

2010-11-03 Thread Dimitri Liakhovitski
Never mind - I found it in reshape package: rbind.fill I wonder if it's still in reshape2. Dimitri On Wed, Nov 3, 2010 at 5:34 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have 2 data frames like this (well, actually, I have 200 of them): df1-data.frame(location=c

Re: [R] avoiding too many loops - reshaping data

2010-11-03 Thread Dimitri Liakhovitski
On Wed, Nov 3, 2010 at 4:32 PM, Henrique Dallazuanna www...@gmail.com wrote: Try this:  xtabs(value ~ city + brand, mydf) On Wed, Nov 3, 2010 at 6:23 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have a data frame like this one: mydf-data.frame(city=c

[R] stacking effectively - without loops

2010-11-02 Thread Dimitri Liakhovitski
Hello! I have 2 vectors: x-letters[1:5] y-1:3 Is there a way - without loops - to create a data frame such that we repeat the whole y within each level of x so that it looks like this: a 1 a 2 a 3 b 1 b 2 b 3 c 1 c 2 c 3 etc? Thank you! -- Dimitri Liakhovitski Ninah Consulting

Re: [R] stacking effectively - without loops

2010-11-02 Thread Dimitri Liakhovitski
Never mind - found it: expand.grid(y,x) On Tue, Nov 2, 2010 at 4:57 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I have 2 vectors: x-letters[1:5] y-1:3 Is there a way - without loops - to create a data frame such that we repeat the whole y within each level of x

Re: [R] summary.lm for post-hoc tests

2010-10-30 Thread Dimitri Liakhovitski
-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] summary.lm as a post-hoc test?

2010-10-30 Thread Dimitri Liakhovitski
PM, Dimitri Liakhovitski wrote: You are asking a statistics question, not an R question. R-list people never react to such posts. Or they give you a nasty reply of the type: Do you homework first, and then ask questions here. Good point. I thought it was an R question because it was about

[R] help pages do not open

2010-10-29 Thread Dimitri Liakhovitski
and installed R12 instead. But I am getting the same error. Any advice? -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] help pages do not open

2010-10-29 Thread Dimitri Liakhovitski
, Oct 29, 2010 at 9:22 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I have just installed R-2.12 I have Windows 7, 64-bit verison. I currently have IE as my default browser. The internet connection is very good. Whenever I try to run a help command (?lm, for example), I get

Re: [R] help pages do not open

2010-10-29 Thread Dimitri Liakhovitski
Problem solved. It turned out I had to reset my IE as my default browser for all extentions (like .html). Now, R help is working! Dimitri On Fri, Oct 29, 2010 at 4:20 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I tried one more thing - I uninstalled R again, and this time

[R] R version 2-12.0 - running as 32 or as 64 bit?

2010-10-29 Thread Dimitri Liakhovitski
Question: I installed R verison 2-12.0 on my Windows 7 (64 bit) PC. When I was installing it, it did not ask me anything about 32 vs. 64 bit. So, if I run R now - is it running as a 32-bit or a 64-bit? thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] R version 2-12.0 - running as 32 or as 64 bit?

2010-10-29 Thread Dimitri Liakhovitski
wrote: G'day Dimitri, On Fri, 29 Oct 2010 16:45:00 -0400 Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Question: I installed R verison 2-12.0 on my Windows 7 (64 bit) PC. When I was installing it, it did not ask me anything about 32 vs. 64 bit. So, if I run R now - is it running

[R] correctness of a formula in lme (from package nlme)

2010-10-27 Thread Dimitri Liakhovitski
| Subject) summary(fm1) ranef(fm1) When I run it like this I do get fixed effects in summary(my.model) and I do get random coefficients by group (in my example - by Subject) in ranef(fm1). I just want to make sure it's what I want. Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

[R] mixed effects regression with weights using lme (lme4)

2010-10-26 Thread Dimitri Liakhovitski
Hello! I am sorry if it's a naive/wrong question. But can one run a regression with weights using lme? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] mixed effects regression with weights using lme (lme4)

2010-10-26 Thread Dimitri Liakhovitski
are specified the same way as in the lm function, and refers you to ?lm for details. HTH, Ista On Tue, Oct 26, 2010 at 11:21 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I am sorry if it's a naive/wrong question. But can one run a regression with weights using lme

[R] lme vs. lmer results

2010-10-26 Thread Dimitri Liakhovitski
appreciate a clarification! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] lme vs. lmer results

2010-10-26 Thread Dimitri Liakhovitski
...@stat.wisc.edu wrote: On Tue, Oct 26, 2010 at 12:27 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello, and sorry for asking a question without the data - hope it can still be answered: I've run two things on the same data: # Using lme: mix.lme - lme(DV ~a+b+c+d+e+f+h+i

[R] finding the year of a date

2010-10-25 Thread Dimitri Liakhovitski
I know that I can use as.yearmon in the package zoo to find the year and the month of a date. I can use as. yearqtr to find the year and the quarter. But how can one find just the year of a date? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] finding the year of a date

2010-10-25 Thread Dimitri Liakhovitski
Thank you very much! Dimitri On Mon, Oct 25, 2010 at 12:46 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Mon, Oct 25, 2010 at 12:38 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I know that I can use as.yearmon in the package zoo to find the year and the month

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
Grothendieck ggrothendi...@gmail.com wrote: On Fri, Oct 22, 2010 at 9:45 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Gabor, thanks a lot - sqldf might be a solution. However, do you know if sqldf can also read in .txt files (with different delimiters)? The data I am dealing

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
Grothendieck ggrothendi...@gmail.com wrote: On Sat, Oct 23, 2010 at 9:20 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: This is very helpful, Gabor. I've run the code to figure out the end of the line and here is what I am seeing at the end of each line: \r\n So, I specified like

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
:44 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Oh, I understand - I did not realize it's reading in the whole file. So, is there any way to make it read it in only once and the spit into R just one piece (e.g., 1 million rows), write a regular file out (e.g., a txt using

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
O, wait a sec - does it mean I can't feed my objects into sql commands? On Sat, Oct 23, 2010 at 10:07 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I just tried it: for(i in 11:16){ #i-11  start-Sys.time()  print(start)  flush.console()  filename-paste(skipped millions- ,i

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
-bit Windows 7 PC with 6 GB RAM (I assume only 4 can be used?)) I got this error: Error: cannot allocate vector of size 42.0 Mb So, I guess On Sat, Oct 23, 2010 at 10:19 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, Oct 23, 2010 at 10:07 AM, Dimitri Liakhovitski dimitri.liakhovit

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
,.txt,sep=) write.table(DF,sep=\t,header=FALSE,file=filename) count-count+1 } close(con) On Sat, Oct 23, 2010 at 10:19 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sat, Oct 23, 2010 at 10:07 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I just tried it: for(i

Re: [R] How long does skipping in read.table take

2010-10-23 Thread Dimitri Liakhovitski
Also am running the same code on my powerful home PC. It's been running for 25 minutes already, and still has not printed the first end time (does it mean it's still trying to read in DF for the first time)? On Sat, Oct 23, 2010 at 10:52 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com

[R] lm looking for weights outside of the user-defined function

2010-10-22 Thread Dimitri Liakhovitski
defined inside the function? Thank you very much! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ 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

Re: [R] Odp: importing csv gets me all 16,000 columns with NA

2010-10-22 Thread Dimitri Liakhovitski
://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. -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r

Re: [R] lm looking for weights outside of the user-defined function

2010-10-22 Thread Dimitri Liakhovitski
. Look in the data frame 2. Look in the environment of the user-defined function 3. Look outside. Dimitri On Fri, Oct 22, 2010 at 9:15 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 22, 2010, at 9:01 AM, Dimitri Liakhovitski wrote: Dear R'ers, I am fighting with a problem

Re: [R] lm looking for weights outside of the user-defined function

2010-10-22 Thread Dimitri Liakhovitski
AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 22, 2010, at 9:01 AM, Dimitri Liakhovitski wrote: Dear R'ers, I am fighting with a problem that is driving me crazy. I use lm in my user-defined function, but it seems to be looking for weights outside of my function's environment

[R] How long does skipping in read.table take

2010-10-22 Thread Dimitri Liakhovitski
(e.g., 1 milllion) using nrows= and skip. I was able to read in the first 1,000,000 rows no problem in 45 sec. But then I tried to skip 16,999,999 rows and then read in things. Then R crashed. Should I try again - or is it too many rows to skip for R? Thank you! -- Dimitri Liakhovitski Ninah

Re: [R] How long does skipping in read.table take

2010-10-22 Thread Dimitri Liakhovitski
a lot! Dimitri On Fri, Oct 22, 2010 at 6:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Oct 22, 2010 at 5:17 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: I know I could figure it out empirically - but maybe based on your experience you can tell me if it's doable

[R] simple function can't find weights

2010-10-20 Thread Dimitri Liakhovitski
(summary(regr.f)$adj.r.squared,3) results[nrow(results)+1,1]-round(dwtest(regr.f)$statistic,2) row.names(results)[(nrow(results)-2):nrow(results)]-c(R.Sqr, Adj.R.Sqr,DW) write.csv(results,file=file.name) return(results) } -- Dimitri Liakhovitski Ninah Consulting

[R] Initiating graphics recording in RGraphics window via a script

2010-10-20 Thread Dimitri Liakhovitski
, and then run my several graphs, e.g.: for(i in 10:12){ plot(1:i) } Is there any way to avoid doing it manually initiate the graphics recording in the RGraphics window in the script itself? Thanks a lot for your help! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com

Re: [R] Initiating graphics recording in RGraphics window via a script

2010-10-20 Thread Dimitri Liakhovitski
, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

[R] rounding up (always)

2010-10-20 Thread Dimitri Liakhovitski
) floor(signif(x,3)+10) But it's very manual - because in the problem I am facing the numbers sometimes have to be rounded to a 1000, sometimes to a 100, etc. Thanks a lot for any hints! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R

Re: [R] rounding up (always)

2010-10-20 Thread Dimitri Liakhovitski
...@wlandres.net wrote: On 20-Oct-10 21:27:46, Duncan Murdoch wrote: On 20/10/2010 5:16 PM, Dimitri Liakhovitski wrote: Hello! I am trying to round the number always up - i.e., whatever the positive number is, I would like it to round it to the closest 10 that is higher than this number, the closest 100

Re: [R] rounding up (always)

2010-10-20 Thread Dimitri Liakhovitski
Thanks a lot, David - I'll try this solution. Dimitri On Wed, Oct 20, 2010 at 9:54 PM, David Winsemius dwinsem...@comcast.net wrote: On Oct 20, 2010, at 8:38 PM, Dimitri Liakhovitski wrote: Thank you for your help, everyone. Actually, I am building a lot of graphs (in a loop) but the values

<    1   2   3   4   5   6   7   >