0
    ############ uncoded data
   x10<- structure(c(0L, 0L, 0L, 0L, 1L, 1L, 1L, 5L, 8L, 9L, 31L, 1L, 
    0L, 0L, 0L, 1L, 0L, 1L, 2L, 7L, 2L, 10L, 0L, 2L, 0L, 2L, 2L, 
    5L, 2L, 4L, 6L, 8L, 4L, 1L, 1L, 3L, 2L, 2L, 6L, 1L, 12L, 18L, 
    7L, 29L, 8L, 4L, 6L, 8L, 6L, 19L, 3L, 9L, 12L, 3L, 12L, 14L, 
    1L, 2L, 1L, 3L, 1L, 0L, 4L, 6L, 3L, 11L, 0L, 0L, 0L, 1L, 3L, 
    7L, 5L, 8L, 21L, 26L, 51L, 0L, 1L, 0L, 3L, 5L, 10L, 9L, 29L, 
    55L, 60L, 125L, 3L, 0L, 1L, 1L, 3L, 10L, 1L, 6L, 18L, 17L, 13L, 
    6L, 3L, 4L, 13L, 6L, 33L, 17L, 48L, 84L, 54L, 103L, 34L, 11L, 
    20L, 27L, 26L, 50L, 29L, 30L, 54L, 28L, 34L, 31L, 5L, 7L, 3L, 
    4L, 20L, 8L, 16L, 16L, 8L, 41L, 1L, 0L, 0L, 3L, 1L, 3L, 3L, 11L, 
    19L, 16L, 56L, 0L, 0L, 0L, 0L, 3L, 11L, 3L, 18L, 25L, 21L, 62L, 
    3L, 0L, 1L, 4L, 2L, 7L, 8L, 15L, 22L, 12L, 19L, 5L, 2L, 8L, 9L, 
    9L, 42L, 18L, 51L, 70L, 45L, 103L, 29L, 15L, 23L, 34L, 25L, 57L, 
    23L, 38L, 55L, 30L, 33L, 36L, 5L, 5L, 6L, 6L, 16L, 6L, 10L, 17L, 
    9L, 35L, 2L, 0L, 1L, 1L, 2L, 4L, 6L, 8L, 22L, 33L, 73L, 0L, 0L, 
    0L, 1L, 2L, 7L, 7L, 15L, 27L, 21L, 56L, 1L, 2L, 2L, 0L, 2L, 9L, 
    4L, 8L, 24L, 13L, 17L, 14L, 2L, 8L, 10L, 16L, 51L, 16L, 51L, 
    69L, 29L, 99L, 44L, 18L, 25L, 34L, 19L, 49L, 26L, 43L, 63L, 15L, 
    30L, 42L, 9L, 17L, 7L, 3L, 16L, 8L, 13L, 22L, 18L, 45L, 0L, 0L, 
    1L, 3L, 0L, 7L, 4L, 14L, 15L, 20L, 47L, 0L, 1L, 0L, 1L, 1L, 3L, 
    3L, 5L, 6L, 11L, 21L, 1L, 0L, 0L, 4L, 2L, 3L, 8L, 7L, 17L, 3L, 
    13L, 5L, 2L, 6L, 13L, 15L, 34L, 19L, 42L, 62L, 37L, 83L, 52L, 
    16L, 26L, 26L, 29L, 53L, 28L, 45L, 45L, 15L, 22L, 26L, 8L, 12L, 
    11L, 5L, 12L, 5L, 7L, 17L, 10L, 28L), .Dim = c(11L, 6L, 5L), .Dimnames = structure(list(
        c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), 
        c("I've changed for work/ a new job/ gone on a work plan", 
        "I want a phone that doesn't offer", "I want Best Mates/ Favourites", 
        "I was offered or saw a better offer on another network", 
        "Issues with the network (poor coverage)", "Other"
        ), YearQuarter = c("2011-09-01", "2011-12-01", "2012-03-01", 
        "2012-06-01", "2012-09-01")), .Names = c("", "", "YearQuarter"
    )), class = "table")  

############ recoded data
 x10 <- structure(c(40L, 3L, 13L, 12L, 3L, 9L, 12L, 13L, 10L, 36L, 16L, 
    30L, 15L, 54L, 21L, 14L, 22L, 10L, 77L, 16L, 29L, 185L, 28L, 
    84L, 30L, 19L, 24L, 157L, 82L, 132L, 62L, 197L, 84L, 49L, 78L, 
    32L, 72L, 11L, 30L, 83L, 17L, 43L, 31L, 25L, 37L, 148L, 93L, 
    121L, 63L, 206L, 93L, 44L, 80L, 27L, 106L, 16L, 30L, 77L, 17L, 
    42L, 30L, 20L, 32L, 128L, 117L, 120L, 45L, 215L, 106L, 63L, 102L, 
    35L, 67L, 15L, 29L, 32L, 9L, 11L, 16L, 18L, 24L, 120L, 94L, 104L, 
    37L, 230L, 90L, 38L, 79L, 24L), .Dim = c(3L, 6L, 5L), .Dimnames = structure(list(
        c("Promoters", "Detractors", "Passive"), c("I've changed for work/ a new job/ gone on a work plan", 
        "I want a phone that doesn't offer", "I want Best Mates/ Favourites", 
        "I was offered or saw a better offer on another network", 
        "Issues with the network (poor coverage)", "Other"
        ), YearQuarter = c("2011-09-01", "2011-12-01", "2012-03-01", 
        "2012-06-01", "2012-09-01")), .Names = c("", "", "YearQuarter"
    )), class = "table") 


    x10.p <- round(prop.table(x10,c(3,2)),2)*100

你好呀

净促销分数是一个要求消费者以零到十的等级对“推荐产品或服务的可能性”进行评分的问题。被报告为 10 和 9 的人被称为“促进者”,被评为 8 和 7 的人被视为“被动”,被报告低于 6 的人被视为诋毁者。净促销分数是“推荐者”百分比减去“批评者”百分比之间的差值。

从 2011 年 9 月到 2012 年 9 月,我将问题的答案汇总并重新编码到 x10 表中。这些数字是每个组的实际人数(促进者、批评者和被动者)。为三个维度表道歉,我对每个原因的净推荐值感兴趣(即推荐者和批评者之间的百分比差异是多少“我已经换工作/新工作/继续工作计划”在 9 月2012 年。

在我可以绘制它之前的净促销分数,这需要一些操作。我想知道是否有人知道如何做到这一点?

干杯

4

1 回答 1

1

首先,在完成所有计算之前不要四舍五入(否则你的百分比不会加到 1)

x10.p <- prop.table(x10,c(3,2))*100

# get the total promoters
promoters <- apply(x10.p, 2:3, function(x) sum(tail(x,2)))
# and detractors
detractors <- apply(x10.p, 2:3, function(x) sum(head(x,7)))
# passive is everything else
passive  <- passive <- 100 - (detractors +promoters)
# the net score
net <- promoters - detractors

net

                                                       YearQuarter
                                                         2011-09-01 2011-12-01 2012-03-01 2012-06-01 2012-09-01
  I've changed for work/ a new job/ gone on a work plan   66.071429   50.00000  53.982301  59.210526  46.846847
  I want a phone that doesn't offer                       37.500000   52.86195  46.153846  44.117647  44.230769
  I want Best Mates/ Favourites                           -2.857143   15.06849   6.451613  12.195122  -3.448276
  I was offered or saw a better offer on another network  24.390244   20.21563  15.193370   3.013699   8.176101
  Issues with the network (poor coverage)                -43.333333  -39.35860 -39.502762 -46.448087 -54.061625
  Other                                                  -17.391304  -18.23899 -23.841060 -19.500000 -29.078014

您想要 2012 年 9 月,只选择该列,drop = FALSE以确保它仍然是一个包含 1 列的矩阵。

net[,'2012-09-01', drop = FALSE]
                                                        YearQuarter
                                                         2012-09-01
  I've changed for work/ a new job/ gone on a work plan   46.846847
  I want a phone that doesn't offer                       44.230769
  I want Best Mates/ Favourites                           -3.448276
  I was offered or saw a better offer on another network   8.176101
  Issues with the network (poor coverage)                -54.061625
  Other                                                  -29.078014
于 2012-11-06T02:18:45.767 回答