Domanda

I have the results from a describe.by{psych} applied on a dataframe. The results is a list.

List of 1000
 $ 1   :Classes ‘psych’, ‘describe’ and 'data.frame':   20 obs. of  13 variables:
  ..$ var     : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  ..$ n       : num [1:20] 24 24 24 24 24 24 24 24 24 24 ...
  ..$ mean    : num [1:20] 24 30.8 24 31.6 240 ...
  ..$ sd      : num [1:20] 0.937 3.667 0.937 3.537 9.367 ...
  ..$ median  : num [1:20] 23.9 31 23.9 31.9 238.6 ...
  ..$ trimmed : num [1:20] 24 30.9 24 31.7 239.7 ...
  ..$ mad     : num [1:20] 1.11 4.12 1.11 3.29 11.09 ...
  ..$ min     : num [1:20] 22.6 24 22.6 25.3 225.9 ...
  ..$ max     : num [1:20] 25.6 36.9 25.6 36.9 256 ...
  ..$ range   : num [1:20] 3 12.9 3 11.6 30 ...
  ..$ skew    : num [1:20] 0.309 -0.258 0.309 -0.411 0.309 ...
  ..$ kurtosis: num [1:20] -1.163 -0.898 -1.163 -0.819 -1.163 ...
  ..$ se      : num [1:20] 0.191 0.749 0.191 0.722 1.912 ...
 $ 2   :Classes ‘psych’, ‘describe’ and 'data.frame':   20 obs. of  13 variables:
  ..$ var     : int [1:20] 1 2 3 4 5 6 7 8 9 10 ...
  ..$ n       : num [1:20] 7 7 7 7 7 7 7 7 7 7 ...
  ..$ mean    : num [1:20] 16.3 39.3 16.3 40.7 162.9 ...
  ..$ sd      : num [1:20] 0.609 8.045 0.609 8.394 6.086 ...
  ..$ median  : num [1:20] 16.4 39.1 16.4 39.6 164.2 ...
  ..$ trimmed : num [1:20] 16.3 39.3 16.3 40.7 162.9 ...

I would like to plot a graph ( probably candlestick) or boxplots with this sample for each of the 13 metrics. Is there a package in which I can directly leverage the summary stats computed ?

È stato utile?

Soluzione

You question is vague.

describeBy( describe.by is deprecated) , Report basic summary statistics by a grouping variable. So I guess that a boxplot it is the nearest plot.

For example :

describeBy(sat.act,sat.act$gender) 
group: 1
          var   n   mean     sd median trimmed    mad min max range  skew kurtosis   se
gender      1 247   1.00   0.00      1    1.00   0.00   1   1     0   NaN      NaN 0.00
education   2 247   3.00   1.54      3    3.12   1.48   0   5     5 -0.54    -0.60 0.10
age         3 247  25.86   9.74     22   24.23   5.93  14  58    44  1.43     1.43 0.62
ACT         4 247  28.79   5.06     30   29.23   4.45   3  36    33 -1.06     1.89 0.32
SATV        5 247 615.11 114.16    630  622.07 118.61 200 800   600 -0.63     0.13 7.26
SATQ        6 245 635.87 116.02    660  645.53  94.89 300 800   500 -0.72    -0.12 7.41
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
group: 2
          var   n   mean     sd median trimmed    mad min max range  skew kurtosis   se
gender      1 453   2.00   0.00      2    2.00   0.00   2   2     0   NaN      NaN 0.00
education   2 453   3.26   1.35      3    3.40   1.48   0   5     5 -0.74     0.27 0.06
age         3 453  25.45   9.37     22   23.70   5.93  13  65    52  1.77     3.03 0.44
ACT         4 453  28.42   4.69     29   28.63   4.45  15  36    21 -0.39    -0.42 0.22
SATV        5 453 610.66 112.31    620  617.91 103.78 200 800   600 -0.65     0.42 5.28
SATQ        6 442 596.00 113.07    600  602.21 133.43 200 800   600 -0.58     0.13 5.38
> 

You can plot this like :

boxplot(sat.act,sat.act$gender, col ='pink')

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top