If it is numeric or categorically

I recommend improving the styling/layout of your code.
This means choosing points to add a line break so that some code is written to the next line.
compare this equivalent code

ggplot(economics_long, aes(date, value01, colour = variable)) + geom_line()+ theme(legend.position = "top")
ggplot(
  data = economics_long,
  aes(date,
    value01,
    colour = variable
  )) +
  geom_line() + 
  theme(legend.position = "top")

when you write code involving strings; you have to take care to balance them every " that you start will need a companion " that ends it ; similarly single quotes ' , also brackets.
If you struggle to see where you lose these balanced pairs of token, make yourself a fresh script, and grow your code part by part till you identify where it breaks.

For larger work, there is a significant benefit to using version control software like git to manage your versions, you can keep a history of working code; when you add code that breaks , you can both a) go back to the previous working code, b) more easily see the change from your prior working code to your code now. Though for a simple short script this is overkill, for any significant or long lasting project work, it becomes necessary.

Finally; when sharing code to this forum its vital to format it to appear as code