Skip to content

Commit 87e29b4

Browse files
committed
force NA to be "NA" as nchar API changed on 2015-04-23 in R-devel
https://stat.ethz.ch/pipermail/r-devel/2015-April/071007.html
1 parent c7a177d commit 87e29b4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/pandoc.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ pandoc.table.return <- function(t, caption, digits = panderOptions('digits'), de
610610
split.single.cell <- function(x, max.width){
611611
if (!is.character(x))
612612
x <- as.character(x)
613+
## as.character(NA) remains NA, which causes isses with nchar since 2015-04-23
614+
## https://stat.ethz.ch/pipermail/r-devel/2015-April/071007.html
615+
if (is.na(x))
616+
x <- 'NA'
613617
if (!style %in% c('simple', 'rmarkdown')) {
614618
## split
615619
if (nchar(x) == nchar(encodeString(x)) && !use.hyphening) {
@@ -971,8 +975,8 @@ pandoc.table.return <- function(t, caption, digits = panderOptions('digits'), de
971975
if (all (strsplit(justify, "")[[1]] %in% c("c", "l", "r") )) {
972976
if (nchar(justify) != length(t.width))
973977
stop(sprintf('Wrong number of parameters (%s instead of *%s*) passed: justify', nchar(justify), length(t.width)))
974-
975-
justify <- c(l = "left", c = "centre", r = "right")[ strsplit(justify, "")[[1]] ]
978+
979+
justify <- c(l = "left", c = "centre", r = "right")[ strsplit(justify, "")[[1]] ]
976980
} else {
977981
justify <- rep(justify, length(t.width))
978982
}

0 commit comments

Comments
 (0)