Skip to content
Snippets Groups Projects

ÜA3 Code für Plots

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Lasse Harkort
    Edited
    snippetfile1.txt 1005 B
    #install.packages("gridExtra") # in der Konsole
    
    library(gridExtra)
    library(ggplot2)
    
    # Gebäudeschaden
    hist1 <- ggplot(data, aes(SchGeb)) +
      geom_histogram(binwidth=0.1, color="black", fill="lightgrey") + 
      theme_bw() + 
      labs(title="Histogramm - SchGeb", y="absolute Haeufigkeit")
    
    box1 <- ggplot(data, aes(y=SchGeb)) +
      geom_boxplot(fill="lightgrey", size=0.5) + 
      theme_bw() + theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())+ xlim(-1, 1) +
      labs(title="Boxplot - SchGeb")
    
    # Hausratschaden
    
    hist2 <- ggplot(data, aes(SchHr)) +
      geom_histogram(binwidth=0.1, color="black", fill="lightgrey") + 
      theme_bw() + 
      labs(title="Histogramm - SchHr", y="absolute Haeufigkeit")
    
    box2 <- ggplot(data, aes(y=SchHr)) +
      geom_boxplot(fill="lightgrey", size=0.5) + 
      theme_bw() + theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())+ xlim(-1, 1) +
      labs(title="Boxplot - SchHr")
    
    grid.arrange(hist1, hist2, box1, box2, ncol=2, heights=c(1,1.25))
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment