Re: [R] find an empty char in the name of a vector

2014-05-15 Thread arun
Hi, Hi, If the names vector is similar to below: v2 <- c("g_", "", " ","g2","    ", "g3") grep("^$| +",v2) #[1] 2 3 5 #or  grep("^\\s*$",v2) #[1] 2 3 5 A.K. On Thursday, May 15, 2014 6:36 AM, arun wrote: Hi, Assuming that this is the case: v2 <- c("g_", "", "g2","g3")  which(v2=="") #[1

Re: [R] find an empty char in the name of a vector

2014-05-15 Thread Uwe Ligges
On 15.05.2014 12:12, carol white wrote: Hi, I have a vector with the name of an element that is empty. How can I find out the index of this element? The following doesn't work: empty.char = grep('[:blank:||:space:]' ,names(v)) if (length(empty.char)>0) grep("^[[:space:]]*$", c(x,

Re: [R] find an empty char in the name of a vector

2014-05-15 Thread arun
Hi, Assuming that this is the case: v2 <- c("g_", "", "g2","g3")  which(v2=="") #[1] 2 ##Second question v1 <- c("g_", "g_w1", "g_w2", "g_bc3") grepl("\\bg_\\b",v1) #[1]  TRUE FALSE FALSE FALSE v1[grepl("\\bg_\\b",v1)] #[1] "g_" A.K. Hi, I have a vector with the name of an element that is e

[R] find an empty char in the name of a vector

2014-05-15 Thread carol white
Hi, I have a vector with the name of an element that is empty. How can I find out the index of this element? The following doesn't work: empty.char = grep('[:blank:||:space:]' ,names(v)) if (length(empty.char)>0)     How about if the name of one element is g_ and the name of other elements