8000 Catching error · Issue #169 · RGLab/CytoML · GitHub
[go: up one dir, main page]

Skip to content
< 8000 link rel="modulepreload" href="https://github.githubassets.com/assets/tz7-c03b4585a4da8ff7.js" crossorigin="anonymous" />

Catching error #169

Open
Open

Description

@SamGG

Hi,

For keeping track, I spend a few hours trying to identify the error "invalid 'subset' argument!". The error occurs when rendering a R MarkDown file. It does raise when running the RMD chunk by chunk, nor when extracting and excuting the script from the RMD.

Finally, adding an output file for the try() function (options(try.outFile = "totototot")), reveals that

Error in filter(keys, !!enquo(subset)) : 
  ℹ In argument: `list(`$FIL` = fcs_file)`.
Caused by error:
! `..1` must be a logical vector, not a list.

Before using a list, I passed the fcs_file directly, but it also failed.

In the future, it would be great that the error catching returns the original message.

filter(keys, !!enquo(subset))$name
})
}
if(class(subset_parsed) == "try-error")
stop("invalid 'subset' argument!")
subset <- subset_parsed

Activity

  1. SamGG commented on Mar 17, 2026

    @SamGG
    Author

    my command is

            gs1 <- flowjo_to_gatingset(
              ws, path = dirname(wsp_path), name = fj_group, execute = TRUE, subset = fcs_file)
            ))
    

    It works in interactive mode (script or RMD) when fcs_file is a string and contains a valid FCS file name. It fails when knitting.
    What subset should look like when it is supposed to be a argument for the filter() function?

  2. SamGG commented on Mar 18, 2026

    @SamGG
    Author

    The problem occurs because knitting creates its own environment and is not using the .GlobalEnv that is used when executing the code chunk by chunk.

    To solve the invalid subset error, I have the option to use more rlang, which I am not familiar with. inject() encompass the execution in a new environment where variables are evaluated first, as far as I understand.

    # ii is the subset of indices targetting the FCS files of interest
    inject(gs1 <- CytoML::flowjo_to_gatingset(
        ws, subset = !!ii, path = dirname(wsp_path), name = fj_group, execute = TRUE))
    

    I feel the current way to code leads to ugly solution and not easy ot read code. And I dislike the fact that my code should be adapted although it is perfectly correct. It seems that rlang introduced !! and inject() specifically to fix the problems that rlang itself created. Sorry, but this wastes my time and I don't adhere to this stuff.

    In the end, I force knitting in the .GlobalEnv environment. Not perfect, but acceptable to me. Rmarkdown is more important to me than a so-called "better coding".
    https://stackoverflow.com/questions/49755766/r-studio-how-to-load-a-variable-into-the-global-environment-by-running-a-knitr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0