similar to: regexpr with accents

Displaying 20 results from an estimated 6000 matches similar to: "regexpr with accents"

2018 Apr 30
3
How to visualise what code is processed within a for loop
Luca, If speed is important, you might improve performance by making d0 into a true matrix, rather than a data frame (assuming d0 is indeed a data frame at this point). Although data frames may look like matrices, they aren?t, and they have some overhead that matrices don?t. I don?t think you would be able to use the [[nm]] syntax with a matrix, but [ , nm] should work, provided the matrix has
2018 Apr 24
4
How to visualise what code is processed within a for loop
Hi, I am trying to debug the following code: for (i in 1:10){ t <- paste("d0$V",i,sep="") t <- ifelse(regexpr(d1[i,1],d0$X0)>0,1,0) } and I would like to see what code is actually processing R, how can I do that? More to the point, I am trying to update my variables d0$V1 to d0$V10 according to the presence or absence of some text (contained in the file d1)
2018 Apr 28
2
How to visualise what code is processed within a for loop
I forgot to explain why my suggestion. The logical condition returns FALSE/TRUE that in R are coded as 0/1. So all you have to do is coerce to integer. This works because the ifelse will return a 1 or a 0 depending on the condition. Meaning exactly the same values. And is more efficient since ifelse creates both vectors, the true part and the false part, and then indexes those vectors in
2018 Apr 28
2
How to visualise what code is processed within a for loop
Thanks Don, for (i in 1:10){ nm <- paste0("V", i) d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0) } is exaclty what I needed. Best regards, Luca 2018-04-25 23:03 GMT+02:00 MacQueen, Don <macqueen1 at llnl.gov>: > Your code doesn't make sense to me in a couple of ways. > > Inside the loop, the first line assigns a value to an
2018 Apr 30
0
How to visualise what code is processed within a for loop
Hi Rui Thank you for your suggestion, I have tested the code suggested by you against that supplied by Don in terms of timing and results are very much aligned: to populate a 5954x899 0/1 matrix on my machine your procedure took 79 secs, while the one with ifelse employed 80 secs, hence unfortunately not really any significant time saved there. Nevertheless thank you for your contribution.
2018 Apr 30
0
How to visualise what code is processed within a for loop
Thank you for both replies Don & Rui, The very issue here is that there is a search that needs to be done within a text field and I agree with Rui later comment that regexpr might indeed be the time consuming piece of code. I might try to optimise this piece of code later on, but for the time being I am working on the following part of building a neural network to try indeed classifying some
2018 Apr 25
0
How to visualise what code is processed within a for loop
Your code doesn't make sense to me in a couple of ways. Inside the loop, the first line assigns a value to an object named "t". Then, the second line does the same thing, assigns a value to an object named "t". The value of the object named "t" after the second line will be the output of the ifelse() expression, whatever that is. This has the effect of making
2018 Apr 28
0
How to visualise what code is processed within a for loop
Hello, instead of ifelse, the following is exactly the same and much more efficient. d0[[nm]] <- as.integer(regexpr(d1[i,1], d0$X0) > 0) Hope this helps, Rui Barradas On 4/28/2018 8:45 PM, Luca Meyer wrote: > Thanks Don, > > for (i in 1:10){ > nm <- paste0("V", i) > d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0) > }
2018 Apr 24
0
How to visualise what code is processed within a for loop
The loop never assigns anything to d0, only t. The first line makes t a character string "d0$V1" (or "d0$V2" etc.). The second line assigns either 0 or 1 to t. Looking at this, I don't think you've got into the R psychology (bad news if you want to use R, good news in many other ways). I assume d0 is a list, so could you put the V's into a vector, and then just use
2008 Apr 15
1
why does regexpr not work with '.'
Dear R Helpers, I am running R 2.6.2 on a Windows XP machine. I am trying to use regexpr to locate full stops in strings, but, without success. Here an example:- f="a,b.c at d:" #define an arbitrary test string regexpr(',',f) #find the occurrences of ',' in f - should be one at location 2 # and this is what regexpr finds #[1] 2
2010 Jun 01
1
regexpr help (match.length=0)
R-help, Sorry if this is more of a regex question than an R question. However, help would be appreciated on my use of the regexpr function. In the first example below, I ask for all characters (a-z) in 'abc123'; regexpr returns a 3-character match beginning at the first character. > regexpr("[[:alpha:]]*", "abc123") [1] 1 attr(,"match.length") [1] 3
2007 Jun 29
2
regexpr
Hi, I 'd like to match each member of a list to a target string, e.g. ------------------------------ mylist=c("MN","NY","FL") g=regexpr(mylist[1], "Those from MN:") if (g>0) { "On list" } ------------------------------ My question is: How to add an end-of-string symbol '$' to the to-match string? so that 'M' won't
2003 Aug 13
7
Regexpr with "."
I'm trying to use the regexpr function to locate the decimal in a character string. Regardless of the position of the decimal, the function returns 1. For example, > regexpr(".", "Female.Alabama") [1] 1 attr(,"match.length") [1] 1 In trying to figure out what was going on here, I tried the below command: > gsub(".", ",",
2004 Feb 06
3
a grep/regexpr problem
Hi, I'm trying to parse lines of the form: dan001.hin (0): fingerprint={256, 411, 426, 947, 973, 976} What I need is the sequence of number between {}. I'm using grep as match <- grep("{([0-9,\s]*)}",s,perl=T,value=T) where s is a character vector. But all I get is the whole string s. I tried using regexpr in an attempt to get just the sequence I wanted: match <-
2011 Sep 29
2
String manipulation with regexpr, got to be a better way
Help-Rs,   I'm doing some string manipulation in a file where I converted a string date in mm/dd/yyyy format and returned the date yyyy.   I've used regexpr (hat tip to Gabor G for a very nice earlier post on this function) in steps (I've un-nested the code and provided it and an example of what I did below.  My question is: is there a more efficient way to do this.  Specifically is
2010 May 05
1
extracting a matched string using regexpr
Given a text like I want to be able to extract a matched regular expression from a piece of text. this apparently works, but is pretty ugly # some html test<-"</tr><tr><th>88958</th><th>Abcdsef</th><th>67.8S</th><th>68.9\nW</th><th>26m</th>" # a pattern to extract 5 digits > pattern<-"[0-9]{5}" #
2009 Jun 09
2
Sweave and accents
Hello. I want to write my notes in Sweave in my own language (spanish). But my language has accents and when I run Sweave in R to translate my Snw file into the tex file the accents are translated into unrecognizable characters. For example, the word "cami?n" (truck) is translated into "cami??n" Somebody knows how can I do it? One solution I don't like is using a
2010 Sep 22
4
Crash report: regexpr("a{2-}", "")
Each of the following calls crash ("core dumps") R (R --vanilla) on various versions and OSes: regexpr("a{2-}", "") sub("a{2-}", "") gsub("a{2-}", "") EXAMPLES: > sessionInfo() R version 2.11.1 Patched (2010-09-16 r52949) Platform: i386-pc-mingw32 (32-bit) ... > regexpr("a{2-}", "") Assertion
2010 Sep 22
4
Crash report: regexpr("a{2-}", "")
Each of the following calls crash ("core dumps") R (R --vanilla) on various versions and OSes: regexpr("a{2-}", "") sub("a{2-}", "") gsub("a{2-}", "") EXAMPLES: > sessionInfo() R version 2.11.1 Patched (2010-09-16 r52949) Platform: i386-pc-mingw32 (32-bit) ... > regexpr("a{2-}", "") Assertion
2005 Aug 03
2
regexpr and portability issue
Dear all-- I am still forging my first arms with R and I am fighting with regexpr() as well as portability between unix and windoz. I need to extract barcodes from filenames (which are located between a double and single underscore) as well as the directory where the filename is residing. Here is the solution I came to: aFileName <-