Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
Created November 28, 2023 12:52
Show Gist options
  • Save CnrLwlss/e86fbbf1d5f8da365dc2702db049de62 to your computer and use it in GitHub Desktop.
Save CnrLwlss/e86fbbf1d5f8da365dc2702db049de62 to your computer and use it in GitHub Desktop.
Plotting long and wide stripcharts
# Plot wide data
test = data.frame(id=1:4,"A"=1:4,"B"=5:8,"C"=11:14)
# Plot original order
stripchart(test[,2:4])
# Plot updated order
stripchart(test[,c("C","A","B")])
# Plot long data
test2 = reshape(test,direction="long",varying=c("A","B","C"),v.names="Value",idvar=c("id"),timevar=c("Label"),times=c("A","B","C"))
# Plot original order
stripchart(Value~Label, data=test2)
# Plot updated order
test2$Label=factor(test2$Label,levels=c("C","A","B"))
stripchart(Value~Label, data=test2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment