Quantcast
Viewing all articles
Browse latest Browse all 4448

Best Visualisation for 2D contingency table using ggplot2?

@ashish25sahu wrote:

I have a data.frame which explains Most popular method of payment based on hour of the day.

Hour <- c("10,11,12,13,14,15,16,17,18")
Cash <- c("11796,11803,11941,11665,11869,11804,11731,11821,198")
CreditCard <- c("19891,19912,19843,19708,19802,19940,19800,19939,379")
DebitCard <- c("11940,11927,11872,12075,11922,12168,12055,12219,221")

df <- data.frame("Hour", "Cash,", "CreditCard", "DebitCard")

I'm trying to see the pattern of spending method against hour of the day.
Best appropriate way to visualize this using ggplot2 bar/line/density? Please mention the code

xtabs(data = df, formula = ~Hour + Payment_Method, exclude = NA)

Hour  Cash   CreditCard  DebitCard
  10    11796      19891     11940
  11    11803      19912     11927
  12    11941      19843     11872
  13    11665      19708     12075
  14    11869      19802     11922
  15    11804      19940     12168
  16    11731      19800     12055
  17    11821      19939     12219
  18    198        379       221

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles