I have a dataframe with sales of 896 items from Monday to Saturday. Inside, there are some NA values and numbers such as for example $2,796.21. I read the txt file with:
mega1 <- read.table("Report-WEEK 24112014.txt", sep=",", stringsAsFactors = FALSE, header = FALSE)
I want to get rid of the the NA values, the "$" and "," characters so I can perform my sales analysis. I used:
mega1[is.na(mega1)] <- 0 # to replace the NAs by 0
mega1$Monday <- as.numeric(sub("\\$" ,"", mega1$Monday)) #as the same for the other days
but R gave me: Warning message: NAs introduced by coercion and the numbers such as $2796.21 has changed to NA.
I would like some help. Thanks!