2018-05-20から1日間の記事一覧

メモ:リストの要素を消したいときはx[i] <- NULL、NULLを代入したいときはx[i] <- list(NULL)

R

ってFAQに書いてあるのを毎回忘れるのでメモ。 In R, if x is a list, then x[i] <- NULL and x[[i]] <- NULL remove the specified elements from x. The first of these is incompatible with S, where it is a no-op. (Note that you can set elements to…

メモ:環境をコピーしたいときはrlang::env_clone()

R

環境、というかggplot2のレイヤーをコピーすることを考えます。 まず、1つレイヤーをつくります。 library(ggplot2) d <- data.frame( x = 1:4, y = 1:4 ) l1 <- geom_point(d = d, aes(x, y))