I have a two vectors of numbers of equal length. How do I plot the first vector while using the corresponding element in the second vector as the printing character? (Background: I sorted the first column and the second column holds the original indices. I want to use the indices as the printable character so that I can see which data points are outliers, since each number represents one run of data).
> x
$x
[1] 25 29 30 34 38 572 700 733 870 879 899 934 982 1054 1135 1258
[17] 1315 1491 1685 1700 2069 2131 2284 3498 3506 4467 4656 5633 6642 8348
$ix
[1] 23 3 18 30 13 8 4 14 11 17 12 29 9 15 19 16 7 1 20 2 6 28 21 10 5 22 24 26
[29] 25 27
First vector is x$x, second vector is x$ix (results of calling sort with index.return = TRUE)
I've tried plot(x$x, pch=str(x$ix)) but that treats x$ix numerically. If this were Python I would do something like strings = [str(x) for x in x$ix]. but this is R and I've forgotten most of what I used to know.
I found that you can do as.character(x$ix) in order to get the strings,
> as.character(x$ix)
[1] "23" "3" "18" "30" "13" "8" "4" "14" "11" "17" "12" "29" "9" "15" "19" "16"
[17] "7" "1" "20" "2" "6" "28" "21" "10" "5" "22" "24" "26" "25" "27"
and I can use this as the input to pch. But only the first character is used (and according to the docs, that's normal).
I know there's a way to do this; I did it in college. But I can't for the life of me remember how I did it.
Chart without labels:
Chart with labels, but incorrect: