LoslegenKostenlos loslegen

Why is this piece of code slow?

Consider the following piece of code:

x <- NULL
n <- 30000
for(i in 1:n) {
    x <- c(x, rnorm(1))
}

Which of the following statements is correct?

Diese Übung ist Teil des Kurses

Writing Efficient R Code

Kurs anzeigen

Interaktive Übung

In dieser interaktiven Übung kannst du die Theorie in die Praxis umsetzen.

Übung starten