我对 R 茎叶图有几个基本问​​题

数据挖掘 r
2022-03-04 16:09:18

我绘图时的这些数据 -60 85 72 59 37 75 93 7 98 63 41 90 5 17 97

stem(data)

 0 | 577
 2 | 7
 4 | 19
 6 | 0325
 8 | 50378

现在,如果我重建数据,它是5, 7, 7, 27, 60, 63, 62, 65, 85, 80, 83, 87,88

这不会产生反向输入。

2个回答

使用默认比例,您会看到条形左侧的数字增加了 2 - 因此 4 之后的任何数字都是 40 或 50 :

> stem(d,scale=1)

  The decimal point is 1 digit(s) to the right of the |

  0 | 577
  2 | 7
  4 | 19
  6 | 0325
  8 | 50378

使用scale=2,您将看到条形左侧的数字增加一,因此现在您可以精确重建输入,因为您输入了整数:

> stem(d,scale=2)

  The decimal point is 1 digit(s) to the right of the |

  0 | 57
  1 | 7
  2 | 
  3 | 7
  4 | 1
  5 | 9
  6 | 03
  7 | 25
  8 | 5
  9 | 0378

更进一步,您甚至可以在每十年内将其分成前五和后五:

> stem(d,scale=4)

  The decimal point is 1 digit(s) to the right of the |

  0 | 57
  1 | 
  1 | 7
  2 | 
  2 | 
  3 | 
  3 | 7
  4 | 1
  4 | 
  5 | 
  5 | 9
  6 | 03
  6 | 
  7 | 2
  7 | 5
  8 | 
  8 | 5
  9 | 03
  9 | 78

茎图并不总是保证您可以通过反转过程来重现数据,这不是它们的用途。

试试这个 S=c(60, 85, 72, 59, 37, 75, 93, 7, 98, 63, 41, 90 ,5 ,17 ,97) ;stem(S,scale = 2) a value of scale = 2 将导致绘图大约是默认值的两倍。