You can always use regular expressions:

> x <- "Condition: 311"
> as.integer(sub(".*?(\\d <file://d/>+).*", "\\1 <file://0.0.0.1/>", x,
perl=TRUE))
[1] 311
>


On Fri, May 8, 2009 at 10:16 AM, Matthias Gondan <matthias-gon...@gmx.de>wrote:

> Dear list,
>
> Apparently, there is no function like sscanf in R.
>
> I have a string, "Condition: 311", and I would like
> to read out the number and store it to a numeric
> variable. Is there an easy way to do this?
>
> Best wishes,
>
> Matthias
> --
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.
  • [R] sscanf Matthias Gondan
    • Re: [R] sscanf jim holtman

Reply via email to