I have a 40x18 matrix. What I want to do is to check (for loop) every value "x" in this matrix and then if >=0, the x should be transformed to x^alfa. If x<0, then transform it in the way -lamda*(-x)^beta.
At the end, I want to have a new matrix with the transformer values.
I tried this way but it doesn't work. Can anyone help?
Here is a part of my data:
V1 = c(-0.0488238351305964, -0.0365464622704548, -0.023110113947345, -0.00936478818716672, -0.0014143836369377, 0.0136298911422536), V2 = c(-0.0440798156253931, -0.0290469503666371, -0.0184194158583475,-0.00659023901355601, 0.0104814403440645, 0.02050543245721), df[1:40,18) V3 = c(-0.0500446221600135, -0.0310561032780763, -0.0202547384070556, -0.00900829333252385, 0.0179628052483861, 0.024328936936393))
for (h in 1:18) { if df[,h] >= 0,
df1[,h] <- df[,h]^alfa` else df1[,h] <- df[,h]^beta`
}
Aucun commentaire:
Enregistrer un commentaire