How to reproduce a table of student? [closed]

enter image description here

I have to produce a document that looks as much like this student chart as possible using in particular the "outer" function, but I don't know how to do that.


Solution 1:

Something like

x <- 1:20; names(x) <-x
y <- c(0.05, 0.025, 0.01, 0.005, 0.001, 0.0005); names(y) <- y
outer(x, y,function(x, y) {abs(qt(y, df=x))})
#>        0.05     0.025      0.01     0.005      0.001      5e-04
#> 1  6.313752 12.706205 31.820516 63.656741 318.308839 636.619249
#> 2  2.919986  4.302653  6.964557  9.924843  22.327125  31.599055
#> 3  2.353363  3.182446  4.540703  5.840909  10.214532  12.923979
#> 4  2.131847  2.776445  3.746947  4.604095   7.173182   8.610302
#> 5  2.015048  2.570582  3.364930  4.032143   5.893430   6.868827
#> 6  1.943180  2.446912  3.142668  3.707428   5.207626   5.958816
#> 7  1.894579  2.364624  2.997952  3.499483   4.785290   5.407883
#> 8  1.859548  2.306004  2.896459  3.355387   4.500791   5.041305
#> 9  1.833113  2.262157  2.821438  3.249836   4.296806   4.780913
#> 10 1.812461  2.228139  2.763769  3.169273   4.143700   4.586894
#> 11 1.795885  2.200985  2.718079  3.105807   4.024701   4.436979
#> 12 1.782288  2.178813  2.680998  3.054540   3.929633   4.317791
#> 13 1.770933  2.160369  2.650309  3.012276   3.851982   4.220832
#> 14 1.761310  2.144787  2.624494  2.976843   3.787390   4.140454
#> 15 1.753050  2.131450  2.602480  2.946713   3.732834   4.072765
#> 16 1.745884  2.119905  2.583487  2.920782   3.686155   4.014996
#> 17 1.739607  2.109816  2.566934  2.898231   3.645767   3.965126
#> 18 1.734064  2.100922  2.552380  2.878440   3.610485   3.921646
#> 19 1.729133  2.093024  2.539483  2.860935   3.579400   3.883406
#> 20 1.724718  2.085963  2.527977  2.845340   3.551808   3.849516

Created on 2022-01-23 by the reprex package (v2.0.1)

Please extend x to desired length then use any fancy table style for styling.

Solution 2:

Basicly, we can produce the T table by using qt and qnorm.

y <- c(0.05, 0.025, 0.01, 0.005, 0.001, 0.0005)
x <- c(1:30,seq(32,50,by=2),seq(60,100,by=10),120,150,seq(200,600,by=100))
t=outer(x, y,function(x, y) {abs(qt(y, df=x))})
r=-qnorm(y)
table<-rbind(t,r)
colnames(table)<-y
rownames(table)<-c(x,"inf")
table

And the result will be like:

> table
        0.05     0.025      0.01     0.005      0.001      5e-04
1   6.313752 12.706205 31.820516 63.656741 318.308839 636.619249
2   2.919986  4.302653  6.964557  9.924843  22.327125  31.599055
3   2.353363  3.182446  4.540703  5.840909  10.214532  12.923979
4   2.131847  2.776445  3.746947  4.604095   7.173182   8.610302
5   2.015048  2.570582  3.364930  4.032143   5.893430   6.868827
6   1.943180  2.446912  3.142668  3.707428   5.207626   5.958816
7   1.894579  2.364624  2.997952  3.499483   4.785290   5.407883
8   1.859548  2.306004  2.896459  3.355387   4.500791   5.041305
9   1.833113  2.262157  2.821438  3.249836   4.296806   4.780913
10  1.812461  2.228139  2.763769  3.169273   4.143700   4.586894
11  1.795885  2.200985  2.718079  3.105807   4.024701   4.436979
12  1.782288  2.178813  2.680998  3.054540   3.929633   4.317791
13  1.770933  2.160369  2.650309  3.012276   3.851982   4.220832
14  1.761310  2.144787  2.624494  2.976843   3.787390   4.140454
15  1.753050  2.131450  2.602480  2.946713   3.732834   4.072765
16  1.745884  2.119905  2.583487  2.920782   3.686155   4.014996
17  1.739607  2.109816  2.566934  2.898231   3.645767   3.965126
18  1.734064  2.100922  2.552380  2.878440   3.610485   3.921646
19  1.729133  2.093024  2.539483  2.860935   3.579400   3.883406
20  1.724718  2.085963  2.527977  2.845340   3.551808   3.849516
21  1.720743  2.079614  2.517648  2.831360   3.527154   3.819277
22  1.717144  2.073873  2.508325  2.818756   3.504992   3.792131
23  1.713872  2.068658  2.499867  2.807336   3.484964   3.767627
24  1.710882  2.063899  2.492159  2.796940   3.466777   3.745399
25  1.708141  2.059539  2.485107  2.787436   3.450189   3.725144
26  1.705618  2.055529  2.478630  2.778715   3.434997   3.706612
27  1.703288  2.051831  2.472660  2.770683   3.421034   3.689592
28  1.701131  2.048407  2.467140  2.763262   3.408155   3.673906
29  1.699127  2.045230  2.462021  2.756386   3.396240   3.659405
30  1.697261  2.042272  2.457262  2.749996   3.385185   3.645959
32  1.693889  2.036933  2.448678  2.738481   3.365306   3.621802
34  1.690924  2.032245  2.441150  2.728394   3.347934   3.600716
36  1.688298  2.028094  2.434494  2.719485   3.332624   3.582150
38  1.685954  2.024394  2.428568  2.711558   3.319030   3.565678
40  1.683851  2.021075  2.423257  2.704459   3.306878   3.550966
42  1.681952  2.018082  2.418470  2.698066   3.295951   3.537745
44  1.680230  2.015368  2.414134  2.692278   3.286072   3.525801
46  1.678660  2.012896  2.410188  2.687013   3.277098   3.514957
48  1.677224  2.010635  2.406581  2.682204   3.268910   3.505068
50  1.675905  2.008559  2.403272  2.677793   3.261409   3.496013
60  1.670649  2.000298  2.390119  2.660283   3.231709   3.460200
70  1.666914  1.994437  2.380807  2.647905   3.210789   3.435015
80  1.664125  1.990063  2.373868  2.638691   3.195258   3.416337
90  1.661961  1.986675  2.368497  2.631565   3.183271   3.401935
100 1.660234  1.983972  2.364217  2.625891   3.173739   3.390491
120 1.657651  1.979930  2.357825  2.617421   3.159539   3.373454
150 1.655076  1.975905  2.351465  2.609003   3.145453   3.356569
200 1.652508  1.971896  2.345137  2.600634   3.131480   3.339835
300 1.649949  1.967903  2.338842  2.592316   3.117620   3.323252
400 1.648672  1.965912  2.335706  2.588176   3.110731   3.315015
500 1.647907  1.964720  2.333829  2.585698   3.106612   3.310091
600 1.647397  1.963926  2.332579  2.584048   3.103871   3.306816
inf 1.644854  1.959964  2.326348  2.575829   3.090232   3.290527