-1
我想基於邏輯向量提取數據幀的列。我的數據幀df
是基於邏輯向量提取數據幀的列
structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4),
Sepal.Width = c(3.5, 3, 3.2, 3.1, 3.6, 3.9), Petal.Length = c(1.4,
1.4, 1.3, 1.5, 1.4, 1.7), Petal.Width = c(0.2, 0.2, 0.2,
0.2, 0.2, 0.4), Species = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = c("setosa", "versicolor", "virginica"), class = "factor")), .Names = c("Sepal.Length",
"Sepal.Width", "Petal.Length", "Petal.Width", "Species"), row.names = c(NA,
6L), class = "data.frame")
而且我有一個合乎邏輯的載體說x <- c(TRUE,FALSE,TRUE,TRUE,FALSE)
。如何提取邏輯列TRUE
請閱讀R入門教程。這是_really_基本的東西。使用谷歌搜索你的頭銜(加上「R」)會給你答案。 – Henrik