r - ggplot2 geom_line() to skip NA values -


i have data set has multiple na values in it. when plotting data, ggplot's geom_line() option joins lines across na values. there way have ggplot skip joining lines across na values?

edit: thousand apologies involved. made mistake in manipulation of data frame. figured out problem. x axis not continuous when created subset. missing data had not been replaced nas, data being linked because there no nas created in subset between rows.

geom_line make breaks nas in y column, joins across na values in x column.

# set data frame nas in 'x' column independant <- c(0, 1, na, 3, 4) dependant <- 0:4 d <- data.frame(independant=independant, dependant=dependant)  # note unbroken line ggplot(d, aes(x=independant, y=dependant)) + geom_line() 

enter image description here

i assume na values in as.posixlt(date). if so, 1 solution map columns na values y, , use coord_flip make y axis horizontal:

ggplot(d, aes(x=dependant, y=independant)) + geom_line() +   coord_flip() 

enter image description here

presumably code be:

ggplot(crew.twelves, aes(x=laffcu, y=as.posixlt(date)) + geom_line() +   coord_flip() 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -