I'm trying to do a timeseries ggplot2 by year. My issue is that some columns have . instead of NA. As well as it seems that my variables are Factors and not numeric.
Dataset
DATE IR IQ
9/1/1983 77.6 85.7
10/1/1983 . .
11/1/1983 . .
12/1/1983 78 85.4
df_temp <- read.csv("",na.strings = "")
IR.factor <- factor(IR)
IQ.factor <- factor(IQ)
as.numeric(IR.factor)
as.numeric(IQ.factor)
head(df_temp)
str(df_temp)
df_temp <- df_temp[rowSums(is.na(df_temp)) != ncol(df_temp), ]
ggplot(aes(x=date, weight=value, fill=variable), data=df_temp) +
geom_bar() +
labs(x='DATE', y='Index 2000=100, Not Seasonally Adjusted') +
labs(color='Legend') +
scale_fill_discrete(labels = c('IR.factor',
'IQ.factor'
)) +
scale_y_continuous(breaks = round(seq(0, 200, by = 20), 1)) +
scale_x_date(date_breaks = '5 year', date_minor_breaks = '5 year',
date_labels = '%Y') +
theme(plot.title = element_text(lineheight=.7, face='bold')) +
theme(legend.position='bottom')
Any suggestions are much appreciated