[R] sink() not working as expected
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed Nov 3 20:52:11 CET 2021
You do not assign the pipe output, so put the print statement as the
last instruction of the pipe. The following works.
# file: rhelp.R
select(mpg, cyl, disp, hp, am) %>%
sampdt = c("automatic", "manual")[am + 1L]
Then, I've just tested it,
Hope this helps,
Às 19:21 de 03/11/21, Rich Shepard escreveu:
> On Wed, 3 Nov 2021, Ivan Krylov wrote:
>> instead. When you source() a script, auto-printing is not performed. This
>> is explained in the first paragraph of ?source, but not ?sink. If you
>> to source() scripts and rely on their output (including sink()), you'll
>> need to print() results explicitly.
> I've read ?source and still do not understand where to put either
> or an explicit print statement. For example,
> cor_disc %>%
> select(site_nbr,year, mon, day, hr, min, tz, cfs) %>%
> sampdt = make_datetime(year, mon, day, hr, min)
> throws an error. I also get an error when the print statement follows the
> sampdt assignment.
> I need to understand how to get a sourced file that's modified (as these
> tibbles are by combining data and time columns into a datatime colune) and
> saving the tibble with the new appended column.
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help