Re: [R] For loop and using its index

2012-03-09 Thread chuck.01
Hassan, Others have provided you with better solutions, but I hope this allows you to see why yours didn't work. # first (going with your code) you needed a data.frame called "x" # here is an example: x <- structure(list(x1 = c(0.0986048226696643, -0.445652024980979, 0.0893989676314604, -3.02

Re: [R] For loop and using its index

2012-03-09 Thread Petr Savicky
On Fri, Mar 09, 2012 at 01:24:00PM +0330, Hassan Eini Zinab wrote: > Dear All, > > I have a data set with variables x1, x2, x3, ..., x20 and I want to > create z1, z2, z3, ..., z20 with the following formula: > > > z1 = 200 - x1 > z2 = 200 - x2 > z3 = 200 - x3 > . > . > . > z20 = 200 - x20. > >

Re: [R] For loop and using its index

2012-03-09 Thread Milan Bouchet-Valat
Le vendredi 09 mars 2012 à 13:24 +0330, Hassan Eini Zinab a écrit : > Dear All, > > I have a data set with variables x1, x2, x3, ..., x20 and I want to > create z1, z2, z3, ..., z20 with the following formula: > > > z1 = 200 - x1 > z2 = 200 - x2 > z3 = 200 - x3 > . > . > . > z20 = 200 - x20. >

Re: [R] For loop and using its index

2012-03-09 Thread Petr PIKAL
Hi > Dear All, > > I have a data set with variables x1, x2, x3, ..., x20 and I want to > create z1, z2, z3, ..., z20 with the following formula: > > > z1 = 200 - x1 > z2 = 200 - x2 > z3 = 200 - x3 > . > . > . > z20 = 200 - x20. > > > I tried using a for loop and its index as: > > for (i in 1