dimanche 15 août 2021

Reading a csv file as matrix and change the entries using conditional if in R

I have the csv file and I want to read it as a dataframe or matrix. I successfully read the .csv file, but when I want to change the entries based on conditional if statement, it does not work. The csv file can be downloaded here mydata

I want to read this .csv file as a matrix or dataframe. Then, I want to change the entries to "YES" or "NO" based on some condition. I tried this:

mydata = read.csv("mydata.csv")
mydata = data.frame(mydata)
ifelse(mydata>0.005, "YES", "NO")
mydata

However, the result I got are output1 and output2

I have tried this

mydata = 
read.csv("/home/hudamoh/scRNAspatial/binomial/tangram_output.csv")
myresult = data.frame(mydata)
myresult[myresult>0.0005] <- "YES"
myresult[myresult<=0.0005] <- "NO"
myresult

But the output I got is that some are not changed to "YES" or "NO". Also I want it looks like matrix where the rows should be 0, 1, 9. Please help.
myresult

Aucun commentaire:

Enregistrer un commentaire