Of course! Use regexec() and regmatches()
>
regmatches(dat$varx,regexec("(^[[:digit:]]{1,3})([[:alpha:]]{1,2})([[:digit:]]{1,5}$)",dat$varx))
[[1]]
[1] "9F209" "9" "F" "209"
[[2]]
character(0)
[[3]]
[1] "2F250" "2" "F" "250"
[[4]]
character(0)
[[5]]
character(0)
[[6]]
characte
Thank you so much Bert.
Is it possible to split the varx into three ( area code, region and
the numeric part)as a separate variable
On Thu, Nov 28, 2019 at 7:31 PM Bert Gunter wrote:
>
> Use regular expressions.
>
> See ?regexp and ?grep
>
> Using your example:
>
> > grep("^[[:digit:]]{1,3}[[:
Use regular expressions.
See ?regexp and ?grep
Using your example:
> grep("^[[:digit:]]{1,3}[[:alpha:]]{1,2}[[:digit:]]{1,5}$",dat$varx,value
= TRUE)
[1] "9F209" "2F250" "121FL50"
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking
Hi all, I want to remove a row based on a condition in one of the
variables from a data frame.
When we split this string it should be composed of 3-2- 5 format (3
digits numeric, 2 characters and 5 digits numeric). Like
area code -region-numeric. The max length of the area code should be
3, the
p
Cc:
Sent: Sunday, April 7, 2013 2:31 PM
Subject: [R] Remove a row containing a specific value for a column
Dear all,
Could anyone help me with the following?
DATA <- data.frame(rbind(c("Red1", 1, 1, 1), c("Blue1", 1, 1, 1), c("Red2", 1,
1, 1), c("Red3"
Dear all,
Could anyone help me with the following?
DATA <- data.frame(rbind(c("Red1", 1, 1, 1), c("Blue1", 1, 1, 1), c("Red2", 1,
1, 1), c("Red3", 1, 1, 1)))
colnames(DATA) <- c("A", "B","C", "D")
#Option 1
DATA <- DATA[-2, ] #Same result I would like to achieve with Option 2
#Option 2 - I wou
Thank you Sarah.I'm glad it was a quick fix:
On Fri, Feb 5, 2010 at 8:50 AM, Sarah Goslee <> wrote:
> You're not only removing a row of data, you are invoking the default
> behavior of subset, which is to collapse the subsetted result to the
> smallest possible type, which in this case is a vecto
You're not only removing a row of data, you are invoking the default
behavior of subset, which is to collapse the subsetted result to the
smallest possible type, which in this case is a vector. Vectors have
no rows, and thus no row names.
You need the drop=FALSE argument, as in
ENV <- ENV[-1, , dr
I find this odd because it doesn't appear to happen in larger datasets. I
have the following data set ENV with the first column set as row.names:
> ENV
TPlog
001S29H 0.601
002S42H 0.602
003S43S 0.779
004S43S 0.702
005S51H 0.978
006S52P 2.718
If I apply > ENV <- ENV[-1,] # remove f
9 matches
Mail list logo