Remko,

Thank you for your reply. When I try your code, I'm getting the following
error:

acts10 <-read.table('RailAccident10.txt',sep=',',header=T)
> acts11 <- acts10[acts10$ACCDMG > 10^5,]
> h.test <- substr(acts11$CAUSE,1,1)
> h.data <- acts11[h.test == 'H']
Error in `[.data.frame`(acts11, h.test == "H") :
  undefined columns selected

To confirm that acts11$CAUSE is there, I did this:
summary(substr(acts11$CAUSE,1,1)=='H')

And got this:

   Mode   FALSE    TRUE    NA's
logical     393     156       0

Any idea what I'm doing wrong?

Thanks again, I really appreciate your help.
On Sun, Nov 20, 2011 at 7:13 PM, Remko Duursma [via R] <
ml-node+s789695n4090042h18@n4.nabble.com> wrote:

>
> dfr <- data.frame(txt= c("abab","ghghg","ththt","dfdfdf"), yvar=1:4)
>
> ind <- substr(dfr$txt,1,2)
>
> dfr[ind == "ab",]
>
>
>
> greetings,
> Remko
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/Searching-for-the-first-two-characters-of-a-string-tp4089862p4090042.html
>  To unsubscribe from Searching for the first two characters of a string, click
> here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4089862&code=YWxhbi5jbGluYXJkQGdtYWlsLmNvbXw0MDg5ODYyfC01NTMwMzEzOTY=>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://r.789695.n4.nabble.com/Searching-for-the-first-two-characters-of-a-string-tp4089862p4091786.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

