When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R
code chunks within the document. You can embed an R code chunk like this:
library(highcharter)
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
thm <- {hc_theme(
colors = c('red', 'green', 'blue'),
chart = list(
backgroundColor = NULL,
divBackgroundImage = "http://media3.giphy.com/media/FzxkWdiYp5YFW/giphy.gif"
),
title = list(
style = list(
color = '#333333',
fontFamily = "Lato"
)
),
subtitle = list(
style = list(
color = '#666666',
fontFamily = "Shadows Into Light"
)
),
legend = list(
itemStyle = list(
fontFamily = 'Tangerine',
color = 'black'
),
itemHoverStyle = list(
color = 'gray'
)
)
)}
data(diamonds, economics_long, mpg, package = "ggplot2")
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_title(text="Grafico") %>% hc_legend(layout = "vertical", verticalAlign = "top",align = "right") %>%
hc_size(height = 600) %>% hc_add_theme(thm) %>%
hc_xAxis(min = min(mpg$displ),
max = max(mpg$displ),
lineWith = 2,
labels = list(align = "left",
style = list(step=1,
fontSize = "16px",
fontWeight = "bold",
color = "blue",
min = min(mpg$displ),
max = max(mpg$displ)
)))
library(ggplot2)
ggplot(mpg, aes(x=displ, y = hwy)) + geom_point() + labs(title="Frequency bar chart")
DT::datatable(mtcars)
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
red cccccccccc
, violets are blue