X-Achse Boxplot

Wie erstelle ich Grafiken, was ist zu beachten?

Moderatoren: EDi, jogo

Antworten
Tom1980
Beiträge: 3
Registriert: Sa Dez 05, 2020 5:07 pm

X-Achse Boxplot

Beitrag von Tom1980 »

Hallo Ihr Lieben,

ich möchte die Beschriftung der Achse in folgendem Beispiel ändern. Anstatt 0,1,2,3,4,5 möchte ich dort die entsprechenden Modelnamen "crude", "direct", "total", "bias1"... stehen haben. Wie mache ich das? Kann mir jemand helfen?

Außerdem möchte ich gerne eine Legendenbeschriftung für die rote Linie mit "true causal effect"

Code: Alles auswählen

 
 ## Illustrating causal estimates --------------------------------------------------
# This function add points with confidence interval to an existing plot
add_estimate <- function(model, xpos) {
  # Estimate for causal effect
  estimate <- model$coefficients['dat$ZSpAttAnx_Emp']
  # It's 95 % CI
  ci <- confint(model)['dat$ZSpAttAnx_Emp',]
  
  # Draw CI in plot
  arrows(x0 = xpos, x1 = xpos, y0 = ci[1], y1 = ci[2], 
         length = 0.05, angle = 90, code = 3)
  # Draw point
  points(xpos, estimate, pch = 16, bg = 'grey')
}

# Make plot
plot(0, xlim = c(0, 5), ylim = c(0.4, 0.8), pch = '', xlab = 'Model', 
     ylab = 'Causal estimate', main=" quality of prediction models \n burnout employees",)
# Add line at direct causal effect
lines(c(-1, 6), c(0.5, 0.5), lty = 5, col = 'red')


# Use function to add data points and error bars (95 % CIs)
add_estimate(crude, 0)
add_estimate(direct, 1)
add_estimate(total, 2)
add_estimate(bias1, 3)
add_estimate(bias2, 4)
add_estimate(bias3, 5)
 
bigben
Beiträge: 2771
Registriert: Mi Okt 12, 2016 9:09 am

Re: X-Achse Boxplot

Beitrag von bigben »

Hi!

R sagt zu Deinem Code

Code: Alles auswählen

Fehler in add_estimate(crude, 0) : Objekt 'crude' nicht gefunden
Was nutzt der Code ohne Daten? Im Titel steht was von boxplot, im Code kann ich das nicht finden. Stattdessen ist da von Konfidenzintervallen die Rede.

Ich kann also nur hoffen, dass das hier hilft:

Code: Alles auswählen

plot(0, xlim = c(0, 5), ylim = c(0.4, 0.8), xaxt="n")
axis(1, at = 1:4, labels = LETTERS[1:4])
Siehe bitte auch viewtopic.php?f=20&t=11

LG,
Bernhard
---
Programmiere stets so, dass die Maxime Deines Programmierstils Grundlage allgemeiner Gesetzgebung sein könnte
Antworten