guRus
I have say a dataframe, d and I wish to do the following:
1) For each row, I want to take one particular value of the row and multiply
it by 2. How do I do it. Say the data frame is as below:
OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05 0 0 0 1052.5
0 0 0 987.8 0 0 0
For 1, an easy way is
dat - transform(dat, CLOSE2=2*CLOSE)
For 2:
apply(dat,1,fun)
On 08/06/2010 03:06 PM, Raghuraman Ramachandran wrote:
guRus
I have say a dataframe, d and I wish to do the following:
1) For each row, I want to take one particular value of the row and multiply
it by 2.
Raghuraman Ramachandran wrote:
guRus
I have say a dataframe, d and I wish to do the following:
1) For each row, I want to take one particular value of the row and multiply
it by 2. How do I do it. Say the data frame is as below:
OPEN HIGH LOW CLOSE 1931.2 1931.2 1931.2 1931.2 0 0 0 999.05
How do I multiply only the close of every row using the 'apply' function?
And once multiplied how do I obtain a new table that also contains the new
2*CLOSE column (without cbind?).
You don't use apply in this case - a simple multiplication and
variable assignment will do:
require(tseries)
4 matches
Mail list logo