Re: [R] splitting a long dataframe

2012-12-25 Thread David Winsemius
On Dec 25, 2012, at 9:52 AM, Swagath wrote: 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',

Re: [R] path analysis

2012-12-25 Thread Pascal Oettli
First, hello, Second, http://r.789695.n4.nabble.com/path-analysis-td2528558.html#a2530207 Last, Regards Le 26/12/2012 04:11, Ali Mahmoudi a écrit : What's the function of 'path analysis ' to do it with R? Please help me.Thanks. [[alternative HTML version deleted]]

[R] path analysis

2012-12-25 Thread Ali Mahmoudi
What's the function of 'path analysis ' to do it with R? Please help me.Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-p

[R] splitting a long dataframe

2012-12-25 Thread Swagath
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', '4:00:00','0:00:00', '0:30:

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread arun
Hi, You could use library(data.table) x <- data.frame(A=rep(letters,2), B=rnorm(52), C=rnorm(52), D=rnorm(52)) res<- with(x,aggregate(cbind(B,C,D),by=list(A),mean)) colnames(res)[1]<-"A"  x1<-data.table(x) res2<- x1[,list(B=mean(B),C=mean(C),D=mean(D)),by=A]  identical(res,data.frame(res2)) #[1]

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread arun
Hi, Jim's method was found to be faster than data.table() n <- 1  nLevels <- 10  nRows <- 120  Cols <- list(rep(list(sample(nRows)), n))  df <- data.frame(levels = sample(nLevels, nRows, TRUE), Cols)  colnames(df)[-1] <- paste0('col', 1:n)  # convert to matrix for faster processing  df.m <-

Re: [R] for loop not working

2012-12-25 Thread arun
HI Eliza, Try this: set.seed(15) mat1<-matrix(sample(1:2000,1776,replace=TRUE),ncol=444) colnames(mat1)<-paste("Col",1:444,sep="") res1<-lapply(1:37,function(i) mat1[,seq(i,444,37)]) res2<-lapply(1:37,function(i) {a<-mat1[,i:444];a[,c(TRUE,rep(FALSE,36))]}) #your code identical(res1,res2) #[1] TR

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread Wensui Liu
aggregate() is not efficient. try by(). On Tue, Dec 25, 2012 at 11:34 AM, Martin Batholdy wrote: > Hi, > > > I need to aggregate rows of a data.frame by computing the mean for rows > with the same factor-level on one factor-variable; > > here is the sample code: > > > x <- data.frame(rep(letters

Re: [R] pscore.dist problem when running optmatch

2012-12-25 Thread Pascal Oettli
Hello, Did you contact the package maintainer? Mark M. Fredrickson There is also a webpage: https://github.com/markmfredrickson/optmatch Regards, Pascal Le 18/12/2012 21:37, MA a écrit : Hello My optmatch package is loaded and otherwise running fine. I get an error after lcds successfully c

Re: [R] apply with missing values

2012-12-25 Thread David Winsemius
On Dec 24, 2012, at 11:21 AM, jenna wrote: I am trying to get the means of each participants avg saccade amplitude as a function of the group they were in (designated by "shape_"), but there are missing values in the datasetthis is what i tried... with(data055,tapply(AVERAGE_SACCADE_AM

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread jim holtman
According to the way that you have used 'aggregate', you are taking the column means. Couple of suggestions for faster processing: 1. use matrices instead of data.frames ( i converted your example just before using it) 2, use the 'colMeans' I created a 120 x 10 matrix with 10 levels and its

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread Patrick Burns
I'd suggest the 'data.table' package. That is one of the prime uses it was created for. Pat On 25/12/2012 16:34, Martin Batholdy wrote: Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code:

Re: [R] aggregate / collapse big data frame efficiently

2012-12-25 Thread Jeff Newmiller
You might consider using the sqldf package. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. D

Re: [R] Sampling data without having infinite numbers after diong a transformation

2012-12-25 Thread Jeff Newmiller
Perhaps you should read the help file for rnorm more carefully. ?rnorm Keep in mind that the normal probability distribution is a density function, so the smaller the standard deviation is, the greater the magnitude of the density function is. --

Re: [R] for loop not working

2012-12-25 Thread eliza botto
Dear Arun, thank-you very much. i m extremely sorry for spoiling your Christmas. eliza > Date: Tue, 25 Dec 2012 08:51:05 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] for loop not working > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org; kri...@ymail.com > > HI Eliza, > > Try

Re: [R] as.Date to as.POSIXct

2012-12-25 Thread arun
Hi, You should have provided a reproducible example. To convert in general, ?as.POSIXct() A.K. - Original Message - From: Antonio Rodriges To: r-help@r-project.org Cc: Sent: Tuesday, December 25, 2012 7:28 AM Subject: [R] as.Date to as.POSIXct Hello, I have converted some UNIX tim

[R] aggregate / collapse big data frame efficiently

2012-12-25 Thread Martin Batholdy
Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code: x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52)) aggregate(x, list(x[,1]), mean) Now my problem is, that the actual data-s

[R] Sampling data without having infinite numbers after diong a transformation

2012-12-25 Thread Agnes Ayang
Hello R-helpers.. I want to ask about how I can sample data sets without having the infinite numbers coming out. For example, set.seed(1234) a<-rnorm(15,0,1) b<-rnorm(15,0,1) c<-rnorm(15,0,1) d<-rnorm(15,0,36) After come out with the sample, I need to do a transformation (by Hoaglin, 1985) f

Re: [R] R and Matlab

2012-12-25 Thread Suzen, Mehmet
Simplest way is the call a system command, using R CMD. See :http://stackoverflow.com/questions/6695105/call-r-scripts-in-matlab But there are more complicated solutions are proposed: http://www.mathworks.co.uk/matlabcentral/fileexchange/5051 This is uses R-(D)-COM In my opinion most robust int

[R] as.Date to as.POSIXct

2012-12-25 Thread Antonio Rodriges
Hello, I have converted some UNIX time stamps with as.Date as follows dates_unix <- seq( as.Date(convertTimeToString(timeStart)), length = length(data), by="1 mon") and now I would like to convert "dates_unix" from type D

Re: [R] apply with missing values

2012-12-25 Thread Jessica Streicher
A bit of data might be useful. Make a small example and post the data with dput(). On 24.12.2012, at 20:21, jenna wrote: > I am trying to get the means of each participants avg saccade amplitude as a > function of the group they were in (designated by "shape_"), but there are > missing values in

Re: [R] Error message "cs_lu(A) failed: near-singular A (or out of memory)"

2012-12-25 Thread Arne Henningsen
Dear Rui If you impose the homogeneity (adding-up) restrictions, your system becomes singular, because the error terms of the share equations always sum up to zero. Therefore, you can arbitrarily delete one of the share equations and obtain the coefficients that were not directly estimated by the