geom_smooth not appearing on ggplot












-1















I am having a problem where geom_smooth() is not working on my ggplot. Based on previous posts, I have found that because my date variables are character vectors, the geom_smooth() is not working. I am trying to convert my dates from class character to class date but using as.Date results in a class "unknown" for my date variables.



Here is my code to attempt to fix my class type:



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = as.Date(theatrical_release_release_date, format = "%Y-%m-%d"))


And here is my code for attempting to plot with geom_smooth(), in case anyone can help me find the error here.



ggplotly(tooltip = c("text"),
ggplot(data = allmovies, aes(x = theatrical_release_release_date,
y = total_box_office, color = mpaa, text = movie)) +
geom_point() +
geom_smooth(method=lm) +
scale_y_continuous(labels = comma) +
labs(color = "MPAA Rating") +
ylab("Total Box Office Revenue") +
xlab("Theatrical Release Date") +
ggtitle("Total Box Office Revenue Over Time",
subtitle = "While revenue generally improved over time, a further analysis shows PG rated movies generated much more revenue over time while PG-13 and R-rated revenue correlations do not appear to be significant.")) %>%
layout(title = "Total Box Office Revenue Over Time",
font = font)


Finally, here is a sample of my data of the date column:



dput(head(allmovies$theatrical_release_release_date))
c("2013-08-23", "2013-03-22", "2012-09-14", "2012-03-16", "2012-02-17",
"2011-10-14")


and here is a small sample of the whole data:



structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))









share|improve this question

























  • Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

    – iod
    Nov 27 '18 at 19:03






  • 1





    Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

    – Mako212
    Nov 27 '18 at 19:06






  • 1





    We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

    – joran
    Nov 27 '18 at 19:31






  • 1





    I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

    – joran
    Nov 27 '18 at 19:44






  • 2





    You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

    – joran
    Nov 27 '18 at 19:47
















-1















I am having a problem where geom_smooth() is not working on my ggplot. Based on previous posts, I have found that because my date variables are character vectors, the geom_smooth() is not working. I am trying to convert my dates from class character to class date but using as.Date results in a class "unknown" for my date variables.



Here is my code to attempt to fix my class type:



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = as.Date(theatrical_release_release_date, format = "%Y-%m-%d"))


And here is my code for attempting to plot with geom_smooth(), in case anyone can help me find the error here.



ggplotly(tooltip = c("text"),
ggplot(data = allmovies, aes(x = theatrical_release_release_date,
y = total_box_office, color = mpaa, text = movie)) +
geom_point() +
geom_smooth(method=lm) +
scale_y_continuous(labels = comma) +
labs(color = "MPAA Rating") +
ylab("Total Box Office Revenue") +
xlab("Theatrical Release Date") +
ggtitle("Total Box Office Revenue Over Time",
subtitle = "While revenue generally improved over time, a further analysis shows PG rated movies generated much more revenue over time while PG-13 and R-rated revenue correlations do not appear to be significant.")) %>%
layout(title = "Total Box Office Revenue Over Time",
font = font)


Finally, here is a sample of my data of the date column:



dput(head(allmovies$theatrical_release_release_date))
c("2013-08-23", "2013-03-22", "2012-09-14", "2012-03-16", "2012-02-17",
"2011-10-14")


and here is a small sample of the whole data:



structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))









share|improve this question

























  • Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

    – iod
    Nov 27 '18 at 19:03






  • 1





    Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

    – Mako212
    Nov 27 '18 at 19:06






  • 1





    We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

    – joran
    Nov 27 '18 at 19:31






  • 1





    I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

    – joran
    Nov 27 '18 at 19:44






  • 2





    You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

    – joran
    Nov 27 '18 at 19:47














-1












-1








-1








I am having a problem where geom_smooth() is not working on my ggplot. Based on previous posts, I have found that because my date variables are character vectors, the geom_smooth() is not working. I am trying to convert my dates from class character to class date but using as.Date results in a class "unknown" for my date variables.



Here is my code to attempt to fix my class type:



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = as.Date(theatrical_release_release_date, format = "%Y-%m-%d"))


And here is my code for attempting to plot with geom_smooth(), in case anyone can help me find the error here.



ggplotly(tooltip = c("text"),
ggplot(data = allmovies, aes(x = theatrical_release_release_date,
y = total_box_office, color = mpaa, text = movie)) +
geom_point() +
geom_smooth(method=lm) +
scale_y_continuous(labels = comma) +
labs(color = "MPAA Rating") +
ylab("Total Box Office Revenue") +
xlab("Theatrical Release Date") +
ggtitle("Total Box Office Revenue Over Time",
subtitle = "While revenue generally improved over time, a further analysis shows PG rated movies generated much more revenue over time while PG-13 and R-rated revenue correlations do not appear to be significant.")) %>%
layout(title = "Total Box Office Revenue Over Time",
font = font)


Finally, here is a sample of my data of the date column:



dput(head(allmovies$theatrical_release_release_date))
c("2013-08-23", "2013-03-22", "2012-09-14", "2012-03-16", "2012-02-17",
"2011-10-14")


and here is a small sample of the whole data:



structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))









share|improve this question
















I am having a problem where geom_smooth() is not working on my ggplot. Based on previous posts, I have found that because my date variables are character vectors, the geom_smooth() is not working. I am trying to convert my dates from class character to class date but using as.Date results in a class "unknown" for my date variables.



Here is my code to attempt to fix my class type:



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = as.Date(theatrical_release_release_date, format = "%Y-%m-%d"))


And here is my code for attempting to plot with geom_smooth(), in case anyone can help me find the error here.



ggplotly(tooltip = c("text"),
ggplot(data = allmovies, aes(x = theatrical_release_release_date,
y = total_box_office, color = mpaa, text = movie)) +
geom_point() +
geom_smooth(method=lm) +
scale_y_continuous(labels = comma) +
labs(color = "MPAA Rating") +
ylab("Total Box Office Revenue") +
xlab("Theatrical Release Date") +
ggtitle("Total Box Office Revenue Over Time",
subtitle = "While revenue generally improved over time, a further analysis shows PG rated movies generated much more revenue over time while PG-13 and R-rated revenue correlations do not appear to be significant.")) %>%
layout(title = "Total Box Office Revenue Over Time",
font = font)


Finally, here is a sample of my data of the date column:



dput(head(allmovies$theatrical_release_release_date))
c("2013-08-23", "2013-03-22", "2012-09-14", "2012-03-16", "2012-02-17",
"2011-10-14")


and here is a small sample of the whole data:



structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))






r ggplot2 dplyr tidyverse as.date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 19:45









joran

135k19327387




135k19327387










asked Nov 27 '18 at 18:45









claireburstclaireburst

65




65













  • Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

    – iod
    Nov 27 '18 at 19:03






  • 1





    Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

    – Mako212
    Nov 27 '18 at 19:06






  • 1





    We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

    – joran
    Nov 27 '18 at 19:31






  • 1





    I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

    – joran
    Nov 27 '18 at 19:44






  • 2





    You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

    – joran
    Nov 27 '18 at 19:47



















  • Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

    – iod
    Nov 27 '18 at 19:03






  • 1





    Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

    – Mako212
    Nov 27 '18 at 19:06






  • 1





    We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

    – joran
    Nov 27 '18 at 19:31






  • 1





    I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

    – joran
    Nov 27 '18 at 19:44






  • 2





    You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

    – joran
    Nov 27 '18 at 19:47

















Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

– iod
Nov 27 '18 at 19:03





Hi Claire. It may be helpful to give some info on the version of R you're using, any packages you have loaded and OS.

– iod
Nov 27 '18 at 19:03




1




1





Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

– Mako212
Nov 27 '18 at 19:06





Please provide a sample of your data as the problem is likely due to some characteristic of your date column.

– Mako212
Nov 27 '18 at 19:06




1




1





We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

– joran
Nov 27 '18 at 19:31





We really don't have enough information to help. The small example of the dates you shared converts to dates just fine for me, with the appropriate class. There could be lots of other reasons the plot isn't working as you expect, but we can't really do an investigating without a full working example that we can run that demonstrates the entire behavior you're seeing.

– joran
Nov 27 '18 at 19:31




1




1





I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

– joran
Nov 27 '18 at 19:44





I think maybe text = movie is causing ggplot to attempt to fit a model to each movie. Try removing that.

– joran
Nov 27 '18 at 19:44




2




2





You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

– joran
Nov 27 '18 at 19:47





You want the text aesthetic probably only in the geom_point layer. When you put them in the top ggplot() call, every subsequent layer inherits all those aesthetic mappings. And you don't want them all in geom_smooth().

– joran
Nov 27 '18 at 19:47












1 Answer
1






active

oldest

votes


















-1














Try the lubridate package:



install.packages("lubridate")
library(lubridate)


Then use the ymd function (check the documentation for dym/ymd order by, ?dmy):



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))


If this doesn't work to use dput to provide a sample of your data and I'll edit my answer accordingly :).






share|improve this answer


























  • Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

    – claireburst
    Nov 27 '18 at 19:24













  • ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

    – QAsena
    Nov 27 '18 at 19:29













  • Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

    – claireburst
    Nov 27 '18 at 19:34













  • can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

    – QAsena
    Nov 27 '18 at 19:36











  • structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

    – claireburst
    Nov 27 '18 at 19:37











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506226%2fgeom-smooth-not-appearing-on-ggplot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














Try the lubridate package:



install.packages("lubridate")
library(lubridate)


Then use the ymd function (check the documentation for dym/ymd order by, ?dmy):



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))


If this doesn't work to use dput to provide a sample of your data and I'll edit my answer accordingly :).






share|improve this answer


























  • Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

    – claireburst
    Nov 27 '18 at 19:24













  • ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

    – QAsena
    Nov 27 '18 at 19:29













  • Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

    – claireburst
    Nov 27 '18 at 19:34













  • can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

    – QAsena
    Nov 27 '18 at 19:36











  • structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

    – claireburst
    Nov 27 '18 at 19:37
















-1














Try the lubridate package:



install.packages("lubridate")
library(lubridate)


Then use the ymd function (check the documentation for dym/ymd order by, ?dmy):



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))


If this doesn't work to use dput to provide a sample of your data and I'll edit my answer accordingly :).






share|improve this answer


























  • Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

    – claireburst
    Nov 27 '18 at 19:24













  • ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

    – QAsena
    Nov 27 '18 at 19:29













  • Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

    – claireburst
    Nov 27 '18 at 19:34













  • can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

    – QAsena
    Nov 27 '18 at 19:36











  • structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

    – claireburst
    Nov 27 '18 at 19:37














-1












-1








-1







Try the lubridate package:



install.packages("lubridate")
library(lubridate)


Then use the ymd function (check the documentation for dym/ymd order by, ?dmy):



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))


If this doesn't work to use dput to provide a sample of your data and I'll edit my answer accordingly :).






share|improve this answer















Try the lubridate package:



install.packages("lubridate")
library(lubridate)


Then use the ymd function (check the documentation for dym/ymd order by, ?dmy):



allmovies <- allmovies %>%
clean_names() %>%
select(movie, total_box_office, theatrical_release_release_date,
running_time, mpaa, metacritic, sentiment) %>%
mutate(theatrical_release_release_date =
as.character(theatrical_release_release_date)) %>%
mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))


If this doesn't work to use dput to provide a sample of your data and I'll edit my answer accordingly :).







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 27 '18 at 19:27

























answered Nov 27 '18 at 19:20









QAsenaQAsena

505




505













  • Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

    – claireburst
    Nov 27 '18 at 19:24













  • ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

    – QAsena
    Nov 27 '18 at 19:29













  • Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

    – claireburst
    Nov 27 '18 at 19:34













  • can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

    – QAsena
    Nov 27 '18 at 19:36











  • structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

    – claireburst
    Nov 27 '18 at 19:37



















  • Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

    – claireburst
    Nov 27 '18 at 19:24













  • ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

    – QAsena
    Nov 27 '18 at 19:29













  • Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

    – claireburst
    Nov 27 '18 at 19:34













  • can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

    – QAsena
    Nov 27 '18 at 19:36











  • structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

    – claireburst
    Nov 27 '18 at 19:37

















Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

– claireburst
Nov 27 '18 at 19:24







Hello! I've provided a sample of the data in the edited version of this post -- unfortunately, trying lubridate with "mutate(theatrical_release_release_date = ymd(theatrical_release_release_date))" still yields an "unknown" class.

– claireburst
Nov 27 '18 at 19:24















ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

– QAsena
Nov 27 '18 at 19:29







ok try now - I changed it from dmy to ymd - seems to work with the dput you provided. use str(allmovies) to see if the date column is character, factor or date. It should be date now :)

– QAsena
Nov 27 '18 at 19:29















Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

– claireburst
Nov 27 '18 at 19:34







Thank you, this worked -- do you have any idea, however, why my geom_smooth() does not appear on my plot?

– claireburst
Nov 27 '18 at 19:34















can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

– QAsena
Nov 27 '18 at 19:36





can you use dput(head(allmovies)) to give a sample of the whole dataframe and I'll take a look. You only need to copy the console output :)

– QAsena
Nov 27 '18 at 19:36













structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

– claireburst
Nov 27 '18 at 19:37





structure(list(movie = c("The Frozen Ground", "The Croods", "Stolen", "Seeking Justice", "Ghost Rider: Spirit of Vengeance", "Trespass" ), total_box_office = c(5617460, 573068425, 17967746, 411746, 149217355, 786532), theatrical_release_release_date = structure(c(15940, 15786, 15597, 15415, 15387, 15261), class = "Date"), running_time = c(105, 98, 96, 104, 95, 90), mpaa = c("R", "PG", "R", "R", "PG-13", "R"), metacritic = c(37, 55, 43, 38, 34, 37), sentiment = c(NA, 0.1363636, NA, NA, NA, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

– claireburst
Nov 27 '18 at 19:37




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506226%2fgeom-smooth-not-appearing-on-ggplot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks