Re: [R] Data extraction and assembly from a data frame

2014-06-20 Thread Jun Shen
Hi Don, Bill and A.K. Thanks for your reply. It worked! On Fri, Jun 20, 2014 at 3:56 PM, arun wrote: > You could try: > library(plyr) > res <- ddply(TestData[,-2],.(ID),numcolwise(max)) > colnames(res)[-1] <- paste0(colnames(res)[-1],".max") > A.K. > > > > > On Friday, June 20, 2014 3:43 PM, Ju

Re: [R] Data extraction and assembly from a data frame

2014-06-20 Thread arun
You could try: library(plyr) res <- ddply(TestData[,-2],.(ID),numcolwise(max)) colnames(res)[-1] <- paste0(colnames(res)[-1],".max") A.K. On Friday, June 20, 2014 3:43 PM, Jun Shen wrote: Hi all, Here is my situation. I have a dataframe, the structure would be something like this, TestData<

Re: [R] Data extraction and assembly from a data frame

2014-06-20 Thread William Dunlap
Have you looked at the 'aggregate' function? E.g., aggregate(TestData[c("VAR1","VAR2","VAR3")], by=TestData["ID"], max) Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Jun 20, 2014 at 12:42 PM, Jun Shen wrote: > Hi all, > > Here is my situation. I have a dataframe, the structure would be

Re: [R] Data extraction and assembly from a data frame

2014-06-20 Thread MacQueen, Don
How about aggregate(TestData[,c('VAR1','VAR2','VAR3')], by=list(id=TestData$ID), FUN=max) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/20/14 12:42 PM, "Jun Shen" wrote: >Hi all, > >Here is my situation. I have a dat

[R] Data extraction and assembly from a data frame

2014-06-20 Thread Jun Shen
Hi all, Here is my situation. I have a dataframe, the structure would be something like this, TestData<-data.frame(ID=rep(1:10,each=10),TIME=rep(seq(0.1,1,0.1),10),VAR1=rnorm(100),VAR2=5*rnorm(100),VAR3=10*rnorm(100)) Basically, I want to extract the maximum value from each ID for VAR1, VAR2, VA

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] Data Extraction - benchmark() On 22-11-2012, at 18:20, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hi Berend, > > I see you are one of the contributors to the rbecnhmark package. > > I am sorry that I am bothering you

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Berend Hasselman
te.cases(df),][1:ncol(df)]} > > require(rbenchmark) > > benchmark( d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df), d5 <- > s5(df), d6 <- s6(df), >columns=c("test","elapsed", "relative", "replications")

Re: [R] Data Extraction

2012-11-22 Thread Bert Gunter
Berend et. al: 1, Except you did not use "my solution." It is not what you have but instead: f4 <- function(df)na.omit.df wrapping the return in data.frame() is both unnecessary and inefficient. 2. But my point is not to be the speediest nor even to show how clever I am -- using a built-in func

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
columns=c("test","elapsed", "relative", "replications") ) identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), identical (d1,d6) From: Berend Hasselman [b...@xs4all.nl] Sent: Th

Re: [R] Data Extraction

2012-11-22 Thread Berend Hasselman
On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hi Berend, > > You have compared all 3 ways. ... very nicely evaluated. > Bert's solution is indeed nice and simple. But Petr's solution is still the quickest: >N <- 10 > set.seed(13) > df <- data.frame(matrix(sample(c(1:1

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
-project.org Subject: Re: [R] Data Extraction Hi, is.na<http://is.na/>( X1 | X2 | X3 | X4 | X5) isn't a valid construct. You'd need !(is.na<http://is.na>(X1) | is.na<http://is.na>(X2) etc ) Or more elegantly df1[apply(df1, 1, function(x)all(!is.na<http://is.na>(x))

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
-project.org Subject: Re: [R] Data Extraction On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hello, > > I would appreciate if someone could help me resolve the following: > > 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work > > 2. Is these

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
elp@r-project.org Subject: Re: [R] Data Extraction Unnecessarily complicated. ?na.omit (linked from ?complete.cases) df <- na.omit(df) -- Bert On Thu, Nov 22, 2012 at 6:49 AM, Berend Hasselman mailto:b...@xs4all.nl>> wrote: On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > H

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Muhuri, Pradip (SAMHSA/CBHSQ) > Sent: Thursday, November 22, 2012 3:11 PM > To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org > Subject: [R] Data Extraction > > Hello, > > I would appreciate if

Re: [R] Data Extraction

2012-11-22 Thread Bert Gunter
Unnecessarily complicated. ?na.omit (linked from ?complete.cases) df <- na.omit(df) -- Bert On Thu, Nov 22, 2012 at 6:49 AM, Berend Hasselman wrote: > > On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > > > Hello, > > > > I would appreciate if someone could help me resolve the f

Re: [R] Data Extraction

2012-11-22 Thread Berend Hasselman
On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hello, > > I would appreciate if someone could help me resolve the following: > > 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work > > 2. Is these message harmful? The following object(s) are masked from 'df1

Re: [R] Data Extraction

2012-11-22 Thread PIKAL Petr
oject.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Muhuri, Pradip (SAMHSA/CBHSQ) > Sent: Thursday, November 22, 2012 3:11 PM > To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org > Subject: [R] Data Extraction > > Hello, > > I would appreciate if someone co

Re: [R] Data Extraction

2012-11-22 Thread Sarah Goslee
Hi, is.na( X1 | X2 | X3 | X4 | X5) isn't a valid construct. You'd need !(is.na(X1) | is.na(X2) etc ) Or more elegantly df1[apply(df1, 1, function(x)all(!is.na(x))), ] Sarah On Thursday, November 22, 2012, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hello, > > I would appreciate if someone could he

[R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I would appreciate if someone could help me resolve the following: 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work 2. Is these message harmful? The following object(s) are masked from 'df1 (position 3)': X1, X2, X3, X4, X5 Thanks, Pradip Muhuri #Reproducible

Re: [R] Data extraction

2012-03-27 Thread Bert Gunter
Inline. On Tue, Mar 27, 2012 at 5:28 PM, Luisin Galindo, PhD wrote: > Dear ReXperts, > > I have the below text file output. I need to extract the T, QC, QO, QO-QC > and WT columns for > the data between T = 10 and T=150. > > Any ideas? Lots. They all begin with: ?"[.data.frame" -- Bert > > Than

Re: [R] Data extraction

2012-03-27 Thread R. Michael Weylandt
? subset subset(x, (T > 10) & (T < 150), c("T", "QC", "QO", "QO-QC") Michael On Tue, Mar 27, 2012 at 8:28 PM, Luisin Galindo, PhD wrote: > Dear ReXperts, > > I have the below text file output. I need to extract the T, QC, QO, QO-QC > and WT columns for > the data between T = 10 and T=150. > > A

[R] Data extraction

2012-03-27 Thread Luisin Galindo, PhD
Dear ReXperts, I have the below text file output. I need to extract the T, QC, QO, QO-QC and WT columns for the data between T = 10 and T=150. Any ideas? Thanks in advance. 1 D C ---CAT-- T

[R] data extraction in R

2012-01-24 Thread crimsonengineer87
All, I currently have a dataset with a variety of different columns, let's say, A,B,C, and D. I'd like to run an R script that graphs only certain rows of the dataset based on what's in column A. In awk, it'd be something like: awk ' { if(A==5 && B ==6) print $0 } ' datafile | command or file Si

[R] Data Extraction/threshold/

2011-01-19 Thread Stuart
X959X967X968 X9591 -0.04 0.45 X967-0.04 1 -0.09 X9680.45-0.09 1 X968_2 0.76-0.16 0.82 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide ht

Re: [R] Data extraction problem after importation using RODBC

2009-05-14 Thread Dieter Menne
Axel Leroix wrote: > > > Then I perform an lm regression using the following code: > reg1 <-lm(data$prod~data$pri+data$cli) > summary(reg1) > Use reg1 <-lm(prod~pri+cli, data=data) instead. It is not necessary to call the data frame you read your stuff into "data", any more useful name,

[R] Data extraction problem after importation using RODBC

2009-05-14 Thread Axel Leroix
Dear all,   I write this message because I have a problem in data importation. I hope that you help me. My data base is in an Excel spreasheet. I import this data base using the following code: library(RODBC) db <- "C:/Users/Axel/Desktop/estimation/data.xls" channel <- odbcConnectExcel(xls.fil