Apply different calculations by row in r

27 Views Asked by At

I am trying to calculate results per each row in a data frame Data frame

I have tried the following

results$index<-noquote(results$Expr) results$index<-parse(text=results$index) results$index<-eval(results$index)

results %>% rowwise() %>% mutate(eval(eval(parse(text=noquote(index))))) results %>% rowwise() %>%mutate(res = eval(rlang::parse_expr(character(index))))

1

There are 1 best solutions below

0
Δημήτρης Παπαδόπουλος On

This works

for (i in 1:nrow(results)) { results$index[which(results$indicator==i)]<-eval(rlang::parse_expr(results$expr[i])) }

but it is taking a lot time