pell...@gmail.com
unread,Feb 28, 2019, 6:19:11 AM2/28/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Forest-R
Hi All,
I have this array :
arr <- array(data = c(0.1, 0.52, 0.3, 0.4, 0.3, 0.2, 0.7, 0.8), dim = c(2, 2, 2))
I want to test if there is a value > 0.5 so return it if not return NA.
I tried this but it is not what I want :
apply(arr, c(1,2), function(x) {ifelse(x >0.5, x,NA)})
my desire output 1 matrix 2*2:
res1= #resturn the value
[,1] [,2]
[1,] NA 0.7
[2,] 0.52 0.8
and another matrix 2*2 to show the index res2= return the index of that value
[,1] [,2]
[1,] NA 1
[2,] 1 2
1 means 0.7 comes from the first matrix arr[,,1]
2 means 0.8 comes from the second matrix arr[,,2] etc
Any hints on this.
thanks
Thom