Skip to content

R API: ggplot2 ggplotly(): geom_smooth() not supported #179

@brianboonstra

Description

@brianboonstra

Trying to make a plot with geom_smooth() ends up without the smoothing layer. The error message is

In layer2traces(L, df, misc): Conversion not implemented for geom_smooth (basic geom_smooth),
ignoring. Please open an issue with your example code at https://github.com/ropensci/plotly/issues

Code to reproduce is as follows

raw_data = Quandl(c('WIKI/XOM', "NSE/OIL"))
clean.quandl.name <- function(x) {
cleaned <- x
if (x=='Date') {} else {
    tryCatch({
                parts <- stringr::str_split(x, " - ",n=2)
                first.parts <- stringr::str_split(parts[[1]][[1]], "\\.",n=2)
                cleaned <- paste(first.parts[[1]][[2]], parts[[1]][[2]], sep=".")
                cleaned <- str_replace_all(cleaned," ","")
                },
             error = function(e) {cat(paste0("Err on",x,"\n"))}
             )
}
stringr::str_trim(cleaned)
}
fixed.names <- lapply(names(raw_data),clean.quandl.name)
renamed_data <- raw_data
names(renamed_data) <- fixed.names
gp <- ggplot(renamed_data, aes(x=OIL.Open, y=XOM.Open))+geom_point()+geom_smooth()
py <- plotly()
response <- py$ggplotly(gp)

My output looked like this:

but should have looked like this:
unknown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions