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

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu May 15 14:34:46 CEST 2014



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,y))



> How about if the name of one element is g_ and the name of other elements g_anyword     where any word contain alphanumeric characters and I want to find the one whose name contain only g_?

  grep("g_$", names(v))


Uwe Ligges

>
> Cheers,
>
> Carol
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list