[R] Plotting Non Numeric Data

jim holtman jholtman at gmail.com
Tue Nov 20 05:32:19 CET 2007


Here is one way to plot your data:

# generate 24 cases of 4 letter character strings
x <- expand.grid(c("A", "B"), c("C","D"), c("E","F"), c("G","H","I"))
x <- apply(x, 1, paste, collapse='')
# data to plot
y <- factor(sample(x, 200, TRUE))
par(mar=c(5,6,1,1))
plot(seq_along(y), y, yaxt='n', type='l', ylab='')
axis(2, at=seq_along(levels(y)), labels=levels(y), las=2)


On Nov 19, 2007 7:37 PM, Michal Charemza <m.t.charemza at warwick.ac.uk> wrote:
> Hi,
>
> Is there a way to plot non numerical data in R?
>
> Specifically, I have an array, say with 1000 entries, where each entry
> is a string of 4 characters (in any order, 24 possibilities in my
> case). I would like on the y-axis all the strings that are in the
> array as labels. The x-axis I would like labeled 0 to 1000. The line
> is to show how the strings change as we move through the array.
>
> (This is essentially a trace plot of a Markov Chain Monte Carlo
> algorithm. I think essentially I would like an equivalent to
> plot(myArray, type='l') but with discrete, finite, non-numerical
> values on the y-axis)
>
> Is this possible?
>
> Michal.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list