Stats
10,525
reputation
65k
reached
563
answers
1
question
Loading…
Collectives
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
Badges
View all badges
2
gold badges
-
ElectorateAug 24
-
FanaticFeb 13, 2024
11
silver badges
-
rSep 20
-
SportsmanshipApr 29
-
PunditApr 29
Top tags
View all tags