similar to: regexpr mystery can not remove trailing spaces

Displaying 20 results from an estimated 8000 matches similar to: "regexpr mystery can not remove trailing spaces"

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
2010 Dec 21
2
Warning message when items of Hmisc are masked by loading a package.
I've noticed that I get a warning message every time a package masks some functions from Hmisc. The warning message says : Warning message: In identical(get(., i), get(., lib.pos)) : ignoring non-pairlist attributes This happens with eg: library(plyr) library(xtable) I think I've seen this passing by before, but I'm not sure any more. Just thought I'd mention it. Cheers Joris
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
2012 Aug 06
5
regexpr with accents
Hello, I have build a syntax to find out if a given substring is included in a larger string that works like this: d1$V1[regexpr("some text = 9",d1$V2)>0] <- 9 and this works all right till "some text" contains standard ASCII set. However, it does not work when accents are included as the following: d1$V1[regexpr("some t?xt = 9",d1$V2)>0] <- 9 I have
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}" #
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 <-
2008 Aug 20
3
vector operation using regexpr?
Hi, Here's my problem... I have a data frame with three columns containing strings. The first columns is a simple character. I want to get the index of that character in the second column and use it to extract the item from the third column. I can do this using a scalar method. But I'm not finding a vector method. An example is below. col1 col2 col3 'L'
2007 Jul 26
3
substituting dots in the names of the columns (sub, gsub, regexpr)
Dear R users, I have the following two problems, related to the function sub, grep, regexpr and similia. The header of the file(s) I have to import is like this. c("y (m)", "BD (g/cm3)", "PR (Mpa)", "Ks (m/s)", "SP g./g.", "P (m3/m3)", "theta1 (g/g)", "theta2 (g/g)", "AWC (g/g)") To get rid of spaces and
2002 Jun 24
3
RegExpr in ---exclude
Hi there, is it possible to use regular expressions in the exclude-paramter of rsync ? For example: rsync --exclude "/path/to/*/[Ff][Oo][Ll][Dd][Ee][Rr]" I've tried it, but it will take no effect. -- SET THE CONTROLS FOR THE HEART OF THE SUN Jens
2008 Oct 01
1
regexpr syntax question
Greetings R list, I am stuck on a simple syntax problem. I want to list all files in a directory, excluding files of a certain type. I have tried pattern matching as follows: a <- list.files(data, full.name = TRUE, pattern != ".xml") # exclude all .xml files The warning returns that my syntax is incorrect. I have read the regexpr help files and search old posts to no
2010 Oct 28
1
Unexpected behabiour of min, tapply and POSIXct/POSIXlt classes?
Hello, I found rather surprising the behaviour of POSIXct and POSIXlt classes when combined with min and tapply. The details can be deduced from the script below: ############# Start of the script #################### before <- Sys.time() Sys.sleep( 1 ) now1 <- now2 <- Sys.time() my.times <- c( before, now1, now2 ) class( my.times ) ## [1] "POSIXct"
2006 Oct 27
1
Regexpr. analyzer
Hi! I want to index html files, but w/o the tags, so I was thinking either I remove them before I index it (expensive), or put up an RegExpAnalyzer. BTW, when using an analyzer, does that mean that everything which it declines (i.e. the RegExpAnalyzer doesn''t match) won''t be put into the index files (i.e. blows it up)? I came up with a simple test, which didn''t
2010 Jun 08
2
how to ignore rows missing arguments of a function when creating a function?
Hi, I am relatively new to R; when creating functions, I run into problems with missing values. I would like my functions to ignore rows with missing values for arguments of my function) in the analysis (as for example is the case in STATA). Note that I don't want my function to drop rows if there are missing arguments elsewhere in a row, ie for variables that are not arguments of my
2010 Jun 18
3
Non-procedural access to columns of a matrix
Hi, I would like to have an index for a column in a matrix encoded in a cell of the same matrix. For example: x = matrix(c(11,12,13,1, 21,22,23,3, 31,32,33,2),byrow=T,ncol=4) In this case, column 4 is the index. I then access the column specified in the index by: > for (i in 1:3) print(x[i,x[i,4]]) [1] 11 [1] 23 [1] 32 > > for (i in 1:3) {x[i,x[i,4]] <- x[i,x[i,4]] + 5} > x