Re: [R] linear regression for grouped data

2010-12-28 Thread Dennis Murphy
Hi: There are some advantages to taking a plyr approach to this type of problem. The basic idea is to fit a linear model to each subgroup and save the results in a list, from which you can extract what you want piece by piece. library(plyr) # One of those SAS style data sets... > df <- data.fram

Re: [R] linear regression for grouped data

2010-12-28 Thread Bill.Venables
library(nlme) lmList(y ~ x | factor(ID), myData) This gives a list of fitted model objects. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Entropi ntrp Sent: Wednesday, 29 December 2010 12:24 PM To: r-help@r-project.org Subject:

Re: [R] filling up holes

2010-12-28 Thread Bill.Venables
Dear 'analyst41' (it would be a courtesy to know who you are) Here is a low-level way to do it. First create some dummy data > allDates <- seq(as.Date("2010-01-01"), by = 1, length.out = 50) > client_ID <- sample(LETTERS[1:5], 50, rep = TRUE) > value <- 1:50 > date <- sample(allDates) > clien

Re: [R] linear regression for grouped data

2010-12-28 Thread David Winsemius
On Dec 28, 2010, at 9:23 PM, Entropi ntrp wrote: Hi, I have been examining large data and need to do simple linear regression with the data which is grouped based on the values of a particular attribute. For instance, consider three columns : ID, x, y, and I need to regress x on y for ea

[R] linear regression for grouped data

2010-12-28 Thread Entropi ntrp
Hi, I have been examining large data and need to do simple linear regression with the data which is grouped based on the values of a particular attribute. For instance, consider three columns : ID, x, y, and I need to regress x on y for each distinct value of ID. Specifically, for the set of data

[R] filling up holes

2010-12-28 Thread analys...@hotmail.com
I have a data frame with three columns client ID | date | value For each cilent ID I want to determine Min date and Max date and for any dates in between that are missing I want to insert a row Client ID | date| NA Any help would be appreciated. __

Re: [R] using lapply and split to plot up subsets of a vector

2010-12-28 Thread Phil Spector
The data= argument to plot only makes sense if the first argument is a formula. So if you change the plot command in your function to plot(ln.o2con~lnbm,data=df) you might get what you want. But I would suggest you take a look at the plot produced by library(lattice) xyplot(ln.o2con~l

[R] using lapply and split to plot up subsets of a vector

2010-12-28 Thread karmakiller
Hi, I would like to be able to plot data from each of the sp.id on individual plots. At the moment I can plot all the data on one graph with the following commands but I cannot figure out how to get individual graph for each sp.id. i<- function(df)plot(lnbm,ln.o2con,data=df) j<- lapply(split(one

Re: [R] Problem applying McNemar's - Different values in SPSS and R

2010-12-28 Thread Johannes Huesing
Marc Schwartz [Tue, Dec 28, 2010 at 07:14:49PM CET]: [...] > > An old question of mine: Is there any reason not to use binom.test() > > other than historical reasons? > (I meant "in lieu of the McNemar approximation", sorry if some misunderstanding ensued). > I may be missing the context of yo

Re: [R] levelplot blocks size

2010-12-28 Thread Greg Snow
Here is a basic example: tmp.df <- expand.grid( x= 1:100, y=1:100 ) tmp.df$z <- with(tmp.df, x+2*y) library(lattice) levelplot( z ~ x + y, data=tmp.df ) tx2 <- with(tmp.df, cut(x, seq(0.5, 100.5, 10) ) ) ty2 <- with(tmp.df, cut(y, seq(0.5, 100.5, 20) ) ) tmp.df2 <- aggregate(tmp.df, list( tx2,

Re: [R] batch file output

2010-12-28 Thread Joshua Wiley
On Tue, Dec 28, 2010 at 5:09 AM, Mikkel Grum wrote: > I run a batch file with the following command in Windows XP: > > C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore > C:\users\me\file.out 2>&1 I'm a bit surprised this worked for you...did you customize your build so that Rterm.exe is in \b

Re: [R] another superscript problem

2010-12-28 Thread baptiste auguie
Hi, this seems to work, plot.new() legend("topleft", legend=as.expression(c(bquote(.(txt) == .(obv)*degree), "Von Mises distribution"))) HTH, baptiste On 28 December 2010 20:17, Tyler Dean Rudolph wrote: > legend("topleft", legend=c(bquote(.(txt) == .(obv)*degree), "Von Mises > distribution"

Re: [R] Error in combined for() and if() code

2010-12-28 Thread Nathan Miller
Hi all, I haven't solved the problem of filtering the data, but I have managed to find all the peaks in the data despite their relatively flat nature using peaks() in the IDPmisc package. It works really well for my data and the ability to set a lower threshold for peaks to report is convenient as

Re: [R] another superscript problem

2010-12-28 Thread Tyler Dean Rudolph
Part of the reason I was having difficulty is that I'm trying to add a legend with more than one element: plot(1,1) obv = 5 txt = "Pop mean" # this works legend("topleft", legend=bquote(.(txt) == .(obv)*degree)) # but this doesn't legend("topleft", legend=c(bquote(.(txt) == .(obv)*degree), "Von

Re: [R] Gamma & Lognormal Model

2010-12-28 Thread Louisa
Thank you Michael! -- View this message in context: http://r.789695.n4.nabble.com/Gamma-Lognormal-Model-tp3165408p3166318.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/l

Re: [R] Error in combined for() and if() code

2010-12-28 Thread David Winsemius
On Dec 28, 2010, at 1:08 PM, Nathan Miller wrote: Hello, I am trying to filter a data set like below so that the peaks in the Phase value are more obvious and can be identified by a peak finding function following the useful advise of Carl Witthoft. I have written the following for(i i

Re: [R] Error in combined for() and if() code

2010-12-28 Thread Duncan Murdoch
On 28/12/2010 1:13 PM, Uwe Ligges wrote: On 28.12.2010 19:08, Nathan Miller wrote: Hello, I am trying to filter a data set like below so that the peaks in the Phase value are more obvious and can be identified by a peak finding function following the useful advise of Carl Witthoft. I have wri

Re: [R] Problem applying McNemar's - Different values in SPSS and R

2010-12-28 Thread Marc Schwartz
On Dec 28, 2010, at 11:47 AM, Johannes Huesing wrote: > Marc Schwartz [Tue, Dec 28, 2010 at 06:30:59PM CET]: >> >> On Dec 28, 2010, at 11:05 AM, Manoj Aravind wrote: >> >>> Hi friends, >>> I get different values for McNemar's test in R and SPSS. Which one should i >>> rely on when the p values

Re: [R] Error in combined for() and if() code

2010-12-28 Thread Uwe Ligges
On 28.12.2010 19:08, Nathan Miller wrote: Hello, I am trying to filter a data set like below so that the peaks in the Phase value are more obvious and can be identified by a peak finding function following the useful advise of Carl Witthoft. I have written the following for(i in length(data$P

Re: [R] Error in combined for() and if() code

2010-12-28 Thread Duncan Murdoch
On 28/12/2010 1:08 PM, Nathan Miller wrote: Hello, I am trying to filter a data set like below so that the peaks in the Phase value are more obvious and can be identified by a peak finding function following the useful advise of Carl Witthoft. I have written the following for(i in length(data$P

[R] Error in combined for() and if() code

2010-12-28 Thread Nathan Miller
Hello, I am trying to filter a data set like below so that the peaks in the Phase value are more obvious and can be identified by a peak finding function following the useful advise of Carl Witthoft. I have written the following for(i in length(data$Phase)){ newphase=if(abs(data$Phase[i+1]-data$P

Re: [R] Faster way to do it??...using apply?

2010-12-28 Thread Jonathan P Daily
I don't know if it's any faster, but it is also possible this way: y <- ifelse(x ==1, round(runif(x)), sign(x)) -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when

Re: [R] Faster way to do it??...using apply?

2010-12-28 Thread Henrique Dallazuanna
Try this indeed replace(replace(x, x == 1, sample(0:1, sum(x == 1), rep = TRUE)), x == 2, 1) On Tue, Dec 28, 2010 at 3:14 PM, M.Ribeiro wrote: > > Hi Henrique, > Thanks for the fast answer, > The only problem in your code, which I think I didn't mention in my message > is that I would like one

Re: [R] Problem applying McNemar's - Different values in SPSS and R

2010-12-28 Thread Johannes Huesing
Marc Schwartz [Tue, Dec 28, 2010 at 06:30:59PM CET]: > > On Dec 28, 2010, at 11:05 AM, Manoj Aravind wrote: > > > Hi friends, > > I get different values for McNemar's test in R and SPSS. Which one should i > > rely on when the p values differ. [...] > > > The SPSS test appears to be an exact

Re: [R] Jaccard dissimilarity matrix for PCA

2010-12-28 Thread Flabbergaster
This sounds like something I could use.. I'm kind of new with R, meaning I've having some minor troubles all the time... Say I have a range of binary(0,1) variables X1 to Xn, with missing data for different cases. At the moment my data is a binary indicator matrix; rows representing the i individu

Re: [R] Faster way to do it??...using apply?

2010-12-28 Thread M.Ribeiro
Hi Henrique, Thanks for the fast answer, The only problem in your code, which I think I didn't mention in my message is that I would like one different random sampling procedure for each 1 in my vector The way it was written, it samples only once and replace by every 1: > x = as.matrix(c(1,1,1,1,

Re: [R] Problem applying McNemar's - Different values in SPSS and R

2010-12-28 Thread Marc Schwartz
On Dec 28, 2010, at 11:05 AM, Manoj Aravind wrote: > Hi friends, > I get different values for McNemar's test in R and SPSS. Which one should i > rely on when the p values differ. > I came across this problem when i started learning R and seriously give up > on SPSS or any other proprietary softwa

[R] Problem applying McNemar's - Different values in SPSS and R

2010-12-28 Thread Manoj Aravind
Hi friends, I get different values for McNemar's test in R and SPSS. Which one should i rely on when the p values differ. I came across this problem when i started learning R and seriously give up on SPSS or any other proprietary software. Thank u in advance Output in SPSS follows *Crosstab*

Re: [R] Faster way to do it??...using apply?

2010-12-28 Thread Henrique Dallazuanna
Try this: replace(replace(x, x == 1, sample(0:1, 1)), x == 2, 1) On Tue, Dec 28, 2010 at 2:43 PM, M.Ribeiro wrote: > > Hi, > I have a simple task, but I am looking for a clever and fast way to do it: > > I have a vector x with 0,1 or 2 and I want to create another vector y with > the same lengt

[R] Faster way to do it??...using apply?

2010-12-28 Thread M.Ribeiro
Hi, I have a simple task, but I am looking for a clever and fast way to do it: I have a vector x with 0,1 or 2 and I want to create another vector y with the same length following the rules: If the element in x is equal to 0, the element in y is equal to 0 If the element in x is equal to 2, the

Re: [R] batch file output

2010-12-28 Thread David Winsemius
On Dec 28, 2010, at 10:38 AM, Mikkel Grum wrote: Thanks. The way I run it, I can determine what version of R to run with which script. Don't know how to do that with R CMD BATCH. Seems as though something like this (using absolute path to the instance of R.exe) should work: C:\R\R-2.12.

Re: [R] Jaccard dissimilarity matrix for PCA

2010-12-28 Thread Christian Hennig
jaccard in package prabclus computes a Jaccard matrix for you. By the way, if you want to do hierarchical clustering, it doesn't seem to be a good idea to me to run PCA first. Why not cluster the dissimilarity matrix directly without information loss by PCA? (I should not make too general stat

Re: [R] batch file output

2010-12-28 Thread Mikkel Grum
Thanks. The way I run it, I can determine what version of R to run with which script. Don't know how to do that with R CMD BATCH. Placing options(echo = FALSE) in the infile solves my problem. I got that from the page you linked to. Mikkel --- On Tue, 12/28/10, David Winsemius wrote: > From:

Re: [R] Jaccard dissimilarity matrix for PCA

2010-12-28 Thread David L Lorenz
Jacob, You might have a look at the vegan package. It might compute the Jaccard distance and it might have some other toolsa that you might be interested in. Dave From: Flabbergaster To: r-help@r-project.org Date: 12/28/2010 08:26 AM Subject: [R] Jaccard dissimilarity matrix for PCA Sent b

Re: [R] Jaccard dissimilarity matrix for PCA

2010-12-28 Thread Marcelo Luiz de Laia
Flabbergaster gmail.com> writes: > My problem is, that I don't know how to compute the jaccard dissimilarity > matrix in R? Which package to use, and so on... http://rss.acs.unt.edu/Rdoc/library/arules/html/dissimilarity.html http://cc.oulu.fi/~jarioksa/softhelp/vegan/html/vegdist.html

Re: [R] Reading sas7bdat files into R

2010-12-28 Thread Frank Harrell
Whoops - thought I was replying to google medstats instead of r-help. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Reading-sas7bdat-files-into-R-tp3165608p3166047.html Sent from the R help mailing li

[R] Jaccard dissimilarity matrix for PCA

2010-12-28 Thread Flabbergaster
Hi I have a large dataset, containing a wide range of binary variables. I would like first of all to compute a jaccard matrix, then do a PCA on this matrix, so that I finally can do a hierarchical clustering on the principal components. My problem is, that I don't know how to compute the jaccard

Re: [R] Gamma & Lognormal Model

2010-12-28 Thread Michael Dewey
At 20:08 27/12/2010, Louisa wrote: Dear, I'm very new to R Gui and I have to make an assignment on Gamma Regressions. Surfing on the web doesn't help me very much so i hope this forum may be a step forward. Well since you are so honest about it being homework try Googling for lognormal gamma

Re: [R] batch file output

2010-12-28 Thread Gabor Grothendieck
On Tue, Dec 28, 2010 at 8:09 AM, Mikkel Grum wrote: > I run a batch file with the following command in Windows XP: > > C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore > C:\users\me\file.out 2>&1 > > Is there any way to get only the output of R in file.out, without getting all > the code from

Re: [R] batch file output

2010-12-28 Thread David Winsemius
On Dec 28, 2010, at 8:27 AM, David Winsemius wrote: On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore \file.R> C:\users\me\file.out 2>&1 Is there any way to get only the output of

Re: [R] batch file output

2010-12-28 Thread David Winsemius
On Dec 28, 2010, at 8:09 AM, Mikkel Grum wrote: I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore \file.R> C:\users\me\file.out 2>&1 Is there any way to get only the output of R in file.out, without getting all the code from fil

Re: [R] Link prediction in social network with R

2010-12-28 Thread Gábor Csárdi
Dear Eu, On Wed, Dec 22, 2010 at 12:00 AM, EU JIN LOK wrote: > > Dear R users > > I'm a novice user of R and have absolutely no prior knowledge of social > network analysis, so apologies if my question is trivial. I've spent alot of > time trying to solve this on my own but I really can't so ho

[R] batch file output

2010-12-28 Thread Mikkel Grum
I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.out 2>&1 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Any help greatly appreciated, Mikkel _

Re: [R] Bayesian Belief Networks in R

2010-12-28 Thread Petr Savicky
On Thu, Dec 23, 2010 at 09:12:41AM -0500, Data Analytics Corp. wrote: > Hi, > > Does anyone know of a package for or any implementation of a Bayesian > Belief Network in R? Different types of graphical models in R including Bayesian networks are described in CRAN Task View gR http://cran.at.r-

[R] foreach + dopar: how to check progress of parallel computations?

2010-12-28 Thread Marius Hofert
Dear expeRts, I use foreach to do parallel computations. Is it possible to have some progress output written while the computations are done? In the minimal example below, I just print a number ("n") to check the progress. If you run this example with "%do%" instead of "%dopar%", then the compu