Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Kimmo Elo
Hi, using the library "stringi" allows this: > unlist(stringr::str_split(x, "\n")) [1] "abc" "def" """ghi" Best, Kimmo ke, 2025-02-05 kello 09:35 -0500, Duncan Murdoch kirjoitti: > Thanks to Rui, Peter and Tanvir! Peter's seems to be the fastest of > the > 3 suggestions so far on the littl

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Duncan Murdoch
On 2025-02-05 5:20 p.m., Rolf Turner wrote: On Wed, 5 Feb 2025 08:44:12 -0500 Duncan Murdoch wrote: If I have this object: x <- c("abc\ndef", "", "ghi") and I write it to a file using `writeLines(x, "test.txt")`, my text editor sees a 5 line file: 1: abc 2: def 3: 4: gh

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Rui Barradas
Hello, Inline. Às 20:27 de 05/02/2025, peter dalgaard escreveu: A 3rd option could be scan(text=x, what="", blank.lines.skip=FALSE) (all because readLines() doesn't obey the text=x convention, perhaps it should? I'm unsure whether the textConnection is left open in Rui's method.) No, it is

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Rolf Turner
On Wed, 5 Feb 2025 08:44:12 -0500 Duncan Murdoch wrote: > If I have this object: > >x <- c("abc\ndef", "", "ghi") > > and I write it to a file using `writeLines(x, "test.txt")`, my text > editor sees a 5 line file: > >1: abc >2: def >3: >4: ghi >5: > > which is what

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread peter dalgaard
A 3rd option could be scan(text=x, what="", blank.lines.skip=FALSE) (all because readLines() doesn't obey the text=x convention, perhaps it should? I'm unsure whether the textConnection is left open in Rui's method.) -pd > On 5 Feb 2025, at 15:35 , Duncan Murdoch wrote: > > Thanks to Rui, Pe

Re: [R] R CMD check error: File `inconsolata.sty' not found

2025-02-05 Thread Enrico Schumann
On Sun, 02 Feb 2025, Naresh Gurbuxani writes: > R CMD check gives me below message at the > end. There does not seem to be a problem with my TeX > installation. Is it possible that R CMD check is not > looking in the correct location? How can this problem > be fixed? > > Thanks, > Naresh > > *

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Duncan Murdoch
Thanks to Rui, Peter and Tanvir! Peter's seems to be the fastest of the 3 suggestions so far on the little test case, but on the real data (where x contains several thousand lines), Rui's seems best. Duncan On 2025-02-05 9:13 a.m., peter dalgaard wrote: This also seems to work: strsplit(pa

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Mohammad Tanvir Ahamed via R-help
x <- c("abc\ndef", "", "ghi") unlist(strsplit(gsub("^$", "\n", x), "\n")) or  x %>%   gsub("^$", "\n", .) %>%   strsplit("\n") %>%   unlist() Regards. Tanvir Ahamed Stockholm, Sweden |  mashra...@yahoo.com On Wednesday, February 5, 2025 at 02:44:37 PM GMT+1, Duncan Murdoch

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread peter dalgaard
This also seems to work: > strsplit(paste(x,collapse="\n"),"\n")[[1]] [1] "abc" "def" """ghi" > On 5 Feb 2025, at 14:44 , Duncan Murdoch wrote: > > If I have this object: > > x <- c("abc\ndef", "", "ghi") > > and I write it to a file using `writeLines(x, "test.txt")`, my text editor >

Re: [R] Looking for simple line-splitting code

2025-02-05 Thread Rui Barradas
Às 13:44 de 05/02/2025, Duncan Murdoch escreveu: If I have this object:   x <- c("abc\ndef", "", "ghi") and I write it to a file using `writeLines(x, "test.txt")`, my text editor sees a 5 line file:   1: abc   2: def   3:   4: ghi   5: which is what I'd expect:  the last line in the e

[R] Looking for simple line-splitting code

2025-02-05 Thread Duncan Murdoch
If I have this object: x <- c("abc\ndef", "", "ghi") and I write it to a file using `writeLines(x, "test.txt")`, my text editor sees a 5 line file: 1: abc 2: def 3: 4: ghi 5: which is what I'd expect: the last line in the editor is empty. If I use `readLines("test.txt")` on th

Re: [R] Error when loading optimx package and a solution

2025-02-05 Thread peter dalgaard
I think the operative words here are "brew install". I.e., this is a homebrew installation, and thus nothing to do with CRAN. Nothing wrong with homebrew as far as R Core and the CRAN team knows, we just don't support it, so you have to hope for response from other homebrew users. - Peter D.

[R] Error when loading optimx package and a solution

2025-02-05 Thread Marc Girondot via R-help
Dear R-help members Since this morning (5/2/2025), I get an error when I try to load optimx package. I solve it and I send my solution but if someone has a better idea or understand what's happened, I will be most happy to know. MacOSX 15.3 R 4.4.2 nlopt installed using brew install nlopt