-1

I am using the twitter sentiment analysis for airline flights dataset and It has a column called negative result and another column called airline name. I need to know how to count the repetitions of the value "Bad Flight" in the column negative result Where the airline name is "Virgin America" and repeat this step for "Late Flight" and "Virgin America" and then compare between values and choose the bigger number and use it in plotting.

for example :

Negative Result Airline Name

Bad Flight Virgin America

Bad Flight Virgin America

Bad Flight Virgin America

Late Flight Virgin America

Late Flight Virgin America

Bad Flight United

Damaged Luggage United

Bad Flight United

Late Flight United

Late Flight United

Bad Flight Virgin America

Bad Flight Virgin America

Late Flight Virgin America

expected output will be 5 for bad flight and 3 for late flight so after comparing, bad flight will be the value to be plotted.

dooo2710
  • 1
  • 1
  • Please, see it. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – bbiasi May 07 '19 at 21:36

1 Answers1

0

If your dataframe is called df you can just do table(df).

Using dplyr:

library(dplyr)
df %>% 
  filter(`Airline Name` == "Virgin America") %>% 
  group_by(`Negative Result`) %>% 
  summarize(n = n())
c1au61o_HH
  • 867
  • 7
  • 14