Please try to read my earlier comments.
In the absence of a proper example with expected output I think what you
are trying to achieve is:
# create a sample dataframe
df <- data.frame(Command=c("_localize_PD", "_localize_tre_t2",
"_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2"))
#
On Mon, May 2, 2016 at 1:01 PM, ch.elahe via R-help
wrote:
> I just changed all the names in Command to lowercase, then this
> str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have
> any idea how I can bring PDT2 also in str_extract?
>
Looking at ?grepl, I see the option: i
I just changed all the names in Command to lowercase, then this str_extract
works fine for "pd" and "t2", but not for "PDT2". Do you have any idea how I
can bring PDT2 also in str_extract?
On Monday, May 2, 2016 9:16 AM, Tom Wright wrote:
The first thing I notice here is that your first
The first thing I notice here is that your first two subset statements are
searching in an object named Command, not the column df$Command. I'm not at
all sure what you are trying to achieve with the str_extract process but it
is looking for the exact string 'PDT2' the vectors / dataframe formed in
Yes it works, but let me explain what I am going to do. I extract all the names
I want and then create a new column out of them for my plot. This is he whole
thing I do:
PD=subset(df,grepl("pd",Command)) //extract names in Command with only "pd"
t2=subset(df,grepl("t2",Command)) //extract nam
Sorry for the missed braces earlier. I was typing on a phone, not the best
place to conjugate regular expressions.
Using the example you provided:
> df=data.frame(Command=c("_localize_PD", "_localize_tre_t2",
"_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2"))
> grepl("(.*t2.*pd.*)|
Thanks Peter, you were right, the exact grepl is
grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command), but it does not change anything
in Command, when I check the size of it by
sum(grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command)) the result is 0, but I am
sure that the size is not 0. It seems that thi
On 02 May 2016, at 12:43 , ch.elahe via R-help wrote:
> Thanks for your reply tom. After using
> Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error:
> Argument "x" is missing, with no default. Actually I don't know how to fix
> this. Do you have any idea?
Tom's code
Thanks for your reply tom. After using
Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error:
Argument "x" is missing, with no default. Actually I don't know how to fix
this. Do you have any idea?
Thanks,
Elahe
On Saturday, April 30, 2016 7:35 PM, Tom Wright wrote:
A
Actually not sure my previous answer does what you wanted. Using your
approach:
t2pd=subset(df,grepl("t2",df$Command) & grepl("pd",df$Command))
Should work.
I think the regex pattern you are looking for is:
Subset(df,grepl("(.* t2.*pd.* )|(.* pd.* t2.*)",df$Command)
On Sat, Apr 30, 2016, 7:0
subset(df,grepl("t2|pd",x$Command))
On Sat, Apr 30, 2016 at 2:38 PM, ch.elahe via R-help
wrote:
> Hi all,
>
> I have one factor variable in my df and I want to extract the names from
> it which contain both "t2" and "pd":
>
> 'data.frame': 36919 obs. of 162 variables
>$TE:
Your code looks fine to me. What did t2pd look like?
I tried reproducing the problem in R-3.2.4(Revised) and everything worked
(although the output of str() looked a bit different - perhaps you have an
old version of R)
> df <- data.frame(TE=1:10, TR=101:110,
Command=c("pd_local_abdomen_t2","kne
Hi all,
I have one factor variable in my df and I want to extract the names from it
which contain both "t2" and "pd":
'data.frame': 36919 obs. of 162 variables
$TE:int 38,41,11,52,48,75,.
$TR:int 100,210,548,546,.
$Command :factor W/
13 matches
Mail list logo