r - Plotting densities with a summary data frame
问题描述
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.
解决方案
推荐阅读
- javascript - Nuxt如何传递多个参数?
- groovy - katalon / groovy if 元素不存在 else 语句
- algorithm - 请建议一种算法来比较格雷码数
- vba - application.ontime vba 传递变量
- html - 订购 Bootstrap div
- c++ - 如何在 C++ 项目中编写着色器源代码?
- node.js - 如何在 Node.js 中通过 Postfix 邮件服务器发送消息?
- java - 如何更改 2d ArrayList 中某些 ArrayList 的大小?
- arrays - 在kotlin中将字符串类型转换为ByteArray
- java - 对象之间的 Java OOP 功能