R标记可删除删除行(s)?
嗨,我有一张表,我想用kable打印R标记可删除删除行(s)?,r,r-markdown,R,R Markdown,嗨,我有一张表,我想用kable打印 ds <- read.table(header = TRUE, text =" g1 color A red A yellow B red C red C yellow ") ds使用包:“formattable”在
ds <- read.table(header = TRUE, text ="
g1 color
A red
A yellow
B red
C red
C yellow
")
ds使用包:“formattable”在html中执行此操作。对pdf不太清楚
library(formattable)
ds <- read.table(header = TRUE, text ="
g1 color
A red
A yellow
B red
C red
C yellow
")
formattable(ds, list(
area(row = which(ds$color == "yellow")) ~ formatter("span",
style = "text-decoration:line-through")))
帽尖
库(kableExtra)
库(格式化表)
图书馆(dplyr)
ds%as.data.frame()%%>%在(is.factor,as.character)%%>%时进行变异
变异(
g1=ifelse(
颜色==“黄色”,
粘贴0(“\\sout{”,g1,“}”),g1
),color=ifelse(
颜色==“黄色”,
粘贴0(“\\sout{”,颜色,“}”),颜色
)
) %>%
kable(“乳胶”,escape=F,booktabs=T)
注:编译时需要包括TeX包(例如Rmd文件的YAML标题)
library(kableExtra)
library(formattable)
library(dplyr)
ds <- read.table(header = TRUE, text ="
g1 color
A red
A yellow
B red
C red
C yellow
")
ds <- ds %>% mutate(g1 = formatter("span",
style = x ~ style("text-decoration" = ifelse(ds$color == "yellow", "line-through", NA)))(g1),
color = formatter("span",
style = x ~ style("text-decoration" = ifelse(ds$color == "yellow", "line-through", NA)))(color))
kable(ds, "html", escape = F)
system("wkhtmltopdf --javascript-delay 1 --dpi 300 in.html out.pdf")
library(kableExtra)
library(formattable)
library(dplyr)
ds <- read.table(header = TRUE, text ="
g1 color
A red
A yellow
B red
C red
C yellow
")
ds %>% as.data.frame() %>% mutate_if(is.factor,as.character) %>%
mutate(
g1 = ifelse(
color == "yellow",
paste0("\\sout{", g1, "}"), g1
), color = ifelse(
color == "yellow",
paste0("\\sout{", color, "}"), color
)
) %>%
kable("latex", escape = F, booktabs = T)