sink

Removing [1] with sink and sprintf output in R

試著忘記壹切 提交于 2019-12-06 02:34:59
I am trying to write a series of characters and numerical values using sprintf and sink: sink("sample.txt", append=TRUE, split=TRUE) sprintf("Hello World") of course, the above is an example, so I don't have the numerical values from a data frame above, but I need to use sprintf. The output in the text file (sample.txt) looks like this: [1] Hello World How do I remove the [1] from the line? Is there a way so the [1] won't write to the file? Two options spring to mind, using cat() or writeLines() > cat(sprintf("Hello World"), "\n") Hello World > writeLines(sprintf("Hello World")) Hello World

R: sink() split table in some lines

南笙酒味 提交于 2019-12-02 11:35:59
I have a very very big table of correlation values that i would like to save in a file. That actually do: sink("/to/path/file.csv") cor(total) sink() that writes something like in the file: a b c d r 0.635391844 0.316249555 0.715476998 0.138705124 y 1.000000000 0.245008313 0.927208342 0.109602263 z 0.245008313 1.000000000 0.239142304 0.080837639 t 0.927208342 0.239142304 1.000000000 0.131402452 h 0.109602263 0.080837639 0.131402452 1.000000000 e 0.996816365 0.247379819 0.930169663 0.108444557 a 0.125584355 0.149714007 0.139603217 0.664041704 a 0.245518153 0.318763442 0.252738479 0.337095547 h

Is it possible to write Flume headers to HDFS sink and drop the body?

痞子三分冷 提交于 2019-12-02 00:19:43
The text_with_headers serializer (HDFS sink serializer) allows to save the Flume event headers rather than discarding them. The output format consists of the headers, followed by a space, then the body payload. We would like to drop the body and retain the headers only. For the HBase sink, the "RegexHbaseEventSerializer" allows us to transform the events. But I am unable to find such a provision for the HDFS sink. You can set serializer property to header_and_text , which outputs both the headers and the body. For example: agent.sinks.my-hdfs-sink.type = hdfs agent.sinks.my-hdfs-sink.hdfs

Redirect all NLog output to Serilog with a custom Target

你离开我真会死。 提交于 2019-12-01 21:23:38
As a step in switching from NLog to Serilog, I want to redirect the standard wiring underlying standard invocations of NLog's LogManager.GetLogger(name) to Bridge any code logging to NLog to forward immediately to the ambient Serilog Log.Logger - i.e. I want to just one piece of config that simply forwards the message, without buffering as Log4net.Appender.Serilog does for Log4net. Can anyone concoct or point me to a canonical snippet that does this correctly and efficiently please? Requirements I can think of: Maintain the level, i.e. nlog.Warn should be equivalent to serilog.Warning It's ok

R: Sink not working correctly

主宰稳场 提交于 2019-12-01 13:15:10
I have an issue with the fourth from last line in the code below (sorry for large amounts of code, I am unsure of how much is necessary) library(mlogit) library(foreign) clogit <- read.table("~/R/clogit.dat", col.names=c("mode", "ttme", "invc", "invt", "gc", "chair", "hinc", "psize", "indj", "indi", "aasc", "tasc", "basc", "casc", "hinca", "psizea", "z", "nij", "ni"), na.strings= "-999") clogit$mode.ids <-factor(rep(1:4,210), labels=c("air", "train", "bus", "car")) CLOGIT <- mlogit.data(clogit,shape="long", choice="mode", alt.var="mode.ids") res1 <- mlogit(mode~ttme+gc, data=clogit,shape="long

R: Sink not working correctly

久未见 提交于 2019-12-01 10:10:03
问题 I have an issue with the fourth from last line in the code below (sorry for large amounts of code, I am unsure of how much is necessary) library(mlogit) library(foreign) clogit <- read.table("~/R/clogit.dat", col.names=c("mode", "ttme", "invc", "invt", "gc", "chair", "hinc", "psize", "indj", "indi", "aasc", "tasc", "basc", "casc", "hinca", "psizea", "z", "nij", "ni"), na.strings= "-999") clogit$mode.ids <-factor(rep(1:4,210), labels=c("air", "train", "bus", "car")) CLOGIT <- mlogit.data

How to capture RCurl verbose output

别来无恙 提交于 2019-11-30 20:11:09
I have the following request library(RCurl) res=getURL("http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=RCurl&btnG=Search", .opts=list(verbose = TRUE) ) and would like to capture the verbose output of the call (i.e., what is printed in red in the R console). I thought that the output lines are messages and are therefore printed to stderr() . The following works for messages sink(textConnection("test","w"),type="message") message("test message") sink(stderr(),type="message") test #[1] "test message" but not if I replace message("test message") by the RCurl request res=getURL(.....) as

is it possible to redirect console output to a variable?

爱⌒轻易说出口 提交于 2019-11-27 19:40:38
In R, I'm wondering if it's possible to temporarily redirect the output of the console to a variable? p.s. There are a few examples on the web on how to use sink() to redirect the output into a filename, but none that I could find showing how to redirect into a variable. p.p.s. The reason this is useful, in practice, is that I need to print out a portion of the default console output from some of the built-in functions in R. I believe results <- capture.output(...) is what you need (i.e. using the default file=NULL argument). sink(textConnection("results")); ...; sink() should work as well,

is it possible to redirect console output to a variable?

故事扮演 提交于 2019-11-26 19:57:36
问题 In R, I'm wondering if it's possible to temporarily redirect the output of the console to a variable? p.s. There are a few examples on the web on how to use sink() to redirect the output into a filename, but none that I could find showing how to redirect into a variable. p.p.s. The reason this is useful, in practice, is that I need to print out a portion of the default console output from some of the built-in functions in R. 回答1: I believe results <- capture.output(...) is what you need (i.e.