rstudio / rstudio

RStudio is an integrated development environment (IDE) for R
https://posit.co/products/open-source/rstudio/
Other
4.65k stars 1.09k forks source link

Feature Request: Pipe |> (%>%) with RHS empty automatically calls methods(,class(data)) and are shown as a List in RStudio IDE #9162

Open jtelleriar opened 3 years ago

jtelleriar commented 3 years ago

Similar in spirit to how Python pandas.DataFrame works when using the dot "."(pd.data.[Method List]), and using an IDE such as PyCharm, which shows a method list, it would be nice to see available methods (generic functions) for a given class easily and intuitively when using the new pipe operator |> or magrittr pipe operator %>% when RHS is empty, being methods(,class(object) automatically invoked, and those generic functions shown through the IDE.

Many R newcomers, when start using R, think only on functions and not methods, this new feature would allow to intuitively see that a given class, has a given set of methods / generic functions, simply for being the class it is.

Plus syntax methods(,class(object)) is not 100% intuitive, as you have to know that it exits (Specially for being "class" the second argument).

mtcars |> subset(cyl == 4) |> For being the RHS empty when executing from terminal, would be equal to:

methods(,class(subset(mtcars, cyl == 4))) [1] $<- [ [[ [[<- [<- aggregate anyDuplicated anyNA as.data.frame as.list
[11] as.matrix by cbind coerce dim dimnames dimnames<- droplevels duplicated edit
[21] filter fliplr flipud format formula head initialize intersect is.na Math
[31] merge na.exclude na.omit Ops padarray plot print prompt rbind row.names
[41] row.names<- rowsum setdiff setequal show size slotsFromS3 split split<- stack
[51] str subset sum summary Summary t tail transform type.convert union
[61] unique unstack within
see '?methods' for accessing help and source code

Being methods shown as a list through the IDE (Similar to how other IDEs such as PyCharm work with Python).

Thank you in advance for your help!

jtelleriar commented 3 years ago

As an example for Python:

image

Would be great being able to see the same for %>% pipe by automatically calling

methods(,class(.))