| ggsurface | R Documentation | 
a ggplot2 2D surface plot function for R glm or lm models
ggsurface(m, x.var, y.var, x.label, y.label, legend.title,
low.col, high.col, xgrid.size, ygrid.size, n.bins, round.legend, scale.type)
m | 
 an object glm, lm or loess object model from stats package  | 
x.var | 
 the name or columns position of the variable to be plot at the x axis. This param has to match with the name or column position of the variable as input in the model object  | 
y.var | 
 same as x.var but for the y axis  | 
x.label | 
 a string with label for the x axis (optional). If NULL the function return x.var  | 
y.label | 
 same as x.label for the y axis  | 
legend.title | 
 a string with name for the response variable. If null the function returns 'response variable'.  | 
low.col | 
 a hexadecimal or ggplot standard color name to represent the low fitting. Default is "grey80"  | 
high.col | 
 a hexadecimal or ggplot standard color name to represent the high fitting. Default is "blue"  | 
xgrid.size | 
 An integer representing the size of the grid to create a prediction. This variable controls the number of elements to build a new x.var interval to fit the model. The default is 15.  | 
ygrid.size | 
 same as xgrid.size for the y variable. The default is also 15.  | 
n.bins | 
 An integer. The number of division / breaks for the plot. More bins will result in a plot with more divisions.  | 
round.legend | 
 the number of decimal cases to round the scales at the legend. The default is 0, which rounds to the next integer. Users may also uses -1 to round for the nearest 10th number.  | 
scale.type | 
 the type of prediction required. The default is "link", and returns the scale of the linear predictors. The alternative "response" return the prediction at the reponse variable scale. So if a glm is ran with a binomial link function than the prediction are probabilities at logit scale, but if type = "response" the prediction will be returned at probabiliti scales. See more in stats::predict help.  | 
This function takes a model object and uses the function prediction to fit the model to a grid of x size. Therefore at this version the function needs one of the model objects from the stats package. In case of any crash, plese contact-me at: <wilsonfratntine@gmail.com>.
Wilson Frantine-Silva
stats::predict, stats::glm, stats::lm, stats::lm
data(mtcars)
m <- glm(mpg ~ wt + hp, data=mtcars, family = "gaussian")
ggsurface(m, x.var = "wt", y.var = "hp",
   legend.title = "milles per galon", high.col = "darkred",
   round.legend = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.