Re: [R] data frame manipulation

2014-02-20 Thread Jeff Newmiller
Depending what you really want to achieve, the following may be useful or educational: dat$ID2x <- with( dat, ave( rep( 1, nrow( dat ) ), ID, USE, FUN=cumsum ) ) dat$ID2y <- dat$ID2x dat$ID2y[ dat$USE != "001" ] <- NA On Thu, 20 Feb 2014, arun wrote: Hi, Try: dat$ID2 <- with(dat,ave(seq_along

Re: [R] data frame manipulation

2014-02-20 Thread arun
Hi, Try: dat$ID2 <- with(dat,ave(seq_along(USE),ID,FUN=function(x){x1 <- USE[x] =='001'; ifelse(!x1,'',cumsum(x1))})) A.K. On Thursday, February 20, 2014 3:31 PM, Pedro Mardones wrote: Dear R community; I'm kind of stuck with the following situation and would appreciate any hint. Let's assu

[R] data frame manipulation

2014-02-20 Thread Pedro Mardones
Dear R community; I'm kind of stuck with the following situation and would appreciate any hint. Let's assume I have the following data frame: dat <- data.frame(ID = c(rep("01",18), rep("02",16)), USE = c(c("001","004", "005","007","001","004","005","007","012","001","004","005","007","001","004",

Re: [R] Data frame manipulation

2012-11-22 Thread arun
ão Junho   1   3   7h 2.20412 #6 Conceição Junho   1   4   7h 2.16435 A.K. To: r-help@r-project.org Cc: Sent: Thursday, November 22, 2012 8:53 PM Subject: [R] Data frame manipulation Hello, I have a table that was constructed in a wrong way (dput data on bottom - wrong data-frame):    

Re: [R] Data frame manipulation

2012-11-22 Thread jim holtman
The 'reshape2' package is your friend: > require(reshape2) > x <- melt(wrong, id = c("Local", "Mês", "Dia", "Colonia"), variable.name = > "Hora") > # remove "X" from Hora > x$Hora <- as.character(substring(x$Hora, 2)) > head(x) # not in the right order Local Mês Dia Colonia Hora value

[R] Data frame manipulation

2012-11-22 Thread Raoni Rodrigues
Hello, I have a table that was constructed in a wrong way (dput data on bottom - wrong data-frame): Local Mês Dia Colonia X6h X7h X8h X9hX10hX11h X12hX13hX14hX15hX16hX17h 1 Conceição Junho 1 3 2.16137 2.20412 2.08991 1.72428 1.69897 1.

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
nlap. > > Arnaud Gaboury > > A2CT2 Ltd. > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of ilai > Sent: vendredi 24 février 2012 20:14 > To: A2CT2 Trading > Cc: r-help@r-project.org > Subject:

Re: [R] data frame manipulation with conditions

2012-02-24 Thread Arnaud Gaboury
To: A2CT2 Trading Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with conditions On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading wrote: > Dear list, > > n00b question, but still can't find any easy answer. > > Here is a df: > >> df<-data.frame(cbin

Re: [R] data frame manipulation with conditions

2012-02-24 Thread ilai
On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading wrote: > Dear list, > > n00b question, but still can't find any easy answer. > > Here is a df: > >> df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) # No, your y is a factor str(df) 'data.frame': 4 obs. of 2 variables: $ x: Factor w/ 3 leve

Re: [R] data frame manipulation with condition

2012-02-24 Thread William Dunlap
requires you to choose. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: Sarah Goslee [mailto:sarah.gos...@gmail.com] > Sent: Friday, February 24, 2012 9:39 AM > To: William Dunlap > Cc: Arnaud Gaboury; r-help@r-project.org > Subject: Re: [

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
Whatever makes you happy. > df1 <- + structure(list(x = structure(c(1L, 2L, 2L, 3L), .Label = c("AA", + "BB", "CC"), class = "factor"), y = 1:4), .Names = c("x", "y" + ), row.names = c(NA, -4L), class = "data.frame") > mult <- c("AA"=2,"BB"=5,"CC"=1,"DD"=2) > df1$y * mult[df1$x] AA BB BB CC 2 10

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
B","CC","DD","DD"), y = 1:8) >df2$y <- df2$y * mult[as.character(df2$x)] > df2 x y 1 AA 2 2 AA 4 3 BB 15 4 BB 20 5 BB 25 6 CC 6 7 DD 14 8 DD 16 WORKING Ty both of you and have a good weekend. Arnaud Gaboury   A2CT2 Ltd. -Original Mes

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
90 > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf Of Arnaud Gaboury >> Sent: Friday, February 24, 2012 8:37 AM >> To: U

Re: [R] data frame manipulation with condition

2012-02-24 Thread William Dunlap
in% names(mult) > df$y[i] <- df$y[i] * mult[as.character(df$x[i])] > df x y 1 AA 10 2 BB 50 3 CC 3 4 AA 40 5 DD 75 6 DD 90 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-hel

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
r the use of the individual or entity to whom they are addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. If yo

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
ting. Feel free to ignore my post if you think I am lazy and disrespectful to the list. Arnaud Gaboury   A2CT2 Ltd. -----Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:41 To: Arnaud Gaboury Cc: r-help@r-project.org Subject:

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
---> if df$x==BB, df$y<-2*25 > 3 CC 3         NOTHING > 4 AA 40    > if df$x==AA, df$y<-4*10 > 5 DD 75   > if df$x==DD, df$y<-5*15 > 6 DD 90   > if df$x==DD, df$y<-6*15 > > Arnaud Gaboury > > A2CT2 Ltd. > > -Original Message-

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
==DD, df$y<-6*15 Arnaud Gaboury A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:07 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:59, Arnaud

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
5 DD 75 > if df$x==DD, df$y<-5*15 6 DD 90 > if df$x==DD, df$y<-6*15 Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 17:07 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re

Re: [R] data frame manipulation with condition

2012-02-24 Thread Sarah Goslee
2CT2 Ltd. >> >> >> -Original Message- >> From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] >> Sent: vendredi 24 février 2012 16:33 >> To: Arnaud Gaboury >> Cc: r-help@r-project.org >> Subject: Re: [R] data frame manipulation

[R] data frame manipulation with conditions

2012-02-24 Thread A2CT2 Trading
Dear list, n00b question, but still can't find any easy answer. Here is a df: > df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) > df x y 1 AA 1 2 BB 2 3 CC 3 4 AA 4 I want to modify this df this way : if df$x=="AA" then df$y=df$y*10 if df$x=="BB" then df$y=df$y*25 and so on with ot

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
boury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:25, Arnaud Gaboury wrote: Dear list, n00b question, but still can't find any easy answer. Here is a df: Change df<-data.frame(cbind(x=c("AA","BB","CC&q

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
boury   A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février 2012 16:33 To: Arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation with condition On 24.02.2012 16:25, Arnaud Gaboury wrote: > D

Re: [R] data frame manipulation with condition

2012-02-24 Thread Uwe Ligges
On 24.02.2012 16:25, Arnaud Gaboury wrote: Dear list, n00b question, but still can't find any easy answer. Here is a df: Change df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) to df <- data.frame(x = c("AA","BB","CC","AA"), y = 1:4) to make your object a sensible data.frame.

[R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
Dear list, n00b question, but still can't find any easy answer. Here is a df: > df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4)) > df x y 1 AA 1 2 BB 2 3 CC 3 4 AA 4 I want to modify this df this way : if df$x=="AA" then df$y=df$y*10 if df$x=="BB" then df$y=df$y*25 and so on with ot

Re: [R] Data frame manipulation by eliminating rows containing extreme values

2011-10-23 Thread aajit75
Hi David, Thanks for the reply, f=function(x){quantile(x, c(0.25, 0.75),na.rm = TRUE) - matrix(IQR(x,na.rm = TRUE) * c(1.5), nrow = 1) %*% c(-1, 1)} Here parameter 1.5 is set for example in the above function as argument, it can be even more may be 3.0 after analyzing actual data. Here expecta

Re: [R] Data frame manipulation by eliminating rows containing extreme values

2011-10-22 Thread David Winsemius
On Oct 22, 2011, at 6:57 AM, aajit75 wrote: Dear All, I have got the limits for removing extreme values for each variables using following function . f=function(x){quantile(x, c(0.25, 0.75),na.rm = TRUE) - matrix(IQR(x,na.rm = TRUE) * c(1.5), nrow = 1) %*% c(-1, 1)} I think you need t

[R] Data frame manipulation by eliminating rows containing extreme values

2011-10-22 Thread aajit75
Dear All, I have got the limits for removing extreme values for each variables using following function . f=function(x){quantile(x, c(0.25, 0.75),na.rm = TRUE) - matrix(IQR(x,na.rm = TRUE) * c(1.5), nrow = 1) %*% c(-1, 1)} #Example: n <- 100 x1 <- runif(n) x2 <- runif(n) x3 <- x1 + x2 + runif(

Re: [R] Data Frame Manipulation using function

2010-07-09 Thread David Winsemius
Really? I don't usually think of Vectorize as a performance enhancement, probably because my use of with a complex function then gets applied to 4.5 million records. I need to go out, get a cup of coffee, and leave it alone for about half an hour. I tried recently to figure out how I can d

Re: [R] Data Frame Manipulation using function

2010-07-09 Thread harsh yadav
Hi, Thanks a lot. The Vectorize method worked and its much faster than looping through the data frame. Regards, Harsh Yadav On Thu, Jul 8, 2010 at 11:06 PM, David Winsemius wrote: > > On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote: > > >> I have a data frame: >>> id url >>> urlType >>

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote: I have a data frame: id url urlType 1 1 www.yahoo.com www.yahoo.com>1 2 2 www.google.com/?search=

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread Erik Iverson
I have a data frame: id url urlType 1 1 www.yahoo.com 1 2 2 www.google.com/?search= 2 3 3

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 10:09 PM, harsh yadav wrote: Hi, Here is a somewhat detailed explanation of what I want to achieve: I have a data frame: id url urlType 1 1 www.yahoo.com1 2 2 www.google.com/?search= 2 3

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread harsh yadav
Hi, Here is a somewhat detailed explanation of what I want to achieve: I have a data frame: id url urlType 1 1 www.yahoo.com1 2 2 www.google.com/?search= 2 3 3 www.google.com

Re: [R] Data Frame Manipulation using function

2010-07-08 Thread Erik Iverson
It will be a lot easier to help you if you follow the posting guide and PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. You gave your function definition, which is good. Use ?dput to give us a small data.frame that can accurately show what y

[R] Data Frame Manipulation using function

2010-07-08 Thread harsh yadav
Hi all, I have a data frame for which I want to limit the output by checking whether row values for specific column meets particular conditions. Here are the more specific details: I have a function that checks whether an input string exists in a defined list:- checkBaseLine <- function(s){ fo

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread arnaud Gaboury
n Ripley > Subject: Re: [R] data frame manipulation with zero rows > > Hi Arnaud, > > I've added this case to the set of test cases in plyr and it will be > fixed in the next version. > > Hadley > > On Tue, Jun 1, 2010 at 2:33 PM, arnaud Gaboury > wrote:

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread Hadley Wickham
(nrow(futures)==0) futures<-data.frame(...) > > > > > >> -Original Message- >> From: Peter Ehlers [mailto:ehl...@ucalgary.ca] >> Sent: Tuesday, June 01, 2010 12:07 PM >> To: arnaud Gaboury >> Cc: 'Prof Brian Ripley'; r-help@r-project.o

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
rnaud Gaboury > Cc: 'Prof Brian Ripley'; r-help@r-project.org > Subject: Re: [R] data frame manipulation with zero rows > > On 2010-06-01 1:53, arnaud Gaboury wrote: > > Brian, > > > > If I do understand correctly, I must use in my function something > else

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
It is indeed ddply() from package plyr. > -Original Message- > From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > Sent: Tuesday, June 01, 2010 12:24 PM > To: Peter Ehlers > Cc: arnaud Gaboury; r-help@r-project.org > Subject: Re: [R] data frame manipulation with

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Prof Brian Ripley
hat that is or what it should do for the case of zero rows: it may or may not be the one in package plyr. -Peter Ehlers -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Tuesday, June 01, 2010 9:47 AM To: arnaud Gaboury Subject: Re: [R] data frame manip

Re: [R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
to aggregate > -Original Message- > From: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de] > Sent: Tuesday, June 01, 2010 11:38 AM > To: arnaud Gaboury > Subject: Re: [R] data frame manipulation ddply > > Hi Arnaud, > > maybe "agg

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread Peter Ehlers
ilto:rip...@stats.ox.ac.uk] Sent: Tuesday, June 01, 2010 9:47 AM To: arnaud Gaboury Subject: Re: [R] data frame manipulation with zero rows On Tue, 1 Jun 2010, arnaud Gaboury wrote: Dear group, Here is the kind of data.frame I obtain every day with my function : futures<- structure(list(DESCRIPT

[R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
Dear group, Here is my data frame: futures <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10", "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
0 9:47 AM > To: arnaud Gaboury > Subject: Re: [R] data frame manipulation with zero rows > > On Tue, 1 Jun 2010, arnaud Gaboury wrote: > > > Dear group, > > > > Here is the kind of data.frame I obtain every day with my function : > > > > futures <

[R] data frame manipulation with zero rows

2010-05-31 Thread arnaud Gaboury
Dear group, Here is the kind of data.frame I obtain every day with my function : futures <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10", "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR N

Re: [R] Data frame manipulation

2010-05-29 Thread Tal Galili
Hi there, I am glad it helped. I used mean as something to use, not because I had an understanding that this is what you need - so if you believe sum is what you where after - go with it :) Regarding loving R, and time spending - everyone on this list probably know how you feel. We all spent time

Re: [R] Data frame manipulation

2010-05-28 Thread LCOG1
Tal, Wow, i cant believe how many different manipulations i went through trying to coerce it into the format i wanted. The below works nearly perfectly, i had to change the "mean" call to "sum". Im curious why you used mean? Other than that thank you very much, i feel a little foolish ab

Re: [R] Data frame manipulation

2010-05-28 Thread Tal Galili
Hi there, The tool to learn for this is the cast function using the reshape package. In your example you have more then one value for RTL, which you should think of how to account for. But basically, here is a solution to what you asked for (assuming I understood you correctly) require(reshape)

[R] Data frame manipulation

2010-05-27 Thread LCOG1
Hello All, Please consider the following: TotEmp<-c(19,6,1,1,8,44,2,33,48,1) ClusterType<-c("AGF","CNS","OSV","RTL","RTL","TRN","REL","ACC_CLUST","RTL","WHL") Taz<-c(0,0,0,100,100,100,101,101,102,103) AllCtTypes_<-c("AGF","CNS","OSV","RTL","TRN","REL","ACC_CLUST","WHL","ADM_CLUST", "HLH","HLH_C

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
..@gmail.com] Sent: Thursday, May 27, 2010 10:38 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria Off course. You put in a matrix to sapply, but sapply is for vectors. You want to apply the switch command on every entry of the

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
, 2L, 1L), Price = c("15.2500", "368.", "368.5000"), Net.Charges..sum. = c(4.01, -8.64, -4.32)), .Names = c("Trade.Status", "Instrument.Long.Name", "Delivery.Prompt.Date", "Buy.Sell..Cleared.", "Volume", "Price"

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread Joris Meys
)],switch,Sell="Buy",Buy="Sell") > > > tradenews > Sell > "Buy" > > Not really what I want !! > > From: Joris Meys [mailto:jorism...@gmail.com] > Sent: Thursday, May 27, 2010 10:38 AM > To: arnaud Gaboury > Cc: r-help@r-projec

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread Joris Meys
t; NULL > > $Instrument.Long.Name > NULL > > $Delivery.Prompt.Date > NULL > > $Buy.Sell..Cleared. > [1] "Buy" > > $Volume > [1] "Buy" > > $Price > NULL > > $Net.Charges..sum. > NULL > > That's certainly not what I w

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
[1] "Buy" $Volume [1] "Buy" $Price NULL $Net.Charges..sum. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulat

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria see ?switch X<- rep(c("Buy","Sell","something else"),each=5) Y<- rep(c("DEL","INS","DEL"),5) new.vect

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread Joris Meys
e any way to combine if() and switch() in one line? In my case, > something like : > > >if(trade$Trade.Status=="DEL")switch(.) > > I would like to avoid the loop . > > > > From: Joris Meys [mailto:jorism...@gmail.com] > Sent: Wednesday, May 26, 2010 9:15 PM &

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread Joris Meys
see ?switch X<- rep(c("Buy","Sell","something else"),each=5) Y<- rep(c("DEL","INS","DEL"),5) new.vect <- X for (i in which(Y=="DEL")){ new.vect[i]<-switch( EXPR = X[i], Sell="Buy", Buy="Sell", X[i]) } cbind(new.vect,X,Y) On Wed, May 26, 2010 at 7:43 P

[R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
Dear group, Here is my df : trade <- structure(list(Trade.Status = c("DEL", "INS", "INS"), Instrument.Long.Name = c("SUGAR NO.11", "CORN", "CORN"), Delivery.Prompt.Date = c("Jul/10", "Jul/10", "Jul/10"), Buy.Sell..Cleared. = c("Sell", "Buy", "Buy"), Volume = c(1L, 2L, 1L), Price = c("15.2500",

Re: [R] data frame manipulation and regex

2010-04-28 Thread David Winsemius
0""ROBUSTA COFFEE (10) Jul/10" [4] "SOYBEANS Jul/10""SPCL HIGH GRADE ZINC USD\n" "STANDARD LEAD USD " -- David *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F ******* -----Original Messag

Re: [R] data frame manipulation and regex

2010-04-28 Thread Henrique Dallazuanna
gt; > > *** > Arnaud Gaboury > Mobile: +41 79 392 79 56 > BBM: 255B488F > *** > > > > -Original Message- > > From: David Winsemius [mailto:dwinsem...@comcast.net] > > Sent: Wednesday, April 28, 2010 2:25 PM &g

Re: [R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
Winsemius [mailto:dwinsem...@comcast.net] > Sent: Wednesday, April 28, 2010 2:25 PM > To: arnaud Gaboury > Cc: r-help@r-project.org > Subject: Re: [R] data frame manipulation and regex > > > On Apr 28, 2010, at 5:14 AM, arnaud Gaboury wrote: > > > Dear group, > > &g

Re: [R] data frame manipulation and regex

2010-04-28 Thread David Winsemius
On Apr 28, 2010, at 5:14 AM, arnaud Gaboury wrote: Dear group, Here is my data.frame : avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD Jul/10", "STANDARD LEAD USD Jul/10"), prix = c(-1.5, -108

[R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
Dear group, Here is my data.frame : avprix <- structure(list(DESCRIPTION = c("CORN Jul/10", "CORN May/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SPCL HIGH GRADE ZINC USD Jul/10", "STANDARD LEAD USD Jul/10"), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8,

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Excellent!! You saved me hours and hours of turning around and around. TY so much. From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:37 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation It works for me... > DF <- + str

Re: [R] data frame manipulation

2010-04-16 Thread Ista Zahn
DATE SETTLEMENT > 1 PRIMARY NICKEL0 2010-03-10 > 2 PRM HGH GD ALU0 2010-04-09 > 3 SPCL HIGH GRAD2 2010-04-09 > 4 STANDARD LEAD 0 2010-04-06 > > > That is exactly what I want, but not with the NA ! the SETTLEMENT column

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
the CREATED.DATE *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:05 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation Hi, I'm not sure I understand

Re: [R] data frame manipulation

2010-04-16 Thread Ista Zahn
Hi, I'm not sure I understand what you want exactly. My best guess is that you want something like op=ddply(DF, c("DESCRIPTION"), summarise, POSITION= sum(QUANITY),DATE=max(CREATED.DATE), CLOSING.PRICE = CLOSING.PRICE[CREATED.DATE == max(CREATED.DATE)]) op <- unique(op) Does that do it? -Ista

[R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Dear group, Here is my data.frame : df <- structure(list(DESCRIPTION = c("PRM HGH GD ALU", "PRM HGH GD ALU", "PRIMARY NICKEL", "PRIMARY NICKEL", "PRIMARY NICKEL", "PRIMARY NICKEL", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STANDARD LEAD ", "STA

Re: [R] Data Frame Manipulation: Time Series

2009-01-27 Thread Josip Dasovic
Hello Jim: Yes, that's exactly what I needed! Thank you! Josip - Original Message - From: "jim holtman" To: "Josip Dasovic" Cc: r-help@r-project.org Sent: Tuesday, January 27, 2009 4:45:31 PM GMT -08:00 US/Canada Pacific Subject: Re: [R] Data Frame Manipula

Re: [R] Data Frame Manipulation: Time Series

2009-01-27 Thread jim holtman
Is the what you are after: > df<-data.frame(cbind("country"=c(rep("Angola", 9), rep("Burundi", 7), + rep("Chad", 13)), "year"=c(1975:1983, 1989:1995, 1965:1977)), + "war"=c(rep(1,2), rep(0,5), rep(1,2), rep(1,2), rep(0,2), rep(1,3), + rep(1,4), rep(0,6), rep(1,3))) > x <- split(df,

[R] Data Frame Manipulation: Time Series

2009-01-27 Thread Josip Dasovic
Dear R Helpers: I have a data set where the unit of observation is country-year. I would like to generate a new data set based on some inclusionary (exclusionary) criteria. Here is an example of the type of data that I have. df<-data.frame(cbind("country"=c(rep("Angola", 9), rep("Burundi", 7),

Re: [R] data frame manipulation - splitting monitoring interval and assigning stage

2008-06-26 Thread Jessi Brown
I'd like to thank those who contacted me with ideas on how to solve this little problem. I learned something from looking through each snippet of code, even if it wasn't doing quite what I'd hoped it would do. Mark Leeds deserves special thanks, for helping me debug my several attempts to "improve"

Re: [R] data frame manipulation - splitting monitoring interval and assigning stage

2008-06-25 Thread jim holtman
Is this what you want: > x <- read.table(textConnection("Check1 Check2 HatchDate + 101 121 110 + 130 150 140 + 140 150 160"), header=TRUE) > closeAllConnections() > x Check1 Check2 HatchDate 1101121 110 2130150 140 3140150

[R] data frame manipulation - splitting monitoring interval and assigning stage

2008-06-25 Thread Jessi Brown
Hello, everyone. I'm hoping to prevent myself from doing a lot of pointing and clicking in Excel. I have a dataframe of bird nest check observations, in which I know the date of the first check, the date of the second check (both currently in Julian date format), the status of the nest at the seco

Re: [R] Data frame manipulation - newbie question

2008-01-06 Thread jim holtman
There are a number of different ways that you would have to manipulate your data to do what you want. It is useful to learn some of these techniques. Here, I think, are the set of actions that you want to do. > x <- read.table(textConnection("row k.idx step.forwd pt.nummodel > pre

Re: [R] Data frame manipulation - newbie question

2008-01-06 Thread Rense Nieuwenhuis
Hi, you may want to use that apply / tapply function. Some find it a bit hard to grasp at first, but it will help you many times in many situations when you get the hang of it. Maybe you can get some information on my site: http:// www.rensenieuwenhuis.nl/r-project/manual/basics/tables/ Ho

[R] Data frame manipulation - newbie question

2008-01-03 Thread José Augusto M. de Andrade Junior
Hi all, Could someone please explain how can i efficientily query a data frame with several factors, as shown below: - Data frame: pt.knn ---