我正在尝试将ggvis用于我的日常报告。我遇到的一个问题是,对于我打算在数据顺序中绘制x轴的数据集。但是,实际绘图以字母顺序显示。
是否有任何隐藏参数可以更改R中条形图的x轴顺序?
Step LER
Pre 3.2
DS 2.8
SiARC 2.2
OPL 1.9
ILD 1.6
Oxide 1.5
library(ggvis)
ler <- read.csv("shinyapps/EUV/data/by_step_LER.csv")
ler %>% ggvis(x = ~Step, y = ~LER) %>% layer_bars()
答案 0 :(得分:5)
library(ggvis)
ler <- structure(list(Step = structure(1:6, .Label = c("Pre", "DS", "SiARC", "OPL", "ILD", "Oxide"), class = "factor"), LER = c(3.2, 2.8, 2.2, 1.9, 1.6, 1.5)), .Names = c("Step", "LER"), row.names = c(NA, -6L), class = "data.frame")
ler$Step <- factor(ler$Step, levels = ler$Step)
ler %>% ggvis(x = ~Step, y = ~LER) %>% layer_bars()