1

I'm trying to define breaks in ggplot, but I just get error all the way.

My dataset looks like this: I have 2 rows with Date (eks 23.10.2015) Number (eks 43)

R is not happy with my date format, so I use this command:

r$Date_formated <- as.Date(r$Date)(, "%d.%m.%Y") 

in my script to change the format to this:

Date_formated (eks 2015-10-23)

This is my whole script

r <- read.csv("Date_number.csv", header=T, sep";")
library(tidyverse)
r$Date_formated <- as.Date(r$Date), "%d.%m.%Y")

ggplot(r, aes(r$Date_formated, Number)) +
  ggtitle("Freq") +
  theme_update(plot.title=element_text(hjust=0.5)) +
  ylab("Dive") +
  geom_line(aes(group=1), color="blue") +
  labs(title="Freq", x="Time", y="dive") +
  theme_light() +
  scale_x_date(date_labels="%b", breaks="1 month", minor_breaks=NULL)

I get this error:

Error in strsplit(unitspec, " ") : non-character argument

Does anybody have a good idea to fix this? I want to have a break for each month in my plot, in the x-axis.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
felix93
  • 39
  • 3

0 Answers0