Veiledning i SSBpris
Anne Vedø
2024-05-28
SSBpris-vignette.Rmd
Vignettes are long form documentation commonly included in packages.
Because they are part of the distribution of the package, they need to
be as compact as possible. The html_vignette
output type
provides a custom style sheet (and tweaks some options) to ensure that
the resulting html is as small as possible. The
html_vignette
format:
- Never uses retina figures
- Has a smaller default figure size
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style
Vignette Info
Note the various macros within the vignette
section of
the metadata block above. These are required in order to instruct R how
to build the vignette. Note that you should change the
title
field and the \VignetteIndexEntry
to
match the title of your vignette.
Styles
The html_vignette
template includes a basic CSS theme.
To override this theme you can specify your own CSS in the document
metadata as follows:
output:
rmarkdown::html_vignette:
css: mystyles.css
Figures
The figure sizes have been customised so that you can easily put two images side-by-side.
You can enable figure captions by fig_caption: yes
in
YAML:
output:
rmarkdown::html_vignette:
fig_caption: yes
Then you can use the chunk option
fig.cap = "Your figure caption."
in
knitr.
More Examples
You can write math expressions, e.g. \(Y =
X\beta + \epsilon\), footnotes1, and tables, e.g. using
knitr::kable()
.
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | |
---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21.0 | 6 | 160.0 | 110 | 3.90 | 2.620 | 16.46 | 0 | 1 | 4 | 4 |
Mazda RX4 Wag | 21.0 | 6 | 160.0 | 110 | 3.90 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
Datsun 710 | 22.8 | 4 | 108.0 | 93 | 3.85 | 2.320 | 18.61 | 1 | 1 | 4 | 1 |
Hornet 4 Drive | 21.4 | 6 | 258.0 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 |
Hornet Sportabout | 18.7 | 8 | 360.0 | 175 | 3.15 | 3.440 | 17.02 | 0 | 0 | 3 | 2 |
Valiant | 18.1 | 6 | 225.0 | 105 | 2.76 | 3.460 | 20.22 | 1 | 0 | 3 | 1 |
Duster 360 | 14.3 | 8 | 360.0 | 245 | 3.21 | 3.570 | 15.84 | 0 | 0 | 3 | 4 |
Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.190 | 20.00 | 1 | 0 | 4 | 2 |
Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.150 | 22.90 | 1 | 0 | 4 | 2 |
Merc 280 | 19.2 | 6 | 167.6 | 123 | 3.92 | 3.440 | 18.30 | 1 | 0 | 4 | 4 |
Also a quote using >
:
“He who gives up [code] safety for [code] speed deserves neither.” (via)
library(SSBpris)
data("priceData")
CalcInd(data=priceData, baseVar="b1", pVar="p1", type="jevons", groupVar="varenr", consumVar = NULL, wVar = "weight")
#> Warning: No consumer group variable was specified so an index was calculated
#> for each elementary group.
#> Warning in CalcInd(data = priceData, baseVar = "b1", pVar = "p1", type =
#> "jevons", : Elementary group weights did not add to one and have been scaled.
#> 1 2 3 4 5 6 7 8
#> 1.0539505 1.0028772 1.0944981 1.0017560 0.9845511 1.0005522 1.0014880 1.0398922
#> 9 10 11 12 13 14 15 16
#> 1.0545919 1.0530359 1.0276294 1.0120950 1.0061017 1.0121247 1.0022978 1.0188527
#> 17 18 19 20 21 22 23 24
#> 1.0360861 1.0644728 1.0324028 1.0145528 1.0625093 1.0192284 1.0299098 1.0189841
#> 25 26 27 28 29 30 31 32
#> 0.9964447 1.0430734 1.0307777 0.9880650 1.0394796 1.0360856 1.0960219 1.0236226
#> 33 34 35 36 37 38 39 40
#> 1.0311001 1.0157865 1.0306689 1.0233371 1.0278152 1.0466457 1.0223706 1.0788976
#> 41 42 43 44 45 46 47 48
#> 1.0864876 0.9914069 1.0179040 1.0298613 1.0271920 1.0313625 1.0509045 1.0289209
#> 49 50 51 52 53 54 55 56
#> 1.0307649 1.0298606 1.0625053 1.0154815 1.0093457 1.0714008 1.0087565 1.0273193
#> 57 58 59 60 61 62 63 64
#> 1.0178380 0.9972983 1.0046590 0.9994301 0.9719945 1.0546761 1.0081769 1.0098887
#> 65 66 67 68 69 70 71 72
#> 1.0343937 0.9877617 1.0183837 0.9909766 1.0258743 0.9737955 1.0565840 1.0367297
#> 73 74 75 76 77 78 79 80
#> 1.0224960 1.0186353 1.0393530 1.0156496 1.0486500 1.0626645 1.0634039 1.0248403
#> 81 82 83 84 85 86 87 88
#> 1.0868674 1.0488213 1.0641034 1.0046891 1.0643506 1.0129695 0.9961668 1.0573619
#> 89 90 91 92 93 94 95 96
#> 1.0051264 1.0261694 1.0258682 0.9795391 1.0346499 0.9998584 1.0464673 1.0198447
#> 97 98 99 100 101 102 103 104
#> 1.0197537 1.0522087 1.0061814 1.0184880 1.0249874 1.0283376 1.0272750 1.0159400
#> 105 106 107 108 109 110 111 112
#> 1.0046354 1.0215354 1.0361772 1.0391133 1.0097634 1.0677518 1.0396020 1.0037629
#> 113 114 115 116 117 118 119 120
#> 1.0341543 1.0341299 1.0262806 0.9841818 1.0553283 1.0220326 1.0191662 1.0181769
#> 121 122 123 124 125 126 127 128
#> 1.0102090 1.0563444 1.0408178 0.9738287 1.0232065 1.0218697 1.0474010 0.9925945
#> 129 130 131 132 133 134 135 136
#> 1.0309587 1.0960107 1.0343723 0.9974898 0.9897213 1.0104255 0.9962156 1.0122075
#> 137 138 139 140 141 142 143 144
#> 1.0148058 0.9999690 1.0212295 1.0302462 1.0315783 1.0517064 1.0377130 1.0255911
#> 145 146 147 148 149 150 151 152
#> 1.0258608 1.0595503 1.0511051 1.0273948 1.0145604 1.0188839 1.0136995 0.9921676
#> 153 154 155 156 157 158 159 160
#> 1.0116946 1.0207098 1.0613060 1.0549144 0.9799509 1.0451236 1.0163969 1.0093682
#> 161 162 163 164 165 166 167 168
#> 1.0140566 1.0232423 1.0161983 1.0184514 1.0540262 0.9592681 1.0042335 1.0292417
#> 169 170 171 172 173 174 175 176
#> 1.0395368 1.0371178 1.0645367 1.0048243 1.0518922 0.9931518 1.0246264 1.0154316
#> 177 178 179 180 181 182 183 184
#> 1.0526112 1.0019241 1.0136677 1.0207241 1.0167715 1.0053618 1.0537007 1.0443670
#> 185 186 187 188 189 190 191 192
#> 1.0462701 1.0210060 1.0513857 1.0504464 1.0164743 1.0181593 1.0339258 0.9974444
#> 193 194 195 196 197 198 199 200
#> 1.0050735 1.0355457 1.0077574 1.0348762 1.0256120 1.0356277 0.9915530 1.0139649