3

I am experimenting to use ggvis for my daily report. One issue I came across is that for a dataset that I intended to plot x-axis as in the data order. However, the actual plot shows up in the alphabet order.

Is there any hidden parameters to change x-axis order for Bar chart in R?

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() 
2
  • Add a level to your "Step" values, with factor. You can assign the order you want. Commented Feb 16, 2015 at 6:07
  • Thanks a lot! class(ler$Step) has already returned as "factor". Seems barchart is plotting factor as in alphabet ordr by default. Commented Feb 16, 2015 at 23:29

1 Answer 1

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() 

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.