Skip to main content
The 2025 Annual Developer Survey is live — take the Survey today!
Friede's user avatar
Friede's user avatar
Friede's user avatar
Friede
  • Member for 2 years, 8 months
  • Last seen this week
Stats
10,525
reputation
65k
reached
563
answers
1
question
Loading…
About
# 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
11
silver badges
31
bronze badges
830
Score
563
Posts
100
Posts %
166
Score
104
Posts
18
Posts %
161
Score
100
Posts
18
Posts %
60
Score
37
Posts
7
Posts %
48
Score
26
Posts
5
Posts %
47
Score
19
Posts
3
Posts %