Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
Dear Bert, Thank you for the suggestion. Indeed, there are various solutions and workarounds. However, there is still a bug in strsplit. 2.) gsub I would try to avoid gsub on a Wikipedia-sized corpus: using strsplit directly should be far more efficient. 3.) Punctuation marks Abbreviations and

Re: [R] Regex Split?

2023-05-05 Thread Bert Gunter
Primarily for my own amusement, here is a way to do what I think you wanted without look-aheads/behinds strsplit(gsub("([[:punct:]])"," \\1 ","a bc,def, adef,x; ,,gh"), " +") [[1]] [1] "a""bc" ",""def" ",""adef" ",""x"";" [10] ","",""gh" I certainly would *not* cla

Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
Dear Avi, Punctuation marks are used in various NLP language models. Preserving the "," is therefore useful in such scenarios and Regex are useful to accomplish this (especially if you have sufficient experience with such expressions). I observed only an odd behaviour using strsplit: the exa

Re: [R] Regex Split?

2023-05-05 Thread avi.e.gross
Leonard, It can be helpful to spell out your intent in English or some of us have to go back to the documentation to remember what some of the operators do. Your text being searched seems to be an example of items between comas with an optional space after some commas and in one case, nothing b

Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
Dear Bill, Indeed, there are other cases as well - as documented. Various Regex sites give the warning to avoid the legacy syntax "[[:<:]]", so this is the alternative syntax: strsplit(split="\\b(?=\\w)", "One, two; three!", perl=TRUE) # "O"  "n"  "e"  ", " "t"  "w"  "o"  "; " "t"  "h"  "r"  "

Re: [R] Regex Split?

2023-05-05 Thread Martin Maechler
> Bill Dunlap on Fri, 5 May 2023 08:19:21 -0700 writes: https://bugs.r-project.org/show_bug.cgi?id=16745 (from 2016, still labelled 'UNCONFIRMED") contains some other examples of strsplit misbehaving when using 0-length perl look-behinds. E.g., Thank you, Bill -- yes, uhmm, ...

Re: [R] Regex Split?

2023-05-05 Thread Bill Dunlap
https://bugs.r-project.org/show_bug.cgi?id=16745 (from 2016, still labelled 'UNCONFIRMED") contains some other examples of strsplit misbehaving when using 0-length perl look-behinds. E.g., > strsplit(split="[[:<:]]", "One, two; three!", perl=TRUE)[[1]] [1] "O" "n" "e" ", " "t" "w" "o" "; "

Re: [R] rgl not plotting properly

2023-05-05 Thread Jiayue Wang
在 5/5/23 21:08, Duncan Murdoch 写道: On 05/05/2023 7:41 a.m., Jiayue Wang wrote: 在 5/5/23 19:15, Duncan Murdoch 写道: On 05/05/2023 6:48 a.m., Jiayue Wang wrote: Thanks Duncan. glxgears works at the terminal; tcltk::tktoplevel() outputs the following: $ID [1] ".1" $env attr(,"class") [1]

Re: [R] rgl not plotting properly

2023-05-05 Thread Duncan Murdoch
On 05/05/2023 7:41 a.m., Jiayue Wang wrote: 在 5/5/23 19:15, Duncan Murdoch 写道: On 05/05/2023 6:48 a.m., Jiayue Wang wrote: Thanks Duncan. glxgears works at the terminal; tcltk::tktoplevel() outputs the following: $ID [1] ".1" $env attr(,"class") [1] "tkwin" Jiayue But no window opens f

Re: [R] rgl not plotting properly

2023-05-05 Thread Jiayue Wang
在 5/5/23 19:15, Duncan Murdoch 写道: On 05/05/2023 6:48 a.m., Jiayue Wang wrote: Thanks Duncan. glxgears works at the terminal; tcltk::tktoplevel() outputs the following: $ID [1] ".1" $env attr(,"class") [1] "tkwin" Jiayue But no window opens for tcltk::tktoplevel()?  Sounds like R isn't

Re: [R] rgl not plotting properly

2023-05-05 Thread Duncan Murdoch
On 05/05/2023 6:48 a.m., Jiayue Wang wrote: Thanks Duncan. glxgears works at the terminal; tcltk::tktoplevel() outputs the following: $ID [1] ".1" $env attr(,"class") [1] "tkwin" Jiayue But no window opens for tcltk::tktoplevel()? Sounds like R isn't seeing your DISPLAY variable. Does S

Re: [R] Regex Split?

2023-05-05 Thread Howard, Tim G (DEC) via R-help
If you only want the character strings, this seems a little simpler: > strsplit("a bc,def, adef ,,gh", "[ ,]+", perl=T) [[1]] [1] "a""bc" "def" "adef" "gh" If you need delimeters (the commas) you could then add them back in again afterwards. Tim -- Messag

Re: [R] rgl not plotting properly

2023-05-05 Thread Jiayue Wang
Thanks Duncan. glxgears works at the terminal; tcltk::tktoplevel() outputs the following: $ID [1] ".1" $env attr(,"class") [1] "tkwin" Jiayue 在 5/5/23 16:45, Duncan Murdoch 写道: On 05/05/2023 2:24 a.m., Jiayue Wang wrote: Hi I can't get rgl working. I installed rgl, loaded it, but it seem

Re: [R] Regex Split?

2023-05-05 Thread Ivan Krylov
On Thu, 4 May 2023 23:59:33 +0300 Leonard Mada via R-help wrote: > strsplit("a bc,def, adef ,,gh", " |(?=,)|(?<=,)(?![ ])", perl=T) > # "a"    "bc"   ","    "def"  ","    "" "adef" ","    "," "gh" > > strsplit("a bc,def, adef ,,gh", " |(? # "a"    "bc"   ","    "def"  ","    "" "adef" ",

Re: [R] rgl not plotting properly

2023-05-05 Thread Duncan Murdoch
On 05/05/2023 2:24 a.m., Jiayue Wang wrote: Hi I can't get rgl working. I installed rgl, loaded it, but it seems all plot3d codes have failed: remotes::install_github("dmurdoch/rgl") library(rgl) open3d() x <- sort(rnorm(1000)) y <- rnorm(1000) z <- rnorm(1000) + atan2(x, y) plot3d(x, y, z, col