,
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
To: arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] data frame manipulation change elements meeting
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 - X
for (i in which(Y==DEL)){
new.vect[i]-switch(
EXPR = X[i],
Sell=Buy,
Buy
..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 manipulation change elements meeting criteria
The loop is due to the switch statement
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 manipulation change elements meeting criteria
The loop is due
want !!
From: Joris Meys [mailto:jorism...@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
] 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 manipulation change elements meeting criteria
The loop is due
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 vector
trades$Buy.Sell..Cleared for which trades
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, 368., 368.5000),
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 PM, arnaud Gaboury
9 matches
Mail list logo