When there is no selection, it would be good if the following commands operated on the variable the cursor is on:
r.previewDataframe, r.nrow, r.length, r.head, r.thead, r.names
Details
Consider the following file:
library(ggplot2)
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point()
When the cursor is on iris in line 2, I think it would make sense for r.previewDataframe etc. to act on iris. But calling r.previewDataframe results in the message 'This does not appear to be a dataframe'. Calling r.nrow results in in following appearing in the console:
> nrow(ggplot(iris, aes(Sepal.Width, Sepal.Length)) +)
Error: unexpected ')' in "nrow(ggplot(iris, aes(Sepal.Width, Sepal.Length)) +)"
> nrow(geom_point())
NULL
The reason is that the above commands use getSelection() to decide what to act on. When there is no selection, getSelection() tries to find the 'minimum runnable block of code', which in the above example is lines 2-3.
@MaTo04 Thank you for adding the r.nrow family of commands! Does this suggestion sound okay to you? I don't want to break a use case I haven't thought of.
When there is no selection, it would be good if the following commands operated on the variable the cursor is on:
r.previewDataframe,r.nrow,r.length,r.head,r.thead,r.namesDetails
Consider the following file:
When the cursor is on
irisin line 2, I think it would make sense forr.previewDataframeetc. to act oniris. But callingr.previewDataframeresults in the message 'This does not appear to be a dataframe'. Callingr.nrowresults in in following appearing in the console:The reason is that the above commands use
getSelection()to decide what to act on. When there is no selection,getSelection()tries to find the 'minimum runnable block of code', which in the above example is lines 2-3.@MaTo04 Thank you for adding the
r.nrowfamily of commands! Does this suggestion sound okay to you? I don't want to break a use case I haven't thought of.