ComeçarComece de graça

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?

Este exercício faz parte do curso

Writing Efficient R Code

Ver curso

Exercício interativo prático

Transforme a teoria em ação com um de nossos exercícios interativos

Começar o exercício