Search code examples
rcsvhistogrambins

Plot Single Column Data File Histogram in RStudio


How can I display a histogram with 20 bins for the attached file? The two lines of code I attempted to use are shown below.

d=read.table("wgci_mAdc2.csv") hist(d)

I get an error message which says, "Error in hist.default(d) : 'x' must be numeric"

My data file looks something like the list below. 86.60 91.40 85.30 86.90 89.60 58.40 59.00 58.80 58.60 89.20 91.90 90.60 88.10 89.20 84.40 88.90 85.00 58.30 57.60 58.10 89.80 58.00 91.50 58.10 57.40 58.00 90.10 58.10 58.90 57.70 91.80 58.70 91.80 58.40 57.40 58.00 87.60 95.20 91.20 88.00 82.90 92.60 89.00


Solution

  • Your data is not recognised as numeric. Have you tried as.numeric() ?

    d=read.table("wgci_mAdc2.csv")
    d =as.numeric(unlist(d))
    hist(d)