Data Visualization - Multiple line graphs , Screen 3

Your last code - ggplot(data = life_expec_sex) +
aes(x = Year, y = Avg_Life_Expec) +
geom_line() +
facet_wrap(~Sex, ncol = 2) is giving wrong answer.

geom_line() must be after facet wrap() .Check & correct

Hi @sharathnandalike. I’m unsure of what the question or issue is here, but in this example the order of geom_line() and facet_wrap() does not matter. In certain cases the order of geoms/layers matter, but it should not matter in this case. The issue with the code above is that ncol equals 1 in the answer, but ncol = 2 is used above.

Let me know if you have any follow-up questions.

Good [email protected], below is the error message i get trying to load ggplot2. thanks

library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘lifecycle’

library(ggplot2)

Hello @akheugiomho,

I take the liberty of answering here even if it is probably no longer relevant to you, but it could help others.

It seems to be an installation problem. One suggestion is to restart your RStudio.

If the problem is still there then re-install your ggplot2 like this:

install.packages(
   "ggplot2",
   repos = c("http://rstudio.org/_packages",
   "http://cran.rstudio.com")
)

You can find explanations on these links:

Regards,
John.