Displaying 20 results from an estimated 4000 matches similar to: "Extracting numeric part from a string"
2017 Aug 03
2
Extracting numeric part from a string
... Or if you just want to stick with basic regex's without extra packages:
> x <- "\"cm_ffm\":\"563.77\""
> sub("[^[:digit:]]*([[:digit:]]*.?[[:digit:]]*).*","\\1",x)
[1] "563.77"
Cheers,
Bert
On Wed, Aug 2, 2017 at 5:16 PM, Ismail SEZEN <sezenismail at gmail.com> wrote:
>
>> On 3 Aug 2017, at 02:59,
2017 Aug 03
0
Extracting numeric part from a string
> 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
2017 Aug 03
0
Extracting numeric part from a string
... and Marc's solution is **much** better than mine.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Wed, Aug 2, 2017 at 5:59 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> ... Or if you just want to stick with
2017 Aug 03
0
Extracting numeric part from a string
> On Aug 2, 2017, at 6:59 PM, 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
2011 Jul 07
1
Working with string
Hi there, I have to extract some relevant portion from a defined string,
which is a mix of numeric and character. However this has following
sequence:
Some String - Some numerical - "c/C" (or "p/P") - then again some set of
numbers.
Examples of such string is "fdahsdfcha163517253c463278643" or
"fdahsdfcha163517253C463278643" or
2017 Jul 18
4
Creating/Reading a complex string in R
Thanks for your pointer.
Is there any way in R how to replace " ' " with " /' " programmatically?
My actual string is quite lengthy, so changing it manually may not be
possible. I am aware of gsub() function, however not sure I can apply
it directly on my original string.
Regards,
On Tue, Jul 18, 2017 at 10:27 PM, John McKown
<john.archie.mckown at gmail.com>
2013 Mar 14
3
Working with string
Hello again,
Let say I have following string:
Vec <- c("sada", "asdsa", "sa")
Now I want to make each element of this vector with equal length.
Basically I want following vector:
c("sada ", "asdsa", "sa ")
Therefore we can get:
> nchar(c("sada ", "asdsa", "sa "))
[1] 5 5 5
Is there any
2024 Sep 08
1
Reading a txt file from internet
On 2024-09-07 7:37 p.m., Jeff Newmiller wrote:
> I tried it on R 4.4.1 on Linux Mint 21.3 just before I posted it, and I just tried it on R 3.4.2 on Ubuntu 16.04 and R 4.3.2 on Windows 11 just now and it works on all of them.
>
> I don't have a big-endian machine to test on, but the Unicode spec says to honor the BOM and if there isn't one to assume that it is big-endian data.
2013 Mar 20
2
Pattern match
Hello again, in the help page of grep() function, it is written that
pattern:
character string containing a regular expression (or character string
for fixed = TRUE) to be matched in the given character vector. Coerced
by as.character to a character string if possible. If a character
vector of length 2 or more is supplied, the first element is used with
a warning. Missing values are allowed
2011 Feb 03
2
Sorting a Data Frame by hybrid string / number key
Hi,
I'm trying to present a table of some experimental data, and I want to order
the rows by the instance names. The issue I've got is that there are a
variety of conventions for the instance names (e.g. competition01,
competition13, small_1, big_20, med_9). What I want to be able to sort them
first in category order so: competition < small < med < big, and then
perform the
2019 Aug 15
4
Feature request: non-dropping regmatches/strextract
A very common use case for regmatches is to extract regex matches into a new column in a data.frame (or data.table, etc.) or otherwise use the extracted strings alongside the input. However, the default behavior is to drop empty matches, which results in mismatches in column length if reassignment is done without subsetting.
For consistency with other R functions and compatibility with this use
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration)
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Lapply_me(as.list(1:4), function(xx) {
if (xx ==
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code:
> library(zoo)
> a <- as.yearmon("March-2010", "%B-%Y")
> b <- as.yearmon("May-2010", "%B-%Y")
>
> nn <- (b-a)*12 # number of months in between them
> nn
[1] 2
> as.integer(nn)
[1] 1
What is the correct way to find the number of months between "a" and "b",
still
2018 Mar 04
0
Change Function based on ifelse() condtion
The reason that it works for Apply_MC=TRUE is that in that case you call
mclapply(X,FUN,...) and
the mclapply() function strips off the mc.cores argument from the "..."
list before calling FUN, so FUN is being called with zero arguments,
exactly as it is declared.
A quick workaround is to change the line
Lapply_me(as.list(1:4), function(xx) {
to
Lapply_me(as.list(1:4),
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below :
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Here, I am not passing ... anymore rather passing myList
On Sun, Mar 4, 2018 at 10:37 PM,
2018 Mar 04
2
Change Function based on ifelse() condtion
@Eric - with this approach I am getting below error :
Error in FUN(X[[i]], ...) : unused argument (list())
On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjberger at gmail.com> wrote:
> Hi Christofer,
> You cannot assign to list(...). You can do the following
>
> myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>
> HTH,
> Eric
>
> On Sun, Mar
2019 Sep 23
5
Consulta
Buenas tarde a todo en s:
Tenia la versión de R 3.6 y utilizaba la paquetería de pdftools para extraer información de archivos en pdf actualice la versión 3.6.1 y ya no reconoce la paquetería alguien que me pueda ayudar. Prácticamente no reconoce las funciones de pdftools
library(pdftools)
library(stringr)?
library(NLP)?
library(tm)?
library(tesseract)?
library(magick)?
2012 Dec 14
5
A question on list and lapply
Dear all, let say I have following list:
Dat <- vector("list", length = 26)
names(Dat) <- LETTERS
My_Function <- function(x) return(rnorm(5))
Dat1 <- lapply(Dat, My_Function)
However I want to apply my function 'My_Function' for all elements of
'Dat' except the elements having 'names(Dat) == "P"'. Here I have
specified the name
2012 Mar 16
4
How to start R in maximized size???
Dear all, when I start R, I want that the console window should be in
the Maximized size automatically. Can somebody help me how to achieve
that?
Thanks and regards,
2013 Jul 15
3
ayuda con stringr
Hola a todos.
Soy un poco torpe manejando cadenas de texto, así que os pido ayuda.
Tengo un vector de texto de este tipo
datos$tipo
[1] m.1.p.Álava m.1.p.Albacete
[3] m.2.p.Alicante m.1.p.Almería
[5] m.3.p.Asturias m.1.p.Ávila
[7] m.1.p.Badajoz m.1.p.Baleares (Illes)
[9] m.1.p.Barcelona m.1.p.Burgos
[11] m.1.p.Cáceres m.1.p.Cádiz
Y quiero extraer el