[R] How to apply apply?!

2010-08-06 Thread Raghuraman Ramachandran
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

Re: [R] How to apply apply?!

2010-08-06 Thread Abhijit Dasgupta, PhD
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.

Re: [R] How to apply apply?!

2010-08-06 Thread Erik Iverson
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

Re: [R] How to apply apply?!

2010-08-06 Thread Philipp Pagel
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)