search for: writelines

Displaying 20 results from an estimated 326 matches for "writelines".

2012 Mar 15
1
how to assign "writeLines" function
hi, what I want to do is assigning following code to any object. k<-paste("thank") writeLines(strwrap(k, width = 80,indent = 7,exdent = 6)) To assign the "writeLines" code, I try this a<-writeLines(strwrap(k, width = 80,indent = 7,exdent = 6)) or assign(a,writeLines(strwrap(k, width = 80,indent = 7,exdent = 6))) but it doesn't work. is there any way to solve the prob...
2018 Feb 15
2
writeLines argument useBytes = TRUE still making conversions
I think this behavior is inconsistent with the documentation: tmp <- '?' tmp <- iconv(tmp, to = 'UTF-8') print(Encoding(tmp)) print(charToRaw(tmp)) tmpfilepath <- tempfile() writeLines(tmp, con = file(tmpfilepath, encoding = 'UTF-8'), useBytes = TRUE) [1] "UTF-8" [1] c3 a9 Raw text as hex: c3 83 c2 a9 If I switch to useBytes = FALSE, then the variable is written correctly as c3 a9. Any thoughts? This behavior is related to this issue: https://github.com/yih...
2018 Feb 15
0
writeLines argument useBytes = TRUE still making conversions
...tanding the documentation correctly) file(..., encoding = "native.enc") means "assume that strings are in the native encoding, and hence translation is unnecessary". Note that it does not mean "attempt to translate strings to the native encoding". Also note that writeLines(..., useBytes = FALSE) will explicitly translate to the current encoding before sending bytes to the requested connection. In other words, there are two locations where translation might occur in your example: 1) In the call to writeLines(), 2) When characters are passed to the connection....
2006 Feb 28
1
Typos in writeLines.Rd, readLines.Rd, and data.matrix.Rd
Hello, The diffs below are based on revision 37445 and show some typo corrections for writeLines.Rd, readLines.Rd, and data.matrix.Rd that I'd like to bring to the list's attention. Sincerely, Stephen Weigand Rochester, Minnesota, USA --- ./src/library/base/man/writeLines.Rd Sun Feb 26 13:46:06 2006 +++ /tmp/writeLines.Rd Sun Feb 26 20:53:44 2006 @@ -14,8 +14,8 @@ ea...
2016 Feb 24
2
iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)
...uot;UTF-16LE") >> >> which results in a file with one line >> >> """ 3 >> >> and if you debug write.table() you see that its building blocks >> here are >> file <- file(........, encoding = fileEncoding) >> >> a writeLines(*, file=file) for the column headers, >> >> and then "deeper down" C code which I did not investigate. > > I took a look at connections.c. There is a call to strlen() that gets > confused by null characters. I think the obvious fix is to avoid the > call to strlen...
2005 May 28
1
(PR#7899) seek(con, 0, "end", rw="r") does not always work
...flush(fp); > pos = f_tell(fp); > > /* make sure both positions are set */ > Works for your example, but I found another one where it introduces a worse bug when using origin="current". Hence it's not that easy. After reviewing this issue more closely, I think writeLines() into a binary connection might be the real problem and a misuse in this case. See the last paragrpah in the Details Section of ?writeLines. Hence, this might also be an issue related to the text mode connection problem on Windows. Using simple writeChar and readChar statements works as expec...
2016 Feb 23
4
iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)
...imilar wrong result by write.table(x, file = "foo.tab", fileEncoding = "UTF-16LE") which results in a file with one line """ 3 and if you debug write.table() you see that its building blocks here are file <- file(........, encoding = fileEncoding) a writeLines(*, file=file) for the column headers, and then "deeper down" C code which I did not investigate. But just looking a bit at such a file() object with writeLines() seems slightly revealing, as e.g., 'eol' does not seem to "work" for this encoding: > fn <- tem...
2017 Aug 23
4
Possible repeat{} / break function bug in R 3.4.1
...had worked w/o a >>> problem in earlier versions of R, where I've looked at >>> R version 3.3.3 and 3.2.5. >>> I do think this is a bug, but it was not known till now. >>> For ease of use, I attach the two R files to easily reproduce. >>> Note I use writeLines() instead of print() as its output is "nicer". >>> Best regards, >>> Martin Maechler, ETH Zurich >> Trying again with the two attachment. Yes, I of all people (!!) >> should know that they must have an allowed MIME type; in this >> case text/plain ! &...
2016 Feb 25
2
iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)
...uot;UTF-16LE") >> >> which results in a file with one line >> >> """ 3 >> >> and if you debug write.table() you see that its building blocks >> here are >> file <- file(........, encoding = fileEncoding) >> >> a writeLines(*, file=file) for the column headers, >> >> and then "deeper down" C code which I did not investigate. > > I took a look at connections.c. There is a call to strlen() that gets > confused by null characters. I think the obvious fix is to avoid the > call to strle...
2017 Dec 29
3
Writing text files out of a dataset
Hello, I am trying to run the following syntax for all cases within the dataframe "data" d1 <- data[1,c("material")] fileConn<-file("TESTI/d1.txt") writeLines(d1, fileConn) close(fileConn) I am trying to use the for function: for (i in 1:nrow(data)){ d[i] <- data[i,c("material")] fileConn<-file("TESTI/d[i].txt") writeLines(d[i], fileConn) close(fileConn) } but I get the error: Object "d" not found Any sug...
2018 Feb 15
2
writeLines argument useBytes = TRUE still making conversions
...hat it does not mean "attempt to > translate strings to the native encoding". If all that is true I think ?file needs some attention. I've read it several times now and I just don't see how it can be interpreted as you've described it. Best, Ista > > Also note that writeLines(..., useBytes = FALSE) will explicitly > translate to the current encoding before sending bytes to the > requested connection. In other words, there are two locations where > translation might occur in your example: > > 1) In the call to writeLines(), > 2) When characters ar...
2005 Jul 26
2
Dial using URI(web) or using FORM(web)
Hello! I have an Asterisk@home instalation with 7 users working OK, and I'ld like to implement either a -- Web dial feature, where the user would fill one form field with a phone number and a connection would be created between his extention and the entered number. OR -- Dial using an URI (callto:xxxxx link in a web page), having AstTapi installed and configured in all workstations.
2018 Feb 17
1
writeLines argument useBytes = TRUE still making conversions
...uot;. >> >> If all that is true I think ?file needs some attention. I've read it >> several times now and I just don't see how it can be interpreted as >> you've described it. >> >> Best, >> Ista >> >>> >>> Also note that writeLines(..., useBytes = FALSE) will explicitly >>> translate to the current encoding before sending bytes to the >>> requested connection. In other words, there are two locations where >>> translation might occur in your example: >>> >>> 1) In the call to wri...
2014 Oct 19
1
Writing UTF8 on Windows
...> string <- enc2utf8("Z?rich") > Encoding(string) [1] "UTF-8" For example when writing the utf8 string to a binary utf8 binary connection, the output seems to be latin1: > con <- file("test1.txt", open="wb", encoding = "UTF-8") > writeLines(string, con) > close(con) > system("file test1.txt") test1.txt: ISO-8859 text > readLines("test1.txt", encoding="UTF-8") [1] "Z\xfcrich" I am not quite sure if this is a bug or expected. To avoid this and other problems, jsonlite uses the 'useBy...
2004 Jul 26
6
directing print.packageInfo to a file
...s <- c("\n", "\n", "\n", "") formatDocEntry <- function(entry) { if (is.list(entry) || is.matrix(entry)) formatDL(entry, style = "list") else entry } for (i in which(!sapply(x$info, is.null))) { writeLines(headers[i], outConn, sep = "") writeLines(formatDocEntry(x$info[[i]]), outConn) writeLines(footers[i], outConn, sep = "") } close(outConn) if (is.null(file)) file.show(outFile, delete.file = TRUE, title = paste ("Documentation for package&qu...
2011 Jul 04
1
writeLines + foreach/doMC
...quire 10GB mem at least) so I wrote a function that, given a sequence id, provide the needed line to be stored library(doMC) # load library registerDoMC(12) # assign the Number of CPU fileConn<-file(paste(fq_file,"_SeqID.txt",sep=""),open = "at") # open connection writeLines(paste("ReadID","Freq","Seq","LOC_UG","Nb_UG_Seq",sep="\t"), fileConn) # write header foreach(i=1:length(uniq.Seq)) %dopar% # for eqch unique sequence { writeLines(paste(gettable1(uniq.Seq[i]),collapse=" "), fileConn) #write the...
2016 Feb 24
2
iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)
...line >>>> >>>> """ 3 >>>> >>>> and if you debug write.table() you see that its building blocks >>>> here are >>>> file <- file(........, encoding = fileEncoding) >>>> >>>> a writeLines(*, file=file) for the column headers, >>>> >>>> and then "deeper down" C code which I did not investigate. >>> >>> I took a look at connections.c. There is a call to strlen() that gets >>> confused by null characters. I think the obvious...
2018 Feb 17
0
writeLines argument useBytes = TRUE still making conversions
...anslate strings to the native encoding". > > If all that is true I think ?file needs some attention. I've read it > several times now and I just don't see how it can be interpreted as > you've described it. > > Best, > Ista > >> >> Also note that writeLines(..., useBytes = FALSE) will explicitly >> translate to the current encoding before sending bytes to the >> requested connection. In other words, there are two locations where >> translation might occur in your example: >> >> 1) In the call to writeLines(), >>...
2010 May 05
2
readLines with space-delimiter?
Hi, I am reading a large space-delimited text file into R (41 columns and many rows) and need to do run each row's values through another R object and then write to another text file. So, far using readLines and writeLines seems to be the best bet. I've gotten the data exchange working except each row is read in as one 'chunk', meaning the row has all values between two quotes ("41 numbers"). I need to split these based upon the spaces between them. What is the simplest means of doing this?...
2016 Feb 29
1
iconv to UTF-16 encoding produces error due to embedded nulls (write.table with fileEncoding param)
...th one line >>>> >>>> """ 3 >>>> >>>> and if you debug write.table() you see that its building blocks >>>> here are >>>> file <- file(........, encoding = fileEncoding) >>>> >>>> a writeLines(*, file=file) for the column headers, >>>> >>>> and then "deeper down" C code which I did not investigate. >>> >>> I took a look at connections.c. There is a call to strlen() that gets >>> confused by null characters. I think the obvious...