我刚刚将 Mac 上的 RStudio 更新到版本 2023.03.0+386,我以前广泛使用的某些自动完成功能似乎发生了变化。具体来说,我将选择在管道流中间进行联接的列。以前,自动完成功能相当智能且具有上下文感知功能,并且会从我尝试加入的表的名称中提取。现在,尝试自动完成会生成错误:Error in context[[1L]] : subscript out of bounds。出于习惯,我将提供一个代表,尽管由于这无法重现错误,我也会附上屏幕截图。
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
set.seed(42)
df1 <- data.frame(
id = 1:10,
x = runif(10),
y = sample(letters[1:10])
)
df2 <- data.frame(
id = 3:7,
z = rnorm(5)
)
df2 %>%
left_join({ # With cursor in these curly …Run Code Online (Sandbox Code Playgroud) 我有一个数据框,df. 它的一些列包括逻辑。我想放弃那些都是FALSE。
library(tibble)
df <- tibble(A = rep(TRUE, 5),
B = rep(FALSE, 5),
C = c(TRUE, FALSE, TRUE, TRUE, FALSE))
df
# A tibble: 5 x 3
A B C
<lgl> <lgl> <lgl>
1 TRUE FALSE TRUE
2 TRUE FALSE FALSE
3 TRUE FALSE TRUE
4 TRUE FALSE TRUE
5 TRUE FALSE FALSE
Run Code Online (Sandbox Code Playgroud)
所需的输出是:
A C
<lgl> <lgl>
1 TRUE TRUE
2 TRUE FALSE
3 TRUE TRUE
4 TRUE TRUE
5 TRUE FALSE
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用 janitor 包选择常量列,但这将删除所有列 …