Ok thank you!
On Mar 17, 12:12 pm, wrote:
> subset(data,grepl("[1-5]", section) & !grepl("0", section))
>
> BTW
>
> grepl("[1:5]", section)
>
> does work. It checks for the characters 1, :, or 5.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-proje
Kang Min
Sent: Thursday, 17 March 2011 1:29 PM
To: r-help@r-project.org
Subject: Re: [R] Subset using grepl
I have a new question, also regarding grepl.
I would like to subset rows with numbers from 1 to 5 in the section
column, so I used
subset(data, grepl("[1:5]", section))
but this ga
I have a new question, also regarding grepl.
I would like to subset rows with numbers from 1 to 5 in the section
column, so I used
subset(data, grepl("[1:5]", section))
but this gave me rows with 10, 1 and 5. (Why is this so?) So I tried
subset(data, grepl("[1,2,3,4,5]", section))
which worked.
On Sat, 29 Jan 2011, Kang Min wrote:
Thanks Prof Ripley, the condition worked!
Btw I tried to search ?repl but I don't have documentation for it. Is
it in a non-basic package?
I meant grepl: the edit messed up (but not on my screen, as sometimes
happens when working remotely). The point is t
Thanks Prof Ripley, the condition worked!
Btw I tried to search ?repl but I don't have documentation for it. Is
it in a non-basic package?
On Jan 29, 6:54 pm, Prof Brian Ripley wrote:
> The grep comdition is "[A-J]"
>
> BTW, why there are lots of unnecessary steps here, including using
> cbind()
The grep comdition is "[A-J]"
BTW, why there are lots of unnecessary steps here, including using
cbind() and subset():
x <- rep(LETTERS[1:20],3)
y <- rep(1:3, 20)
z <- paste(x,y, sep="")
random.data <- rnorm(60)
data <- data.frame(z, random.data)
data[grepl("[A-J]", z), ]
Now (for the paranoi
Hi all,
I would like to subset a dataframe by using part of the level name.
x <- rep(LETTERS[1:20],3)
y <- rep(1:3, 20)
z <- paste(x,y, sep="")
random.data <- rnorm(60)
data <- as.data.frame(cbind(z, random.data))
I need rows that contain the letters A to J, so I tried:
subset(data, grepl(LETTE
7 matches
Mail list logo