Hi all,
>From  one of the columns of the data frame I want to search and
extract  a text that contains Tall or   Short  and create new column
that should contain these texts in a corresponding row.
My example data and the desired output are shown below

dat<-read.table(text="obs Year char
1  2001 Tall156
2  2002 12565Tall
3  2003 all54
4  2004 Short
5  2005 54all
6  2006 7Short12 ",header=TRUE,stringsAsFactors=F)
dat$new <- "      "

Desired out put
obs Year     char        new
   1 2001   Tall156      Tall
   2 2002 12565Tall    Tall
   3 2003     all54
   5 2004     Short      Short
   6 2005     Shall54
   7 2006  7Short12   Short

How do I get my desired output?
Thank you.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to