mario icon indicating copy to clipboard operation
mario copied to clipboard

quality-of-life: display Vectors, model objects, and other 'unsupported' objects as strings (but beware of length)

Open pgbovine opened this issue 4 years ago • 3 comments

not sure if this ever comes up in %>% pipelines, but sometimes in pandas the result of a pipeline is a 1-D Series object (as opposed to a 2-D DataFrame), so if that comes up too in R, we can support those as well. but again, no need to sweat it.

pgbovine avatar Nov 18 '21 00:11 pgbovine

Re - scalars. Sean: There are no scalars in R, only vectors of length 1. So whatever we do to handle vectors will also cover "scalars"

pgbovine avatar Nov 18 '21 17:11 pgbovine

rhs is a vector here, i believe? right now we just punt and display nothing on rhs (actually right now we crash but after i fix things it will display nothing on rhs)

library(dplyr)
library(palmerpenguins)

penguins %>% pull(species)

if we don't want to get into this complexity yet, a thing that pandas_tutor does is simply print out the string form of non-dataframe-y things. so just print the vector as a string and call it a day. that way, it simulates what the R console prints out. (however, we have to be careful about LONG vectors that take up a ton of space, and account for that in your 1MB upper bound cap ... or else if someone creates a huge vector then it will crash the server)

pgbovine avatar Dec 09 '21 16:12 pgbovine

The same thing happens if you pipe into lm() or first() ... since we don't want to support arbitrary objects like linear model objects, etc., i think the most graceful thing is to print them as a string summary, like whatever would've been printed to the R console

pgbovine avatar Dec 09 '21 16:12 pgbovine