Created
November 28, 2023 12:52
-
-
Save CnrLwlss/e86fbbf1d5f8da365dc2702db049de62 to your computer and use it in GitHub Desktop.
Plotting long and wide stripcharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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