I have followed the answers in https://stackoverflow.com/questions/38900698/how-to-change-labels-from-pca-using-prcomp-to-sample-names but am unable to get it to work. I have set up a dummy file (called tf4) with 7 columns and 12 rows and imported it into R Studio. The first few lines look like this
head(tf4)
# A tibble: 6 x 7
sp1 sp2 sp3 sp4 sp5 sp6 Site
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
1 1 1 1 1 1 1 A1
2 0 1 1 1 1 0 A2
3 0 1 1 1 1 1 B1
4 1 1 1 1 1 0 C1
5 0 0 1 1 0 1 D4
6 1 0 1 1 1 0 E7
I then set the row names to column 7
#setting the row names to column 7
row.names(tf4)<-tf4$Site
head(tf4)
and get a warning message
Warning message: Setting row names on a tibble is deprecated.
and when I inspect again using head(tf4) the row names have not been reset and remain as before.
But when I look at the file in R studio 'environment', it has reset the row names
snip and sketch image of the file in environment
however, when I run prcomp
model<-prcomp(tf4[,-7],scale=TRUE)
biplot(model)
the site identifiers are not used in the plot
snip and sketch view of biplot
I cannot work this out. It seems that setting the row names to column 7 is not working correctly.
Am I missing a step?
do I need an extra instruction in prcomp?
I am not quite certain what you are looking for. But I think this is it;
This changes the names from
mpgandcyltoRow 1andRow 2. Let me know if it is this you are looking for. However, without specific codes I, at least, cant tell where you went wrong.Best.