vscode-R
vscode-R copied to clipboard
Extension not parsing summarise calculations
Environment Windows 11 Enterprise VS Code version 1.99.1 reditorsupport.r version 1.8.4 R version 4.4.3
Describe the bug
When running and R script and a summarise function that includes a line break, the code is not parsed correctly
To Reproduce The following code format works without issue
library(tidyverse)
library(nycflights13)
planes |>
group_by(type, engine) |>
summarise(n = n())
# A tibble: 7 x 3
# Groups: type [3]
type engine n
<chr> <chr> <int>
1 Fixed wing multi engine Reciprocating 5
2 Fixed wing multi engine Turbo-fan 2750
3 Fixed wing multi engine Turbo-jet 535
4 Fixed wing multi engine Turbo-prop 2
5 Fixed wing single engine 4 Cycle 2
6 Fixed wing single engine Reciprocating 23
7 Rotorcraft Turbo-shaft 5
Using the following format, however, the following is returned in the terminal
planes |>
group_by(type, engine) |>
summarize(
n = n(),
)
r$> planes |>
group_by(type, engine) |>
summarize()
`summarise()` has grouped output by 'type'. You can override using the `.groups` argument.
# A tibble: 7 x 2
# Groups: type [3]
type engine
<chr> <chr>
1 Fixed wing multi engine Reciprocating
2 Fixed wing multi engine Turbo-fan
3 Fixed wing multi engine Turbo-jet
4 Fixed wing multi engine Turbo-prop
5 Fixed wing single engine 4 Cycle
6 Fixed wing single engine Reciprocating
7 Rotorcraft Turbo-shaft
r$> n = n()
Error in `n()`:
! Must only be used inside data-masking verbs like `mutate()`, `filter()`, and `group_by()`.
Run `rlang::last_trace()` to see where the error occurred.
r$> )
Error: unexpected ')' in " )"
summarise function that includes a line break work without issue if entered directly in the terminal. The code also works without issue when rendering a quarto document using the VS code quarto extension, but does return the same error response as above when running the code chunk.
This seems to be an issues that was introduced in VS Code version 1.99.1. R scripts with summarise function that includes a line break work without issue in VS Code version 1.88.0
Update: The issue may be related to the operating system rather than the VS Code version. summarise function that includes a line break work without issue on MacOS 15.3.2