Dear Sirs: I've been working with several variables in a dataframe  
that serve as part of a calculation that I need to perform in a  
different way depending on its value. Let me explain:

The main dataframe is called llmcc

llmcc : 'data.frame':	283 obs. of  11 variables:
  $ Area     : num  308.8 105.6 51.4 51.4 52.9 ...
  $ mFondo   : num  30.1 10 10.2 10.2 40.4 ...
  $ mFachada : num  22.95 6.7 4.72 4.72 4.72 ...
  $ Marca    : Factor w/ 132 levels "AA_Movilnet",..: 11 32 82 82 32  
32 32 32 32 32 ...
  $ Clase    : int  8 4 1 1 1 1 1 1 12 1 ...
  $ Categoria: int  2 6 6 6 1 1 1 1 1 1 ...
  $ Phi      : num  0.128 0.147 0.217 0.217 0.887 ...
  $ Rf       : num  0.119 0.102 0.147 0.147 0.143 ...
  $ OldA     : num  0.737 0.258 0.375 0.375 0.385 ...
  $ OldCondo : num  4436 1555 2260 2260 2318 ...
  $ NewA_Jon : num  1.069 0.368 0.256 0.256 0.264 ...

I perform an initial operation using the original variables plus one  
numeric (Abase) that is external and has the same number of rows than  
the dataframe:

alitemp  <- ((Abase/llmcc$Clase)*PClase)+(((1/llmcc 
$Categoria)*Abase)*PCategoria)+((Abase*llmcc$Phi)*PPhi)+((Abase*llmcc 
$Rf)*PRf)

So, after I obtain the results of this calculation, I append the  
series by creating an additional column within the original dataframe:
l
lmcc$Alitmp  <- alitemp

Problem is: I need to calculate a new column using a formula that has  
different structure depending on the values of llmcc$Clase, thus: for  
any given row of llmcc where llmcc$Clase is >= 10 i would have to  
perform some operations with other values in the same row that are, by  
definition, different than the ones I would need in case of lmcc$Clase  
is < 10.
I've managed to break down the original dataframe by using subsets,  
and then performing the calculations, but then it is complicated to  
put the results in the same order of the original dataframe.
I understand the workings of the control structures available in R but  
after reading the docs and help files, I can´t figure how to perform a  
conditional calculation row by row that checks first the values of a  
given column and then applies the corresponding operation to another  
column, so it outputs a series in the same exact order as the dataframe.

Any light that you might share with me over this will be highly  
appreciated.

Thanks in advance.


Guillermo.



Nunca le preguntes a un peluquero si necesitas un corte de pelo. Ley  
de Murray.
------------------------------
Jesús Guillermo Andrade (Abg.)
Gerente de Litigios y Corporativo. EDM. AC. API.
Andrade & Moreno S.C. (http://amlegal.wordpress.com/)


	[[alternative HTML version deleted]]


