Making plots with binary predictor

Hello everyone! I'm kind of new to RStudio and I am using it for my dissertation project. I'm almost done with it, the only thing I need is some pretty plots :slight_smile: I have tried and tried but I have not accomplished anything. Does anyone have any suggestions about how to build a meaningful plot? I understand that I should use the function predict() but I am still not sure how.. most examples I found had the binary variable as response, not predictor as I do.

Many thanks!
(i do have the package ggplot despite what the reprex says)

#> Error in library(ggplot): there is no package called 'ggplot'

# my data frame - rainfall_binary is numeric even tho it is a binary

df <- data.frame(
  VH_average = c(-18.4527033816948,
  rainfall_binary = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  temp = c(4.05, 4.05, 4.05, 4.05, 4.05, 4.05, 7, 7, 7, 7)

# make GLM

GLM.REPREX <- glm(data=df, VH_average~rainfall_binary+temp)

Created on 2020-03-24 by the reprex package (v0.3.0)

Just to clarify, the package is called ggplot2

df$predicted <- predict.glm(GLM.REPREX,
            newdata = df )

would add a column that shows what your model predicted.

As far as graph goes, you should think about what information it is you are trying to communicate to your reader....

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.