0

I have data from a bicycle rental service in NYC for a quarter. I have two user types - Customers and Subscribers and have created a variable called trip.type which can be "long", "avg" or "short". I created a summary data frame that has the counts for trip.type by user.type. However, we have far more subscribers than customers. So I would like to look at a density / percentage plot vs. just raw counts. How do I do this? Thank you so much. I am using ggplot2. Also, am a newbie, so sorry if this is too elementary a question.

DF <- data.frame(User.Type = rep(c("Unknown", "Customer", "Subscriber"), each = 4),
                 trip.type = rep(c("Avg", "long", "Short", "Unknown"), 3),
                 num_trips = c(891, 3817, 31, 77, 4123, 20888, 1378, 388, 266299, 225671, 203048, 734))

What I want is to plot the trip.types as percentages of the total number of users per User.Type instead of counts.

Seema
  • 71
  • 1
  • 7
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Pictures of data aren't helpful because we can't copy/paste it into R. – MrFlick Apr 21 '20 at 15:26
  • I just edited my original post to be more helpful / reproducible hopefully. – Seema Apr 21 '20 at 18:37
  • The sample data looks good, now I'm just not quite sure what the desired result is. Have you tried to plot it at all yet? If so what exactly isn't working for you? – MrFlick Apr 21 '20 at 18:41
  • Yes, I did manage to plot it. What i wanted was to plot the densities / percentages of the different trip types for each user type. I couldn't do it through a single line of code but was able to do it by creating a new percentage variable. Thank you for the help. – Seema Apr 22 '20 at 16:16

0 Answers0