[R] Extracting numeric part from a string

Ismail SEZEN sezenismail at gmail.com
Thu Aug 3 02:16:32 CEST 2017


> On 3 Aug 2017, at 02:59, Christofer Bogaso <bogaso.christofer at gmail.com> wrote:
> 
> Hi again,
> 
> I am struggling to extract the number part from below string :
> 
> "\"cm_ffm\":\"563.77\""
> 
> Basically, I need to extract 563.77 from above. The underlying number
> can be a whole number, and there could be comma separator as well.
> 
> So far I tried below :
> 
>> library(stringr)
> 
>> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
> 
> [1] "563"
> 
>> 
> 
> However, above code is only extracting the integer part.
> 
> Could you please help how to achieve that. Thanks,


library(readr)
parse_number('"cm_ffm":"563.77”')



More information about the R-help mailing list