-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
60 additions
and
3,576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
library(ggplot2) | ||
library(highcharter) | ||
library(dplyr) | ||
|
||
data(mpg, diamonds, package = "ggplot2") | ||
|
||
hchart(mpg, "point", hcaes(displ, hwy, group = drv), regression = TRUE) %>% | ||
hc_colors(c("#d35400", "#2980b9", "#2ecc71")) | ||
|
||
|
||
library(quantmod) | ||
x <- getSymbols("GOOG", auto.assign=FALSE) | ||
|
||
hchart(x, regression = TRUE, | ||
regressionSettings = list(type = "loess", loessSmooth = 30)) | ||
|
||
highchart() %>% | ||
hc_add_series(data = list_parse2(cars), type = "scatter", regression = TRUE, | ||
regressionSettings = list(type = "loess", loessSmooth = 2)) | ||
|
||
hchart(cars, "point", hcaes(speed), regression = TRUE, | ||
regressionSettings = list(type = "loess", loessSmooth = 0.5)) | ||
|
||
|
||
ggplot(mpg, aes(displ, hwy)) + | ||
geom_point() + | ||
geom_smooth() | ||
|
||
|
||
lm(hwy ~ displ, data = mpg) | ||
|
||
hchart(mpg, "point", hcaes(displ, hwy), regression = TRUE, | ||
regressionSettings = list(type = "polynomial", order = 5, hideInLegend = TRUE)) | ||
|
||
|
||
d <- sample_n(diamonds, 500) | ||
d | ||
hchart(d, "point", hcaes(carat, price, group = cut), | ||
color = "transparent", | ||
regression = TRUE, | ||
regressionSettings = list(type = "polynomial", order = 5, hideInLegend = TRUE)) | ||
|
||
|
||
|
||
ggplot(mpg, aes(displ, hwy)) + | ||
geom_point() + | ||
geom_smooth(method = "lm") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6e73453
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I downloaded these latest package updates today and I try use this function :
hchart(cars, "point", hcaes(speed), regression = TRUE, regressionSettings = list(type = "loess", loessSmooth = 0.5))
and the graph does not appear, just a message: no data to display.
Could this be a problem with my Rstudio?
Thanks, now your graphics with regression interactive are amazing!
6e73453
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Elizemiku !
First of all,
hchart(cars, "point", hcaes(speed))
will not work because highcharts doesnt know how interpret point without ay
component, and with highcharter I dont make any guess to try to chart the data when only thex
aesthetic is given.Secondly, as you know I've using the highchart-regression plugin and according with my test
"loess"
only work for highstocks. But now I'm working on something like this:Maybe is longer than add an option (like
regression = TRUE
) but I think we have more control about the input to the higcharts because I really don't know how the pluging works and what calculations do.Finally, you can still using the regression-plugin, but you need to add the pluging manually (via
hc_add_dependency
) due I want to keep the deafulthighcharts()
the light as possible (and every plugin make the file size bigger):Thanks to you! You're who bring the regression to the highcharter π
6e73453
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jbkunst!
Oh! I understand now. I'm flattered that I helped ^-^
The way you did it was great. I always will use highcharter to my graphs with regression.