how to troubleshoot gpplot in R

Would anyone know why the data isn't plotting on this gpplot and how to troubleshoot it (see code below and image):
fig_rstudio

cultnature_fig <- culture_nature_long |>
  ggplot(mapping = aes(x = epoch, y = rel_freq,)) +
  geom_line(aes(linetype = Concept)) +
  theme_classic() +
  labs(x="Epoch", y="Relative Frequency") +
  theme(axis.text.x=element_text(angle=45, hjust=1)) +
  theme(legend.position=c(0.18,0.80))
print(cultnature_fig)

This is the error that comes up: "geom_line(): Each group consists of only one observation.
:information_source: Do you need to adjust the group aesthetic?"
Data frame looks like:

years                concept     proportion
1970-1974            A           0.003
1975-1979            B           0.005 
library(ggplot2)

d <- tibble::tribble(
           ~epoch, ~concept, ~rel_freq,
    "'1970-1974'",      "History",       0.003,
    "'1975-1979'",      "Culture",       0.005,
    "'1980-1984'",      "History",       0.002,
    "'1985-1990'",      "Culture",       0.006,
  )

d |>
  ggplot(mapping = aes(x = epoch, y = rel_freq, 
                        group = concept)) +
  geom_line(aes(linetype = concept)) +
  theme_classic() +
  labs(x="Epoch", y="Relative Frequency") +
  theme(axis.text.x=element_text(angle=45, hjust=1)) +
  theme(legend.position=c(0.18,0.80))

Created on 2023-02-21 with reprex v2.0.2

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.