-1

l have a file having two fields. l want to plot a line plot where x-axis will be days and y-axis will be the frequency of AA and BB. and lines will be AA and BB. I tried some R packages but could not get it. Any lead would be appreciated.

Disease days
AA  7
AA  5
AA  5
AA  15
AA  4
AA  15
AA  5
AA  7
BB  4
BB  3
BB  11
BB  6
BB  12
BB  6
BB  9
BB  20
BB  4
BB  2
Maurits Evers
  • 49,617
  • 4
  • 47
  • 68
Gab
  • 1
  • 2
  • Why did you remove your sample data? A screenshot is *always* a bad idea, as we can't copy and paste data. – Maurits Evers Jan 16 '19 at 11:24
  • Disease days AA 7 AA 5 AA 5 AA 15 AA 4 AA 15 AA 5 AA 7 BB 4 BB 3 BB 11 BB 6 BB 12 BB 6 BB 9 BB 20 BB 4 BB 2 – Gab Jan 16 '19 at 11:25
  • I had no option to add datafile so added an image. – Gab Jan 16 '19 at 11:26
  • @Gab Don't add data/code in comments. I've reversed your edit to include the original data as text (which is one of the preferred ways of sharing data around here). For future posts, please review how to provide a [minimal & reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Maurits Evers Jan 16 '19 at 11:27
  • @MauritsEvers, thanks for your suggestions. I will not add data in the comment section. – Gab Jan 16 '19 at 11:33

1 Answers1

0

You could do something like this

library(tidyverse)
df %>%
    group_by(Disease, days) %>%
    summarise(Freq = n()) %>%
    ggplot(aes(days, Freq, colour = Disease)) +
    geom_line()

enter image description here


Sample data

df <- read.table(text =
    "Disease days
AA  7
AA  5
AA  5
AA  15
AA  4
AA  15
AA  5
AA  7
BB  4
BB  3
BB  11
BB  6
BB  12
BB  6
BB  9
BB  20
BB  4
BB  2", header = T)
Maurits Evers
  • 49,617
  • 4
  • 47
  • 68