简体   繁体   中英

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). 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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