+ Reply to Thread
Results 1 to 3 of 3

Thread: cannot draw a histogram on R

  1. #1
    Points: 4, Level: 1
    Level completed: 7%, Points required for next Level: 46

    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cannot draw a histogram on R




    Im trying to draw a histogram with the code below.

    stat <- read.csv("C://Desktop//lung cancer.csv",header=T)
    x = (2000:2013)
    y = (0:12000)
    hist(stat$Year,stat$Cases, ylab="Cases",xlab="Year",main="Number of cases of Lung Cancer:2000-2013")



    error message:

    > hist(ylab="Cases",xlab="Year",main="Number of cases of Lung Cancer:2000-2013")
    Error in hist.default(ylab = "Cases", xlab = "Year", main = "Number of cases of Lung Cancer:2000-2013") :
    argument "x" is missing, with no default
    > stat <- read.csv("C://Heramba//Desktop//lung cancer.csv",header=T)
    Error in file(file, "rt") : cannot open the connection
    In addition: Warning message:
    In file(file, "rt") :
    cannot open file 'C://Heramba//Desktop//lung cancer.csv': No such file or directory

  2. #2
    Omega Contributor
    Points: 39,138, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,086
    Thanks
    404
    Thanked 1,196 Times in 1,157 Posts

    Re: cannot draw a histogram on R

    I don't use R a bunch, but can you run this line by line to better figure out where the error(s) is.


    And maybe do some basics like just run the following:
    summary(stat)
    x
    y


    P.S., is the double slashes a thing? "//"
    Stop cowardice, ban guns!

  3. #3
    TS Contributor
    Points: 12,501, Level: 73
    Level completed: 13%, Points required for next Level: 349
    rogojel's Avatar
    Location
    I work in Europe, live in Hungary
    Posts
    1,491
    Thanks
    162
    Thanked 334 Times in 314 Posts

    Re: cannot draw a histogram on R


    hi,
    why do you have 2 parameters for the hist call? It only needs one. My guess is that you want a barchart of the number of cases per year. Something like:

    Years=as.character(D$Years)
    barplot(D$Counts, names.arg=Years)


    regards

+ Reply to Thread

           




Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats