Given a dataframe df
as follows:
df <- structure(list(class = c("A", "", "", "B", ""), name = c("Jack",
"Rose", "Steve", "James", "Rick"), score = c(7L, 18L, 9L, 15L,
12L)), class = "data.frame", row.names = c(NA, -5L))
Is it possible I get the output effect as follows with formattable:
library(df)
formattable(df)
Out:
Updated code:
library(flextable)
data <- flextable(
df,
col_keys = c("class", "name", "score"))
data <- merge_v(data, j = c("class"))
formattable(data)
Out:
Error in create_obj(x, "formattable", list(formatter = formatter, format = list(...), :
argument "formatter" is missing, with no default
It raises same error as above:
library(gt)
# dummy data
dat <- tibble(
a=1:3,
b=c("a","b c","d e f")
)
d <- dat %>%
mutate(b = str_replace_all(b, " ", "<br>")) %>%
gt() %>%
fmt_markdown(columns = TRUE)
formattable(d)
Code which may help:
a1 <- c(1, 2, 3)
data <- c(100, 155, -4)
a2 <- c(0, paste(data, collapse = "<br> "), 1000000)
b <- data.frame(cbind(a1, a2))
width <- 10
formattable(b)
Out:
Reference:
In R when using formattable() place line breaks between entries inside a single cell