简体   繁体   English

R相关分数计算

[英]R correlation score calculation

My dataset contains information such as feedbackDate and Subcategory(issue) and location (6 months data). 我的数据集包含诸如feedbackDate和Subcategory(问题)和位置(6个月数据)之类的信息。 The temporal calculation was by cross tabulating the subcategory of issues with their feebackDate s and then calculating Pearson correlation score for every pair of cross tabulated issues. 时间计算是通过将问题的子类别与其feebackDate交叉列表,然后为每对交叉列表问题计算Pearson相关评分。 See the code below 见下面的代码

#weekly correlation
require(ISOweek)
datacfs_date$FeedbackWeek <- ISOweek(datacfs_date$FeedbackDate)
raw_timecor_matrix <- table(datacfs_date$SubCategory, datacfs_date$FeedbackWeek)
raw_timecor_matrix <- t(raw_timecor_matrix)
timecor_matrix <- cor(raw_timecor_matrix)

#Invert correlation to get distance matrix
inverse_tcc <- 1-timecor_matrix

Now the question is how do I calculate this on biweekly and monthly basis instead of weekly correlation of six months data. 现在的问题是,我该如何每两周和每月计算一次,而不是六个月数据的每周相关性。

Just make your labels, eg 只需制作标签,例如

datacfs_date$FeedbackMonth<-paste0(year(datacfs_date$FeedbackDate),"-M",month(datacfs_date$FeedbackDate))

datacfs_date$FeedbackBiWeek<-paste0(year(datacfs_date$FeedbackDate),"-W",(ceiling(week(datacfs_date$FeedbackDate)/2)*2)-1,":",(ceiling(week(datacfs_date$FeedbackDate)/2)*2))

and correlate on those 并关联那些

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM