I am plotting my PCA data (= pca.183s) with ggplot (plotname = t9) and try to label my datapoints. With over 500 datapoint right next to each other, the labelling gets messy if I label every single one of them, so I want to label just every 10th or 15th datapoint.
I tried using gghighlight, but my basic knowledge of ifelse statements leads to no solution for me.
My dput(t9) is printed down below. Please notice that I cropped some of the dimensions (columns) from the data at marked with the "[...]". Delete this part after copy and paste so to avoid errors.
>dput(t9)
structure(list(data = structure(list(Dim.1 = c(-2.64734354178624,
-2.684453957401, -2.72103824389099, -2.7573690538765, -2.79350662742449
), Dim.2 = c(-0.00690584020321681, -0.0073201848208554, -0.00665742324572404,
-0.00701883060121352, -0.00841150808774304), Dim.3 = c(-0.000412824722174013,
-0.00187772191064055, -0.00153941308232753, -0.0017079820861918,
-0.00185339773024843), Dim.4 = c(-0.00379974637879092, -0.00407751816939334,
-0.00502928751035698, -0.0047605647231583, -0.00436471516808505
), Dim.5 = c(0.000319419245109297, 0.000818960273297045, 0.0011031727317379,
0.000386117109515785, 0.000509290349614579), Dim.6 = c(-0.00114820939204092,
-0.00236940468999681, -0.00188089323617931, -0.000723357169355533,
-0.000403598450968381), Dim.7 = c(-0.00135837604359201, -0.00183962442768656,
-0.00147248928991352, -0.00228101038375798, -0.0027097346141399
), Dim.8 = c(-0.0028398473163052, -0.00231692383491865, -0.00290805988706844,
-0.00259298630543098, -0.00319397304905035), Dim.9 = c(-0.00118198348599521,
-0.00107699810223108, -0.00143857323344683, -0.00117982058584542,
-0.00211841077026476), Dim.10 = c(0.000411590953489695, -0.00116304388256147,
-0.000275055364941577, -0.00102210770014903, -0.00090707036026422
), **[...]** Dim.280 = c(-0.000182139854340029, -5.01542241348593e-05,
4.90052942830289e-05, 7.22622620807921e-05, 9.64644303427084e-05
), Dim.281 = c(-6.69341869237857e-16, -6.69341869236451e-16,
-6.69341869236567e-16, -6.69341869237628e-16, -6.69341869236464e-16
)), row.names = c("1636", "1637", "1638", "1639", "1640"), class = "data.frame"),
layers = list(<environment>, <environment>, <environment>,
<environment>), scales = <environment>, mapping = structure(list(
x = ~get_pca_var(pca.183s)$coord[, 1], y = ~get_pca_var(pca.183s)$coord[,
2]), class = "uneval"), theme = list(), coordinates = <environment>,
facet = <environment>, plot_env = <environment>, labels = list(
y = "PC2", x = "PC1", label = "seq(1:nrow(get_pca_var(pca.183s)$coord))",
hjust = "hjust", vjust = "vjust")), class = c("gg", "ggplot"
))
I want some code part like this as a result, but with the ifelse or for statement (every nth row/column) to highlight the labels:
ggplot(df) +
geom_line(aes(x, y, colour = colour)) +
gghighlight("statement")
Thanks for the help!
Aucun commentaire:
Enregistrer un commentaire