Entering edit mode
10 months ago
741801556
•
0
I wonder know how to define the fill and colour using my data in R?
Code is as follows:
data <- read.table("G:/protomtics/20231228-QCM-Gas/20231229-QCM-Gas/data analysis/pca_data.csv",header = T, row.names = 1, sep = ",")
pca <- principal(train.scale, rotate="none")
plot(pca$values, type="b", ylab="Eigenvalues", xlab="Component")
pca.rotate <- principal(train.scale, nfactors = 2, rotate ="varimax")
pca.rotate
pca.scores <- data.frame(pca.rotate$scores)
head(pca.scores)
RC1 RC2
WT_1_126 56.09007 54.1052753
WT_2_127 64.48834 48.1215063
WT_3_126 64.96041 0.5308317
WT_4_127 71.08494 -4.6388461
DMD_1_128N -70.23270 -32.4267293
DMD_2_128C -68.77648 -42.3431540#
pca.scores$Sample_id <- data$Sample_id
library(ggplot2)
p1<-ggplot(pca.scores, aes(x = RC1, y = RC2,fill = Sample_id,colour = Sample_id)
Caused by error:
! Can't find a date.'Sample_id'
You need to post what
pca.scores
looks like. You're also missing a geometry to add to the plot, likegeom_point()
.sorry about that. I have posted a part of the code.