Skip to main content
Friede's user avatar
Friede's user avatar
Friede's user avatar
Friede
  • Member for 3 years, 5 months
  • Last seen this week

About

mostly inactive

# R. Capture console output to create blockquote code chunk for SO.
SOquote = \(X, chunk=TRUE, verbose=TRUE) {
  X = c(paste(' >', deparse(substitute(X))), capture.output(X))
  if (chunk) X = c('```none', X, '```')
  if (verbose) message('Output has been passed to clipboard.')
  paste0('>', X) |> writeLines(pipe('pbcopy')) # adapt if not on macOS 
}
# Example
SOquote(str(cars))
> str(cars)
'data.frame':  50 obs. of  2 variables:
$ speed: num  4 4 7 7 8 9 10 10 10 11 ...
$ dist : num  2 10 4 22 16 10 18 26 34 17 ...

subject: bleeding heart

2
gold badges
14
silver badges
32
bronze badges
977
Score
640
Posts
100
Posts %
195
Score
117
Posts
18
Posts %
177
Score
112
Posts
17
Posts %
66
Score
41
Posts
6
Posts %
56
Score
45
Posts
7
Posts %
49
Score
28
Posts
4
Posts %