'Extract data frame column after pipe, in base R [duplicate]
I'd like to use the [[
base R function to extract a column from a dataframe at the end of a sequence of piped operations. But I get an error message that doesn't make sense to me. Here's a simple example of the error message:
> mtcars |> `[[`("mpg")
Error: function '[[' not supported in RHS call of a pipe
This example is meant to accomplish the same result as the following:
mtcars[['mpg']]
Why doesn't the simple example mtcars |> `[[`("mpg")
work? What can I do instead, using just base R?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|