Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私のオブジェクトにはクラス「キャラクター」があります。gg
x <- rep(TRUE,4) x <- replace(x,3,FALSE)
これを論理クラスに強制/変換したいと思います。x のクラスを変更するにはどうすればよいですか?
私はあなたがあなたの例で意味していると仮定しています:
x <- rep("TRUE", 4) x <- replace(x, 3, "FALSE") class(x) # "character"
その場合、次を試してください:
y <- as.logical(x) class(y) # "logical"