I have a dataframe which I want to print as a warning to show NA
values.
The reason I can't use print alone is that I am running an RMarkdown document which I want to run without adding this dataframe to the pdf but separately print the dataframe with all my other warning messages in the console.
When I try message(df)
it just pastes a long string with all of the columns together and converts dates into numeric.
I tried using message(kable(df))
which was almost perfect but the rows don't appear on new lines. Any suggestions?
My guess is you want to use capture.output()
:
> message(paste0(capture.output(iris), collapse = "\n"))
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With