我无法使用formattable()
格式化表格的文本。
我希望在斜体字里有第二列( Species(Scientific))。
我尝试了下面的代码,但没有任何反应(表格出现在图形窗口中,但没有斜体或警告)
formattable(table.species,
align =c("l","l","c"), list(`Species (scientific)` = formatter(
"span", style = ~ style(color = "grey",font.weight = "italic"))))
下面是我的表的代码。
Species_eng <- c("Lowland paca", "Agouti", "Nine-banded armadillo",
"Common opossum", "Ocelot","Red brocket deer",
"White-nosed coati", "Collared peccary" ,"Central American Spiny rat",
"Northern tamandua")
Species_sc <- c("Cuniculus paca","Dasyprocta punctata",
"Dasypus novemcinxtus", "Didelphis marsupialis",
"Leopardus pardalis", "Mazama americana",
"Nasua narica","Peccari tajacu","Proechimys semispinosus",
"Tamandua mexicana")
weight <- c(8.0, 3.6, 4.2, 2.5, 11.9, 22.8, 3.9, 25.2, 0.4, 4.3)
table.species <- data.frame(cbind(Species_eng, Species_sc, weight))
table.species <- table.species %>%
rename(`Species (Eng)` = Species_eng,
`Species (Scientific)` = Species_sc,
`Weight (kg)` = weight)
#rearrange rows in order of increasing weight
table.species$`Weight (kg)` <- as.numeric(paste(table.species$`Weight (kg)`))
rownames(table.species) = NULL
table.species <- table.species[order(as.integer
(table.species$`Weight (kg)`),
decreasing = FALSE), ]
答案 0 :(得分:1)