I would like to ask you for help with my data frame. It is a vector of many phases and for every one we have names of variables. Lets say
vec<-data.frame(phase1= c("var1","var2","var3","var4","var5","var6"),
phase2= c("var1","var3","var4","var2","var6","var5"),
phase3= c("var4","var3","var2","var1","var6","var5"))
vec
phase1 phase2 phase3
1 var1 var1 var4
2 var2 var3 var3
3 var3 var4 var2
4 var4 var2 var1
5 var5 var6 var6
6 var6 var5 var5
Now, lets say we are interested for the first 3 rows and therefore the weight of variable in one of them is 1/3, zero otherwise. My function would ideally output sth like that:
phase1 phase2 phase3
var1 0.33 0.33 0
var2 0.33 0 0.33
var3 0.33 0.33 0.33
var4 0 0.33 0.33
var5 0 0 0
var6 0 0 0
The function should also be applicable for the first 4, 5 or all 6 rows (ie the weights will change then).
Regards,
Alex
I believe you are looking for this:
If need be, you could add: