Add a shortcut with an input
Closed this issue · 3 comments
Hello,
Thank you for this valuable idea. I want to create a shortcut that takes into account an input. Say for example a shortcut that shows the dimentions of a dataframe.
I expect it to work as follows: I select the data frame, click on the shortcut, and the dimension should appear.
Is that possible?
Thank you,
This is definitely possible. As a rough outline: you'll need to use the rstudioapi to get the selected text, then you can evaluate that text to get the data frame, from there you can show whatever information you want.
Thank you for your answer. Can you be more precise about which function to use in the rstudioapi? I have tried some but it is not working as expected.
Thanks
Here's an example that you could follow that might help: https://github.com/rstudio/addinexamples/blob/fae960911302ed2ca3139b47500e7606233e1390/R/subsetAddin.R#L21-L24