close
Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Friede's user avatar
Friede's user avatar
Friede's user avatar
Friede
  • Member for 3 years, 9 months
  • Last seen this week

Profile

Stats

12,435
reputation
109k
reached
670
answers
1
question

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

3
gold badges
14
silver badges
32
bronze badges
1,040
Score
670
Posts
100
Posts %
198
Score
119
Posts
18
Posts %
191
Score
116
Posts
17
Posts %
66
Score
42
Posts
6
Posts %
59
Score
46
Posts
7
Posts %
51
Score
29
Posts
4
Posts %

Top posts

View all questions, answers, and articles