要创建一些图,我已经使用以下方法汇总了我的数据,其中包括所有需要的信息。取决于矢量的订单清单
# Load Data
RawDataSet <- read.csv("http://pastebin.com/raw/VP6cF31A", sep=";")
# Load packages
library(plyr)
library(dplyr)
library(tidyr)
library(ggplot2)
library(reshape2)
# summarising the data
new.df <- RawDataSet %>%
group_by(UserEmail,location,context) %>%
tally() %>%
mutate(n2 = n * c(1,-1)[(location=="NOT_WITHIN")+1L]) %>%
group_by(UserEmail,location) %>%
mutate(p = c(1,-1)[(location=="NOT_WITHIN")+1L] * n/sum(n))
通过一些其他分析,我确定了不同的用户组。由于我想绘制我的数据,因此将绘图以正确的顺序显示我的数据会很棒。 的顺序是根据USEREMAIL和由以下定义:
order <- c("28","27","25","23","22","21","20","16","12","10","9","8","5","4","2","1","29","19","17","15","14","13","7","3","30","26","24","18","11","6")
问我new.df
与typeof(new.df)
的类型,它说,这是一个list
。我已经尝试了一些方法,如order_by或with_order,但我直到现在我还没有设法订购我的new.df
,这取决于我的order
-vector。当然,订单流程也可以在汇总部分完成。 有没有办法做到这一点?
只是'dplyr :: arrange'。 'typeof' data.frame是一个列表(它在技术上是); 'class'告诉你它是否实际上是一个'data.frame'。 – alistaire