Stats
12,002
reputation
99k
reached
640
answers
1
question
Loading…
Collectives
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
Badges
View all badges
2
gold badges
-
ElectorateAug 24, 2024
-
FanaticFeb 13, 2024
14
silver badges
-
rSep 20, 2024
-
RefinerSep 9
-
SportsmanshipApr 29

