如何删除interaction.plot()

时间:2017-01-21 01:33:02

标签: r

示例:

df <- data.frame(ID = rep(1:6, each = 3), 
                 grp = LETTERS[rep(1:3, each = 6)], 
                 test = rep(c("T1", "T2", "T3"), 6), 
                 score = sample(1:100, 18))

以上数据集如下所示:

    ID grp test score
1   1   A   T1    45
2   1   A   T2     6
3   1   A   T3    98
4   2   A   T1    40
5   2   A   T2    62
6   2   A   T3    38
7   3   B   T1    81
8   3   B   T2    30
9   3   B   T3    58
10  4   B   T1     5
11  4   B   T2    57
12  4   B   T3    71
13  5   C   T1    68
14  5   C   T2    44
15  5   C   T3    72
16  6   C   T1     8
17  6   C   T2    50
18  6   C   T3    83

我想按小组制作每个考试成绩的平均值。

interaction.plot(df$test, df$grp, df$score) # this works 

现在我想修改情节,只是为了保持T2和T3的分数

    interaction.plot(df[df$test != "T1", ]$test, 
                 df[df$test != "T1", ]$grp, 
                 df[df$test != "T1", ]$score) 
# this prints out what I want but how to get rid of T1 in the x axis???

enter image description here

0 个答案:

没有答案