简体   繁体   English

R中的茎叶图带有十进制数字

[英]stem and leaf plot in R with decimal numbers

I have a problem with the stem- and leaf-plot-function. 我的茎图和叶图功能有问题。 One example: I want to stem the correlation coefficients of my meta-analysis. 一个例子:我想阻止我的荟萃分析的相关系数。 Here I have just 2 correlation coefficients (0,056 and -0,022). 在这里,我只有2个相关系数(0,056和-0,022)。 I tried the following function: 我尝试了以下功能:

y<-c(0.056, -0.022)
stem(y)

and I get the following result: 我得到以下结果:

   -2 | 2
   -0 | 
    0 | 
    2 | 
    4 | 6

but thats not the right result, it has to be: 但这不是正确的结果,它必须是:

    0 | 6
   -0 | 2 

So I don't understand which function I have to use to get the right result. 因此,我不明白必须使用哪个功能才能获得正确的结果。 I would be realy thankful if somebody could help me! 如果有人可以帮助我,我将非常感激!

Check out help(stem) and change the scale parameter to control the length of stem plot: 签出help(stem)并更改scale参数以控制茎图的长度:

R > stem(y, scale = 2)

  The decimal point is 2 digit(s) to the left of the |

  -2 | 2
  -1 | 
  -0 | 
   0 | 
   1 | 
   2 | 
   3 | 
   4 | 
   5 | 6

Does that make more sense? 这更有意义吗?

The closest I get to your output is: 我最接近您的输出是:

stem(y, scale=0.5, atom=0.1)

But it has the negative at the top instead of the bottom. 但它在顶部而不是底部具有负数。

The first one that you show is a correct answer (the 0.04 and 0.05 stems are grouped together) even if not the desired answer. 您显示的第一个答案是正确的答案(0.04和0.05的词干被分组在一起),即使不是所需的答案也是如此。

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

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