I am preparing a PCoA analysis graph and having a hard time setting the scales for the PC1 and PC2. The numbers on the axis are shown to the 6 digits and in a continuous level which is unnecessary. Here is the code that I am using.. First by selecting a certain column and then visualizing for PC1 and PC2
I wonder if you're having trouble with continuous vs. discrete variables and ggplot2 complaining that the year variable is continuous? Perhaps something like:
library(tidyverse)
# Sample data, randomly generated here, but you probably read from a file
data_pcoa_scores <- tibble(
stream = "Membrane",
PC1 = runif(10),
PC2 = runif(10),
year = rep(c(2021L, 2022L), each = 5)
) |>
# The 'year' variable has to be a factor(), or else ggplot2 thinks that
# it is a continuous variable instead of a discrete one!
mutate(
year = as_factor(year)
)
data_pcoa_membrane <- data_pcoa_scores |>
filter(stream == "Membrane")
ggplot(data_pcoa_membrane, aes(PC1, PC2, colour = year, shape = year)) +
geom_point() +
coord_fixed() +
theme_bw()
(You may have to include a bit more detail in your question, like the error message, or some made-up sample data, or some output that you didn't expect to get more useful answers )