tabelle
tabelle.Rd
Create a basic table using a data set and a formula to describe the headers.
Details
Basic tables creates, as the name suggests, very basic tables. In general, tabelle
will not create summaries for you or transform your data in any shape or form.
Instead, the idea is that you provide an already summarized data frame (e.g.,
from dplyr's summary function) and just need some nested headers when writing
it to Excel.
Following the tibble
approach, tabelle
assumes that all items that you may
want to use as row names are just columns in your data set (see example). That
is, tabelle
will allow you to pick some of your items as row names and then just
write them in a separate section to the left of the data.
The table headers are defined with a basic formula approach. For example,
Species ~ Sepal.Length + Sepal.Width
defines a table with Species as the
row names and Sepal.Length and Sepal.Width as columns. The output in Excel will
be similar to the following:
|Species | Sepal.Length Sepal.Width|
|:-------|------------: -----------:|
|setosa | 5.1 3.5|
|setosa | 4.9 3.0|
Note that the row names (Species) are in a separate block to the left.
You can add spanner labels with as follows:
Species ~ (Sepal = Sepal.Length + Sepal.Width) + (Petal = Sepal.Length + Sepal.Width)
This will result in an Excel output similar to:
| | Sepal | Petal |
|Species | Sepal.Length| Sepal.Width| Petal.Length| Petal.Width|
|:-------|------------:|-----------:|------------:|-----------:|
|setosa | 5.1| 3.5| 1.4| 0.2|
You can also nest spanners (e.g., Species ~ (Sepal = (Length = Sepal.Length) + (Width = Sepal.Width))
.
In the example above, there is some redundant information: For example, if we have the spanner
label "Sepal", we don't need the "Sepal." part of "Sepal.Length". To remove this
redundancy, you can rename the item in the header using new_name:old_name
.
For example, Species ~ (Sepal = Length:Sepal.Length + Width:Sepal.Width) + (Petal = Length:Sepal.Length + Width:Sepal.Width)
defines as table similar to the following:
| | Sepal | Petal |
|Species | Length | Width | Length | Width |
|:-------|-------:|------:|-------:|------:|
|setosa | 5.1| 3.5| 1.4| 0.2|
Finally, to create a table without row names, use
1 ~ (Sepal = Length:Sepal.Length + Width:Sepal.Width) + (Petal = Length:Sepal.Length + Width:Sepal.Width)
This defines as table similar to the following:
| Sepal | Petal |
| Length | Width | Length | Width |
|-------:|------:|-------:|------:|
| 5.1| 3.5| 1.4| 0.2|