为什么没有geom_boxplot()的输出?

时间:2022-06-15 13:06:46

I am trying to plot a box plot for the data frame below. Running the code below seems doesn't work, there is no output at all. After running

我正在为下面的数据框绘制一个框图。运行下面的代码似乎不起作用,根本没有输出。在运行

ggplot(aes(time, size)) +

somehow the dataframe was changed to a list. Anyone helps?

不知何故,dataframe被改为list。有人帮助吗?

SUBJECTID   Baseline    1   2   3
1001        88          78  30  14
1002        29          26  66  16
1003        50          64  54  46
1004        91          90  99  43
1005        98          109 60  42
1007        100         100     54
1008        45          49  47  32
1009        75          66  57  7
1010        60          52  20  3
1011        68          68  56  47
1012        78          84  56  57
1013        71          70  8   5
1015        79          50  11  3
1016        73          60  57  36
1017        54          27  16
1018        50          37  33  26
1019        115         68  33  67
1021        63          55  0   0
1022        98          91  76  75
1024        76          76      0
1025        47          45  42  42
1026        32          25  14  0
1027        40          37  65  
1028        60          110 110 0

tumor.df <- clinical %>%
  select(SUBJECTID, `MRI LD Baseline`,`MRI LD 1-3dAC`,
        `MRI LD InterReg`,`MRI LD PreSurg`) %>%
  rename(baseline = 'MRI LD Baseline', t1 = 'MRI LD 1-3dAC', 
         t2 = 'MRI LD InterReg', t3 = 'MRI LD PreSurg') %>%
  gather(time, size, baseline : t3) %>%
  ggplot(aes(time, size)) +
  geom_boxplot()

1 个解决方案

#1


2  

This is the output I get from the following code:

这是我从以下代码中得到的输出:

clinical <- read.table(text="
SUBJECTID   baseline    t1  t2  t3
1001        88          78  30  14
1002        29          26  66  16
1003        50          64  54  46
1004        91          90  99  43
1005        98          109 60  42
1007        100         100 NA  54
1008        45          49  47  32
1009        75          66  57  7
1010        60          52  20  3
1011        68          68  56  47
1012        78          84  56  57
1013        71          70  8   5
1015        79          50  11  3
1016        73          60  57  36
1017        54          27  16  NA
1018        50          37  33  26
1019        115         68  33  67
1021        63          55  0   0
1022        98          91  76  75
1024        76          76  NA    0
1025        47          45  42  42
1026        32          25  14  0
1027        40          37  65  NA
1028        60          110 110 0
", header=T)

library(ggplot2)
library(tidyr)
library(plyr)

clinical %>%
  rename(c(baseline = 'MRI LD Baseline', t1 = 'MRI LD 1-3dAC', 
         t2 = 'MRI LD InterReg', t3 = 'MRI LD PreSurg')) %>%
  gather(time, size, 'MRI LD Baseline':'MRI LD PreSurg')  %>%
  mutate(time  = factor(time, levels=unique(time)))  %>%
  ggplot(aes(time, size)) +
  geom_boxplot()

为什么没有geom_boxplot()的输出?

#1


2  

This is the output I get from the following code:

这是我从以下代码中得到的输出:

clinical <- read.table(text="
SUBJECTID   baseline    t1  t2  t3
1001        88          78  30  14
1002        29          26  66  16
1003        50          64  54  46
1004        91          90  99  43
1005        98          109 60  42
1007        100         100 NA  54
1008        45          49  47  32
1009        75          66  57  7
1010        60          52  20  3
1011        68          68  56  47
1012        78          84  56  57
1013        71          70  8   5
1015        79          50  11  3
1016        73          60  57  36
1017        54          27  16  NA
1018        50          37  33  26
1019        115         68  33  67
1021        63          55  0   0
1022        98          91  76  75
1024        76          76  NA    0
1025        47          45  42  42
1026        32          25  14  0
1027        40          37  65  NA
1028        60          110 110 0
", header=T)

library(ggplot2)
library(tidyr)
library(plyr)

clinical %>%
  rename(c(baseline = 'MRI LD Baseline', t1 = 'MRI LD 1-3dAC', 
         t2 = 'MRI LD InterReg', t3 = 'MRI LD PreSurg')) %>%
  gather(time, size, 'MRI LD Baseline':'MRI LD PreSurg')  %>%
  mutate(time  = factor(time, levels=unique(time)))  %>%
  ggplot(aes(time, size)) +
  geom_boxplot()

为什么没有geom_boxplot()的输出?