I am trying to use a simple ifelse
command to do a simple operation on a dataframe.
mnist_raw <- read.csv("https://pjreddie.com/media/files/mnist_train.csv")
mnist = head(mnist_raw,10000)
H = mnist[1:1000,250:300]
H1 = ifelse(H>0,H,1)
colSums(H)
#Whereas this gives an error. Error in colSums(H1) : 'x' must be an array of at least two dimension
colSums(H1)
It seems that the output of ifelse
is a list, which is a different type from the input. Any ideas on how to tackle this so that I get the same type of output as the input.