On Wed, 3 Nov 2021, Rui Barradas wrote:
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
library(dplyr)
mtcars %>%
select(mpg, cyl, disp, hp, am) %>%
mutate(
sampdt = c("automatic", "manual")[am + 1L]
Hello,
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
library(dplyr)
mtcars %>%
select(mpg, cyl, disp, hp, am) %>%
mutate(
sampdt = c("automatic", "manual")[am + 1L]
) %>%
print()
Then, I've
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 want
to source() scripts and rely on their output (including sink()), you'll
need to print() results explicitly.
cat in R behaves similarly to cat in unix-alikes, sends text to a stdout.
Usually, that stdout would be a file, but usually in R it is the R Console.
I think it might also help to note the difference between cat and print:
x <- "test\n"
cat(x)
print(x)
produces
> cat(x)
test
> print(x)
[1] "t
On Tue, 2 Nov 2021 10:18:07 -0700 (PDT)
Rich Shepard wrote:
> 'corvalis discharge summary\n'
> summary(cor_disc)
> sd(cor_disc$cfs)
> '-\n'
In the interactive mode, on the top level of execution, these commands
behave as if you had written
print(sink('data-summaries.txt'))
print
On Tue, 2 Nov 2021, Bert Gunter wrote:
What do you think these 2 lines are doing?
cat ('corvalis discharge summary\n')
print(cat)
Bert,
If I used them in linux cat would display the file (as do more and less) and
print() would be replaced with lpr
Please consult ?cat . You might also spend
What do you think these 2 lines are doing?
cat ('corvalis discharge summary\n')
print(cat)
Please consult ?cat . You might also spend a bit of (more?) time with an R
tutorial or two as you seem confused about how assignment (<-) works. Or
maybe I'm confused about what is confusing you
Bert G
On Tue, 2 Nov 2021, Andrew Simmons wrote:
You probably want to use cat and print for these lines. These things won't
print when not run at the top level, so if you want them to print, you must
specify that.
Andrew,
I modified the file to this:
sink('data-summaries.txt')
cat ('corvalis dischar
You probably want to use cat and print for these lines. These things won't
print when not run at the top level, so if you want them to print, you must
specify that.
On Tue, Nov 2, 2021, 13:18 Rich Shepard wrote:
> I've read ?sink and several web pages about it but it's not working
> properly
> w
I've read ?sink and several web pages about it but it's not working properly
when I have the commands in a script and source() them.
The file:
library(tidyverse)
library(lubridate)
sink('data-summaries.txt')
'corvalis discharge summary\n'
summary(cor_disc)
sd(cor_disc$cfs)
'-\n'
10 matches
Mail list logo