Rapporter/pander — pull request #90 by RomanTsegelskyi (2014-06-16 16:52:08+00:00)
Title: Implementation of possibility to specify max width of the column separately with a vector

So whole implementation is based around such pronciples:

1. If split.cells is just a number, behavior is the same as before.
2. First value in split.cells goes for row names, if there are no row names, then it goes for first param.
2. If length(split.cells) == number of columns, then there is one max.width for every column and for rownames (if they exists) default value will be used
3. If length(split.cells) == number of columns + 1, then first value in split.cells if for row names, and others are for columns.
5. All extra value in split.cells vector are discarded.
6. If split.cells does not have enough values for all columns, warning is produced and default values are added for other columns.

_Creating dummy data_

```
y <- c("aa aa aa", "aaa aaa", "a a a a a", "aaaaa", "bbbb bbbb bbbb", "bb bbb bbbb")
y <- matrix(y, ncol = 3, nrow = 2)
rownames(y) <- c("rowname one", "rowname two")
colnames(y) <- c("colname one", "colname two", "colname three")
```

**Examples for each of the things listed.**

_If split.cells is just a number, behavior is the same as before._

```
d> pander(y, split.cells = 2)

-----------------------------------------
colname colname colname
one two three
----------- --------- --------- ---------
**rowname aa a bbbb
one** aa a bbbb
aa a bbbb
a
a

**rowname aaa aaaaa bb
two** aaa bbb
bbbb
-----------------------------------------

d> pander(y, split.cells = 6)

-----------------------------------------
colname colname colname
one two three
----------- --------- --------- ---------
**rowname aa aa a a a bbbb
one** aa a a bbbb
bbbb

**rowname aaa aaaaa bb
two** aaa bbb
bbbb
-----------------------------------------
```

_If length(split.cells) == number of columns, then there is one max.width for every column and for rownames (if they exists) default value will be used_

```
d> pander(y, split.cells = c(2, 6, 10))

-----------------------------------------------
colname colname colname
one two three
----------------- --------- --------- ---------
**rowname one** aa a a a bbbb bbbb
aa a a bbbb
aa

**rowname two** aaa aaaaa bb bbb
aaa bbbb
-----------------------------------------------

d> pander(y, split.cells = c(2, Inf, Inf))

---------------------------------------------------------
colname colname two colname three
one
----------------- --------- ------------- ---------------
**rowname one** aa a a a a a bbbb bbbb bbbb
aa
aa

**rowname two** aaa aaaaa bb bbb bbbb
aaa
---------------------------------------------------------
```
_If length(split.cells) == number of columns + 1, then first value in split.cells if for row names, and others are for columns._

```
d> pander(y, split.cells = c(5, 2, Inf, Inf))

---------------------------------------------------
colname colname two colname three
one
----------- --------- ------------- ---------------
**rowname aa a a a a a bbbb bbbb bbbb
one** aa
aa

**rowname aaa aaaaa bb bbb bbbb
two** aaa
---------------------------------------------------

```

_All extra value in split.cells vector are discarded._

```
d> pander(y, split.cells = c(5, 2, Inf, 5, 3, 10))

---------------------------------------------
colname colname two colname
one three
----------- --------- ------------- ---------
**rowname aa a a a a a bbbb
one** aa bbbb
aa bbbb

**rowname aaa aaaaa bb
two** aaa bbb
bbbb
---------------------------------------------
```

_If split.cells does not have enough values for all columns, warning is produced and default values are added for other columns._

```
d> pander(y, split.cells = c(5, 2))

-----------------------------------------------------
colname colname colname three
one two
----------------- --------- --------- ---------------
**rowname one** aa a bbbb bbbb bbbb
aa a
aa a
a
a

**rowname two** aaa aaaaa bb bbb bbbb
aaa
-----------------------------------------------------

Warning messages:
1: In split.large.cells(t) :
Split.cells vectors is smaller than data. Default value will be used for other cells
2: In split.large.cells(t.colnames) :
Split.cells vectors is smaller than data. Default value will be used for other cells

d> pander(y, split.cells = c(5, Inf))

---------------------------------------------------------
colname colname two colname three
one
----------------- --------- ------------- ---------------
**rowname one** aa a a a a a bbbb bbbb bbbb
aa
aa

**rowname two** aaa aaaaa bb bbb bbbb
aaa
---------------------------------------------------------

Warning messages:
1: In split.large.cells(t) :
Split.cells vectors is smaller than data. Default value will be used for other cells
2: In split.large.cells(t.colnames) :
Split.cells vectors is smaller than data. Default value will be used for other cells

```