Pipe-Friendly Line Feeds and Printing
lf.Rd
lf()
outputs one or more line feeds during a piped sequence.
Details
print_lf()
prints an object in a piped sequence then outputs one or more line feeds.
An object passed as argument in a piped sequence is printed and/or one or more line feeds are
output during a piped sequence using cat()
. This can be useful to separate
lines of printed output, see examples.
Examples
obj <- "Lorem ipsum dolor sit amet"
obj |> lf() # line feed, object returned invisibly
#>
obj |> lf(3) # three line feeds, object returned invisibly
#>
#>
#>
(obj |> lf(3)) # three line feeds, returned object rendered visible
#>
#>
#>
#> [1] "Lorem ipsum dolor sit amet"
obj |> lf(3) |> paste("consectetur adipiscing elit", sep = ", ")
#>
#>
#>
#> [1] "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
obj |> print() |> lf(3) # line feeds are unexpectedly before printed output.
#>
#>
#>
#> [1] "Lorem ipsum dolor sit amet"
## Use print_lf() instead
obj |> print_lf() # object printed with line feed and returned invisibly
#> [1] "Lorem ipsum dolor sit amet"
#>
obj |> print_lf(3) # object printed with three line feeds and returned invisibly
#> [1] "Lorem ipsum dolor sit amet"
#>
#>
#>
(obj |> print_lf(3)) # Ditto, then rendered visible
#> [1] "Lorem ipsum dolor sit amet"
#>
#>
#>
#> [1] "Lorem ipsum dolor sit amet"
obj |> print_lf(3) |> paste("consectetur adipiscing elit", sep = ", ")
#> [1] "Lorem ipsum dolor sit amet"
#>
#>
#>
#> [1] "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
rm(obj)