Iam trying to calculate multiple values with my own function from a dataframe. The function currently returns only one value in a dataframe. It seems my for loop is not working correctly. I've also tried to put the results in a new list...
My dataframe:
A B C D E ES -0.03 -0.08 -0.07 -0.03 -0.11 My function:
w <- function(x){ for(i in 1:length(x)) { return( (1/x[i]) / (sum(1/x)) ) } } The formula is correct because of the result. Does anyone have a solutions for my problem? Thanks!