Perhaps I've missed something, but if it's really true that the goal is to
remove rows if the first non-zero element is "D" or "d", then how about
this:
tmp <- gsub('0','',df$ch)
first <- substr(tmp,1,1)
subset(df, tolower(first) != 'd')
and of course it could be rolled up into a single expressio
Got it! Thank you Rui!
cp
On Tue, Jul 3, 2012 at 10:14 AM, Rui Barradas wrote:
> Hello,
>
> I'm glad it helped. See answer inline.
>
> Em 03-07-2012 17:09, Claudia Penaloza escreveu:
>
> Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly
>> because there are no instances of 'Dd' or '
Hello,
I'm glad it helped. See answer inline.
Em 03-07-2012 17:09, Claudia Penaloza escreveu:
Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly
because there are no instances of 'Dd' or 'dD' in the data set (that I
would/not want to include/exclude)... but I understand that 'i1new'
Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly because there
are no instances of 'Dd' or 'dD' in the data set (that I would/not want to
include/exclude)... but I understand that 'i1new' targets precisely what I
want.
Why isn't a leader of zero's required for either 'i1' or 'i1new',
Hello,
Inline.
Em 03-07-2012 01:15, jim holtman escreveu:
You will have to change the 'i1' expression as follows:
i1 <- grepl("^([0D]|[0d])*$", dd$ch)
i1 # matches strings with d & D in them
[1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# second string had 'd' & 'D' in
From: Rui Barradas
To: Claudia Penaloza
Cc: r-help@r-project.org
Sent: Monday, July 2, 2012 7:24 PM
Subject: Re: [R] Removing rows if certain elements are found in character string
Hello,
Try regular expressions instead.
In this data.frame, I've changed row nr.4 to have a row wi
07368;
9 9 T000 0.002456;
A.K.
- Original Message -
From: Claudia Penaloza
To: r-help@r-project.org
Cc:
Sent: Monday, July 2, 2012 6:48 PM
Subject: [R] Removing rows if certain elements are found in character string
I would like to remove rows from the fo
On Jul 2, 2012, at 6:48 PM, Claudia Penaloza wrote:
I would like to remove rows from the following data frame (df) if
there are
only two specific elements found in the df$ch character string (I
want to
remove rows with only "0" & "D" or "0" & "d"). Alternatively, I
would like
to remove ro
You will have to change the 'i1' expression as follows:
> i1 <- grepl("^([0D]|[0d])*$", dd$ch)
> i1 # matches strings with d & D in them
[1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> # second string had 'd' & 'D' in it so it was TRUE above and FALSE below
> i1new <- grepl("^(
Hello,
Try regular expressions instead.
In this data.frame, I've changed row nr.4 to have a row with 'D' as
first non-zero character.
dd <- read.table(text="
ch count
1 00D0 0.007368
2 00d0 0.002456
3
I would like to remove rows from the following data frame (df) if there are
only two specific elements found in the df$ch character string (I want to
remove rows with only "0" & "D" or "0" & "d"). Alternatively, I would like
to remove rows if the first non-zero element is "D" or "d".
11 matches
Mail list logo