Error in -x : invalid argument to unary operator

Hi I'm trying to plot my data using ggplot2 but I'm getting this error I've never seen before... I was searching online and couldn't find anything useful.

This is my code:

##PACKAGES

library(ggplot2)
library(viridis)
library(hrbrthemes)

##IMPORT DATA
library(readxl)
TOC_LANG <- read_excel("PHD/LAB/LAB RESULTS/Jul-2021- TOC/TOC- LAN and GROVE AV/vario016_TOC_MOD.xlsx",
sheet = "R", range = "B3:E55")

#IMPORT DATA

library(readxl)
TOC_PORTGA <- read_excel("PHD/LAB/LAB RESULTS/Jul-2021- TOC/TOC- LAN and GROVE AV/vario016_TOC_MOD.xlsx",
sheet = "R", range = "A59:E105")

View(TOC_LANG)

########NUMERIC
TOC_LANG$TOC = as.numeric(TOC_LANG$TOC)
is.numeric(TOC_LANG$TOC)

TOC_LANG$Macroalgae = as.numeric(TOC_LANG$Macroalgae)
is.numeric(TOC_LANG$Macroalgae)

FIRST CODE

ggplot(TOC_LANG,aes(x=Depth,y=TOC, group=Macroalgae)) +
geom_line(aes(color=Macroalgae),size=.5, linetype=1) +
geom_point() +
scale_x_reverse() +
scale_y_continuous( position="right") +
labs(title ="TOC_LANG (%C)", x= "Depth (cm)", y="TOC (%C)") +
coord_flip()

thank you!

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 21 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.