Special symbols causing issues with scipiper?
- Dominant language
- R
- Stars
- 10
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
I think I have uncovered a weird edge case. I think a special character/symbol is causing `scipiper` to throw an error when it shouldn't.
I am working on parsing some files in the lake-temperature-model-prep repository. The files I am writing a parser for have the column name `Temp (°C)`. The column appears in hundreds of files, so just changing it manually is not a great solution. I am using `df %>% rename(temp = "Temp (°C)")` in my function called by `scipiper` to process the data to use our chosen common name for temperature data.
Below is my reproducible example of this issue.
```r
library(dplyr)
# For example, I have this data
df <- tibble(x = 1, `Temp (°C)` = 6)
# I can easily parse using rename
rename(df, temp = "Temp (°C)")
```
I decided to try it within a teeny makefile. Running `scmake("df_parsed")` and the `remake.yml` below works with no errors 👍
```
packages:
- dplyr
targets:
df:
command: tibble(x = 1, `Temp (°C)` = 6)
df_parsed:
command: rename(df, temp = I("Temp (°C)"))
```
I also tried saving and then reading the df in as a file since that is what happens in my actual code. This still works when you run `scmake("df_parsed")` ...
```
packages:
- dplyr
targets:
df:
command: tibble(x = 1, `Temp (°C)` = 6)
df.rds:
command: saveRDS(file = target_name, object = df)
df_read:
command: readRDS("df.rds")
df_parsed:
command: rename(df_read, temp = I("Temp (°C)"))
```
BUT if I first save the RDS outside of the pipeline AND THEN try to read that file in the makefile, it breaks when I run `scmake("df_parsed)` 🤯
```r
df <- tibble(x = 1, `Temp (°C)` = 6)
saveRDS(df, "df_outside.rds")
```
```
packages:
- dplyr
targets:
df_read:
command: readRDS("df_outside.rds")
df_parsed:
command: rename(df_read, temp = I("Temp (°C)"))
```
It shows this:
```r
> x <- scmake("df_parsed")
Starting build at 2021-09-13 11:54:12
< MAKE > df_parsed
[ BUILD ] df_read | df_read <- readRDS("df_outside.rds")
[ READ ] | # loading packages
[ BUILD ] df_parsed | df_parsed <- rename(df_read, temp = "Temp (°C)")
Error: Can't rename columns that don't exist.
x Column `Temp (°C)` doesn't exist.
```
I don't think it has to do with the RDS files because in my real example where it is breaking, the files are xlsx. So, I think it is something with how `scipiper` is interacting with the files created outside of the `scipiper` pipeline. Not sure where to go from here?
It truly seems to be a difference with how it is treating the special symbol. For example, I added this to see if I could get around it by using base R methods:

When I run `scmake()` and pause at the browser, now the code looks like this:

... sorry for such a lengthy issue. Stuck and don't know what to search for to get unstuck since this seems like it is happening only when I run within the `scipiper` pipeline.
Contributor guide
Assessment
This issue has not been assessed yet.