similar to: regex question

Displaying 20 results from an estimated 7000 matches similar to: "regex question"

2008 Nov 13
1
replacing Na's in a vector with the preceding integer element
Hi, I have a vector where an integer is followed by a randomly varying number of NA elements. I want to replace the NA's with the preceding integer. Let me explain with a simple?example : avec<- c(1,NA,NA,5,NA,3,4,NA,NA,NA,NA,9,NA,0,NA,NA) I want to get the following vector from a : bvec<-c(1,1,1,5,5,3,4,4,4,4,4,9,9,0,0,0) How can I do this with R? Will appreciate all the help that I
2010 Jul 08
2
strsplit("dia ma", "\\b") splits characterwise
\b is word boundary. But, unexpectedly, strsplit("dia ma", "\\b") splits character by character. > strsplit("dia ma", "\\b") [[1]] [1] "d" "i" "a" " " "m" "a" > strsplit("dia ma", "\\b", perl=TRUE) [[1]] [1] "d" "i" "a" " "
2006 Nov 07
1
Gregexpr - extract results with lapply
Gregexpr - extract results with lapply Hello, I need to extract sequences of three upper case letters in a string. In other words, in this string: str <-c("ABC", "this WOUld be gOOD") The result I'm looking for is ABC WOU OOD. With gregexpr, I can get the position and length of the sequences gregexpr('[A-Z]{3}',str,perl=TRUE) [[1]] [1] 1
2008 May 07
6
help with updating to R2.7
Hi, From R 2.6, I would like to update to R2.7. I would like to have some tips on the recommended method of installing the latest versions of an entire list of packages in R2.7 - i.e. all the packages that I have presently installed in R2.6. I am hoping that there is an easier method than fetching the packages individually as I did, to begin with, for R2.6. Additionally, I would like to install
2009 Aug 17
1
regex problems with the escape character
Hi R-users and R-experts, I am having a hard time in figuring out how to tackle regex questions where the "backslash" character is an integral part of the string. Let me explain how I?came across?this problem : I wanted to clearly see all the components in the windows environmental path variable. This is a long string.?For easy readability, I wanted to split up this string so that each
2008 Aug 13
3
Comination of two barcharts and one xyplot
Hi Rhelpers, I would like to have some help with a plot which is beyond my capabilities. This plot that I am seeking involves an overlay of two different barcharts and one xyplot. The code that I have used is the following : #save(df1,file="M:\\KBR\\df1.RData") load(file="M:\\KBR\\df1.RData") # df1$Year.ord created to obtain the right order i.e. 2015M < 2015K
2010 Sep 27
7
Regular expressions: offsets of groups
Dear list! > gregexpr("a+(b+)", "abcdaabbc") [[1]] [1] 1 5 attr(,"match.length") [1] 2 4 What I want is the offsets of the matches for the group (b+), i.e. 2 and 7, not the offsets of the complete matches. Is there a way in R to get that? I know about gsubgn and strapply, but they only give me the strings matched by groups not their offsets. I could write
2008 May 07
6
help with the unique function
Hi, The unique function is easy to understand and use. Beyond that, I want to get also the frequency of repetition of each individual row in a data frame Let me explain with an example : x<-data.frame(a=c(1,2,3,1,2),b=c(2,3,4,2,3),c=c(10,20,30,10,20)) xu<-unique(x) We have, > x ? a b? c 1 1 2 10 2 2 3 20 3 3 4 30 4 1 2 10 5 2 3 20 > xu ? a b? c 1 1 2 10 2 2 3 20 3 3 4 30 I want to get
2008 Jul 03
1
how to capture matching words in a string ?
I need to capture matching words in a string, any ideas ? I tried using gregexpr, but it was no help. In this example, I need to capture ID23423424 and ID324234325 > s <- "sID23423424 apple pID324234325 orange"> gregexpr("ID[0-9]+", s)[[1]][1] 2 20attr(,"match.length")[1] 10 11 _________________________________________________________________
2006 May 06
2
regular expression change in R version 2.3.0?
The interpretation of regular expressions with repetition quantifiers in the 'gregexpr' function seems to have changed between R Version 2.2.0 and 2.3.0. The 'gsub' function, however, gives the same results in R Versions 2.2.0 and 2.3.0. Below is an example that demonstrates the version differences of the 'gregexpr' function. I am not sure whether this new behavior is
2011 Aug 17
2
question regarding gregexpr and read.table
Hi, I have a silly question regarding the usage of two commands: read.table and gregexpr: For read.table, if I read a matrix and set header = T, I found that all the dash ("-") becomes dots (".") A = read.table("Matrix.txt", sep = "\t", header = F) A[1,1] # "A-B-C-D". A = read.table("Matrix.txt", sep = "\t", header = T)
2009 Feb 25
1
Using gregexpr with multiple search elements
Dear list, I am trying to use gregexpr to see if entries in a dataframe have either of two possible values for a string. here's an example text<-c("fat", "rat", "cat", "dog", "log", "fish") If I just wanted to find if any one of the elements in text match the pattern "at" I would do gregexpr("\\at", text)
2007 May 22
1
regexp bug in very recent r-devel
completion is semi-broken in today's r-devel, and the reason seems to be some regular expression changes: > sessionInfo() R version 2.6.0 Under development (unstable) (2007-05-22 r41673) i686-pc-linux-gnu locale: [...] attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7]
2019 Feb 19
1
patch for gregexpr(perl=TRUE)
Hi all, Several people have noticed that gregexpr is very slow for large subject strings when perl=TRUE is specified. - https://stackoverflow.com/questions/31216299/r-faster-gregexpr-for-very-large-strings - http://r.789695.n4.nabble.com/strsplit-perl-TRUE-gregexpr-perl-TRUE-very-slow-for-long-strings-td4727902.html - https://stat.ethz.ch/pipermail/r-help/2008-October/178451.html I figured out
2007 Dec 30
2
Installing Rgraphviz package on a windows vista pc
Hi, I want to install Rgraphviz on a windows vista pc. The only source file that I found in the bioconductor homepage is a tar file. I can't install from this using the packages command in the R menu. I would like to get some tips on how I can do the installation. Can I just place the extracted Rgraph folder (from the source tar file) in the library folder of R2.6.1 along with the other
2011 Nov 09
1
installing java on ubuntu 11.10 installation
Dear list members, I am starting to get acquainted with linux on a ubuntu 11.10 installation on an external hard disk. I have just installed R and all the packages available in the r-cran-* list. Now, I would like to get on with the installation of packages like Deducer and Acinonyx. The former requires JGR which in turn requires Java. I have tried to follow the instructions available at the
2007 Oct 10
4
gregexpr (PR#9965)
Full_Name: Peter Dolan Version: 2.5.1 OS: Windows Submission from: (NULL) (128.193.227.43) gregexpr does not find all matching substrings if the substrings overlap: > gregexpr("abab","ababab") [[1]] [1] 1 attr(,"match.length") [1] 4 It does work correctly in Version 2.3.1 under linux.
2011 May 21
1
dealing with sweave.sty and pgfSweave
Hi, I would appreciate some help with a very basic problem in using pgfSweave. That is, dealing with the sweave.sty file. After some googling, I did the following : (1) copied the sweave.sty file to my trial folder and (2) added the line?? \usepackage{Sweave}?? to the Rnw file. Are there more elegant ways of dealing with this issue? I have read something about letting Miktex know about the
2010 Feb 08
2
the hat ^ in regular expression
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20100208/52a6d080/attachment.pl>
2009 Jul 31
1
help in using gsub and ?
Hi all, I would like to strip the R prompt from a series of code lines and copy the resulting text into a R script. For example, consider the following : ##### str1<-" > library(MASS) > data(Cars93) > attach(Cars93) > imosaic(data.frame(AirBags,Cylinders,Origin))" str2<-gsub('>','',str1) ###### This gives, as expected .? > str2 [1] "\n