> Thank you very much Jorge, Phil and David: I was finally able to
> perform the operations I needed. I changed the function in order to
> adapt it to the simplest form like the following:
> ali <- function(Abase) {
> alitemp <- ((Abase/llmcc$Clase)*PClase)+(((1/llmcc
> $Categoria)*Ab
One way. there may be better. The apply function will work with just
one row (or one column) at a time.
> DF
Month Week Estpassage MedFL
1 July 2766534
2 July 28 223235
3 July 29 924135
4 July 30 2846435
5Aug 31 4104935
You can use 'ifelse':
> x <- data.frame(id=sample(1:4,20,TRUE))
> # use ifelse to do the calculations
> x$cal <- ifelse(x$id == 1, 21,
+ifelse(x$id == 2, 221,
+ ifelse(x$id == 3, 2221, 1)))
> x
id cal
1 4 1
2 121
3 3 2221
4 121
5 2 221
6
3 matches
Mail list logo