mardi 15 octobre 2019

ifelse statement returning 0 in R

I am writing a conditional statement in R, to return values from one matrix, if value in other matrix is TRUE. It returns 0 every time.

I have a temperature table of an image, and also table that shows cluster for each point. I want to extract temperature info data only from points in cluster 3.

asc <- read_excel("V:ascii_temp.xlsx") 
b <- df$cluster=="3" # image segmenting result. Taking only cluster 3, matrix 1
m <- as.matrix(asc) # matrix 2
cond <- ifelse(b=="TRUE",m,0)

Aucun commentaire:

Enregistrer un commentaire