+ Reply to Thread
Results 1 to 3 of 3

Thread: how do I create a Line chart from a data frame?

  1. #1
    Points: 8, Level: 1
    Level completed: 15%, Points required for next Level: 42

    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how do I create a Line chart from a data frame?




    i'm quite the newbie with R and i want to create a line chart starting from this dataset:


    where every line points out the number of the smell detected (so in my case case 11 for version 1.2; 11 for version 1.3 and so on) and on the x axis i want to put every version that i've under exam.
    The problem is that i don't know how to keep trace of a "counter" in r, counting how many smells there are for each version

  2. #2
    Points: 8,120, Level: 60
    Level completed: 85%, Points required for next Level: 30

    Posts
    169
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Re: how do I create a Line chart from a data frame?

    It seems, you do not have a concrete imagination, how (line) charts are created in R.

    Thus, here is an example using ggplot2 (the Standard)

    Code: 
    library(ggplot2)
    
    
    dat1 <- data.frame( sex = factor(c("Female","Female","Male","Male")), time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")), total_bill = c(13.53, 16.81, 16.24, 17.42) ) 
     
    p <- ggplot(data=dat1, aes(x=time, y=total_bill, group=sex)) +
         geom_line() +
         geom_point()
    Prediction is very difficult, especially about the future. (Niels Bohr)

  3. #3
    Points: 8, Level: 1
    Level completed: 15%, Points required for next Level: 42

    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how do I create a Line chart from a data frame?


    thanks for the reply, so i managed to get to this


    with your help:
    library(ggplot2)
    p <- ggplot(data=dataset, aes(x=version, y=counter)) +
    geom_line() +
    geom_point() +
    ggtitle("Test Results") +
    theme(plot.title = element_text(hjust = 0.5)) +
    xlab("Version") +
    ylab("Total As")

    but i tought that the function geom_line would link the peak of every version

+ Reply to 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