I am reading a csv file into R and trying to do take the log of the data. The csv file has columns of data with the first row having text headers and the rest numeric data.
data<-read.csv("rawdata.csv",header=T)
trans<-log(csv2)
I get the following error when I do this:
Error in Math.data.frame(list(Revenue = c(18766L, 20197L, 20777L, 23410L, : non-numeric variable in data frame: Costs
Output of str should have been inserted in Q-body:
data.frame': 167 obs. of 3 variables: 
 $ X: int 18766 20197 20777 23410 23434 22100 22337 21511 22683 23151 ... 
 $ Y: Factor w/ 163 levels "1,452.70","1,469.00",..: 22 9 55 109 158 82 131 112 119 137 ...
 $ Z: num 564 608 636 790 843 ...
How do I correct this?
Tada!  Y is a factor - big problem.  The commas shouldn't be in there.
Also, your original question has some anomalies: data is the loaded data.frame, yet the transformation is applied to csv2.  Did you rename the columns?  If so, you've not given a full summary of the steps involved.  Anyway, the issue is that you have commas in your second column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With