I am trying to replace all the negative values in a data frame with zero, and I also want to keep the original data frame with negative values. Here's my attempt with sample data:
col1 <- c("-1", "2", "-3", "0", "10")
col2<- c("1", "2", "3", "4", "5")
col3<- c("1", "-2", "3", "-4", "-5")
uncleaned.data <- data.frame(col1, col2, col3)
cleaned_data <- uncleaned.data[uncleaned.data<0]=0
I got an error like this object 'cleaned_data' not found
Any suggestions? Intuitively I don't see any issues here .. Thanks a lot!