【r<-探索】Advanced R 2.1 小测验
2019-01-10 本文已影响21人
王诗翔
Q
- Given the following data frame, how do I create a new column called “3” that contains the sum of 1 and 2? You may only use $, not [[. What makes 1, 2, and 3 challenging as variable names?
df <- data.frame(runif(3), runif(3))
names(df) <- c(1, 2)
- In the following code, how much memory does y occupy?
x <- runif(1e6)
y <- list(x, x, x)
- On which line does
a
get copied in the following example?
a <- c(1, 5, 3, 2)
b <- a
b[[1]] <- 10
A
df$`3` = df$`1` + df$`2`
object.size(x)
object.size(y)
- 第3行,因为R是使用的是复制-修改机制