> options("show.error.messages") $show.error.messages [1] TRUE > x <- as.numeric (1 + "1") 以下にエラー 1 + "1" : 二項演算子の引数が数値ではありません > x エラー: オブジェクト 'x' がありません > > #オプションを変更 > options(show.error.messages = FALSE) > x <- as.numeric (1 + "1") > x > str (x) > class (x) > structure (x) > attributes (x)
# 指定の長さの日付けオブジェクトを生成する year1 <- seq (as.Date ("2000-12-1"), by = "days", length = 50)
# 期間内の各曜日の数 table (weekdays (year1))
> (x <- 2.3 - 1.3) [1] 1 > # 厳密には1ではない > sprintf("%.16f", x) [1] "0.9999999999999998" > # したがって1との比較は偽になる > if (x >= 1) print("x >=1") else print("x<1") [1] "x<1" > # このような場合に「zapsmall」が使えることがある > if (zapsmall (x) >= 1) print("x >=1") else print("x<1") [1] "x >=1" >
ただし注意のこと
> ?Paren ... Examples: f <- get("(") e <- expression(3 + 2 * 4) identical(f(e), e) do <- get("{") do(x <- 3, y <- 2*x-3, 6-x-y); x; y ## note the differences (2+3) {2+3; 4+5} (invisible(2+3)) {invisible(2+3)}