REditorSupport / REditorSupport/vscode-R
Extension not parsing summarise calculations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 139
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 5
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in VS Code 1.99.1 with reditorsupport.r 1.8.4 using the multiline summarise example, then compare execution in VS Code 1.88.0, the terminal, and a Quarto document. Trace how the extension parses and sends multiline R script expressions; done means the complete summarise call runs as one expression without splitting n = n() or the closing parenthesis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, typescript, vscode
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100