search for: gsubfn

Displaying 20 results from an estimated 261 matches for "gsubfn".

2008 Nov 02
5
R newbie: how to replace string/regular expression
Hello; I am a R newbie and would like to know correct and efficient method for doing string replacement. I have a large data set, where I want to replace character "M", "b", and "K" (currency in Million, Billion and K) to millions. That is 209.7B with (209.7 * 10e6) and 100.00K with (100.00 *1/100) and etc.. d <- c("120.0M", "11.01m",
2012 Oct 22
4
¿Problemas al cargar slqdf sobre Windows....?
Hola, Estoy intentando cargar la librería "sqldf" y obtengo este error: > library(sqldf) Loading required package: gsubfn Error : .onLoad failed in loadNamespace() for ''gsubfn'', details: call: get(name, envir = asNamespace(pkg), inherits = FALSE) error: objeto ''addVigs2WinMenu'' no encontrado Error: package ‘gsubfn’ could not be loaded La versión que tengo de sqldf es esta: Pac...
2008 Oct 20
0
New verion 0.3-7 of gsubfn package
Version 0.3-7 of the gsubfn package is available on CRAN. Changes to the package are: - all known bugs have been fixed. - in gsubfn and strapply the replacement object can be a list (or a function, formula, character string or proto object, as before). In the case of a list, regexp matches are looked up in the list n...
2008 Oct 20
0
New verion 0.3-7 of gsubfn package
Version 0.3-7 of the gsubfn package is available on CRAN. Changes to the package are: - all known bugs have been fixed. - in gsubfn and strapply the replacement object can be a list (or a function, formula, character string or proto object, as before). In the case of a list, regexp matches are looked up in the list n...
2006 Mar 28
0
New package gsubfn
gsubfn is a package with one function, gsubfn, that is like gsub except instead of taking a replacement string it takes a replacement function. For each match, that match is passed to the replacement function along with the backreferences, if any, and replaced with the output of the function. If the firs...
2006 Mar 28
0
New package gsubfn
gsubfn is a package with one function, gsubfn, that is like gsub except instead of taking a replacement string it takes a replacement function. For each match, that match is passed to the replacement function along with the backreferences, if any, and replaced with the output of the function. If the firs...
2013 Dec 17
3
In-string variable/symbol substitution: What formats/syntax is out there?
Hi, I'm try to collect a list of methods/packages available in R for doing in-string variable/symbol substitution, e.g. someFcn("pi=${pi}"), anotherFcn("pi=@pi@") and so on becomes "pi=3.141593". I am aware of the following: ** gsubfn() in the 'gsubfn' package, e.g. > gsubfn( , , "pi = $pi, 2pi = `2*pi`") [1] "pi = 3.14159265358979, 2pi = 6.28318530717959" ** gstring() in the 'R.utils' package, e.g. > gstring("pi = ${pi}, 2pi = ${`2*pi`}") [1] "pi = 3.14159265358979, 2pi...
2009 Dec 01
2
Cut intervals (character) to numeric midpoint; regex problem
...ot;(-2.876,-2.756]", "(-2.756,-2.668]", "(-2.668,-2.597]", "(-2.597,-2.539]") I started this message with the thought of requesting an answer but kept asking myself if I really had check the docs and tested my understanding. I eventually solved it using the gsubfn from the gsubfn package: testintvl <-as.numeric(gsubfn("\\((-?[[:digit:]]+.?[[:digit:]]*), (-?[[:digit:]]+.?[[:digit:]]*)\\]", ~ (as.numeric(x)+as.numeric(y))/2, testvec)) # I did discover that carriage returns in the middle of the pattern will not give desired results, so if th...
2012 Aug 24
1
Error while installing gsubfn_0.6-4.tar.gz for R 2.15.1
Hi, I am getting the follwoing error while installing gsubfn_0.6-4.tar.gz library for R. R version is 2.15.1 and i am installing on Redhat linux version 2.6.18-238.9.1.el5 (mockbuild at x86-002.build.bos.redhat.com<mailto:mockbuild at x86-002.build.bos.redhat.com>) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) * installing to library ?/home/mapred...
2007 Sep 07
2
Automatic detachment of dependent packages
...en one loads certain packages, some other dependent packages are loaded as well. Is there some way of detaching them automatically when one detaches the first package loaded? For instance, > library(sqldf) Loading required package: RSQLite Loading required package: DBI Loading required package: gsubfn Loading required package: proto but > detach(package:sqldf) > > search() [1] ".GlobalEnv" "package:gsubfn" "package:proto" [4] "package:RSQLite" "package:DBI" "package:stats" [7] "package:graphics"...
2009 Apr 13
3
toupper does not work in sub + regex
Hi, I don't know what I am doing wrong to the toupper does not seem working in sub + regex. The following returns 's' not the upper class 'S' as I expect: sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw") Can someone tell me where I did wrong? Thanks, Richard [[alternative HTML version deleted]]
2010 Mar 15
2
tcltk and R
...on this blog post: http://translate.google.com/translate?hl=en&sl=zh-CN&u=http://www.wentrue.net/blog/%3Fp%3D453&prev=http://blogsearch.google.com/blogsearch%3Fhl%3Den%26ie%3DUTF-8%26q%3Dsqldf%26lr%3D%26sa%3DN%26start%3D10 sqldf does not directly use tcltk but it does use strapply in gsubfn for its parsing and strapply uses tcl from the tcltk package to it speed up -- there is also an all R version of strapply but the gsubfn package as a whole still depends on tcltk whether or not the user uses tcltk or not. I was thinking of changing the Depends:tcltk of gsubfn to Suggests:tcltk a...
2011 Oct 19
4
Using SQL "IN" with RJDBC or RMySQL
Hello, The code below works fine up until I try to use the "IN" statement in the last line. The proper SQL format is: SELECT * FROM this_table WHERE this_column IN (1,2,3,4,5) But, I think I may be getting something like: SELECT * FROM this_table WHERE this_column IN c(1,2,3,4,5) Which makes no sense in SQL. I think it may be just a matter of string massaging, but I'm not
2008 Oct 28
1
gsubfn, strapply, REGEX Problem
Hi all, I swear this used to work: library(gsubfn) strapply("S(AC,P)TVDK(8)EELVQK(8), ".[(].{1,2}[)]|.")[[1]] But somewhere along the update path it stopped ... now giving me this Error in base::gsub(pattern, rs, x, ...) : invalid backreference 2 in regular expression Can't figure it out. What am I doing wrong? Thanks fo...
2023 Mar 08
1
Augment base::replace(x, list, value) to allow list= to be a predicate?
That's an interesting example, as it's conceptually similar to what Pavel is proposing, but structurally different. gsubfn() is more complicated than a simple switch in the body of the function, and wouldn't work well as an anonymous function. Multiple dispatch can nicely encompass both of these cases. For replace(), library(S7) replace <- new_generic("replace", c("x", "list"), f...
2008 Jun 14
2
strsplit, keeping delimiters
Hi all, Does anyone have a version of strsplit that keeps the string that is split by. e.g. from x <- "A: 123 B: 456 C: 678" I'd like to get c("A:", "123 ", "B: ", "456 ", "C: ", 678) but strsplit(x, "[A-Z]+:") gives me c("", " 123 ", " 456 ", " 678") Any ideas? Thanks,
2023 Mar 07
1
Augment base::replace(x, list, value) to allow list= to be a predicate?
This could be extended to sub and gsub as well which gsubfn in the gusbfn package already does: library(gsubfn) gsubfn("^..", toupper, c("abc", "xyz")) ## [1] "ABc" "XYz" On Fri, Mar 3, 2023 at 7:22?PM Pavel Krivitsky <p.krivitsky at unsw.edu.au> wrote: > > Dear All, > > Currently,...
2010 Jul 16
2
Deleting a variable number of characters from a string
I have a text processing problem I'm hoping someone can help me solve. This issue it this. I have a character string in which I need to delete a variable number of characters from the string. The string itself contains the number of characters to be deleted. The number of characters to be deleted is proceeded by either a "+" or a "-". A toy example: Suppose I have
2008 Nov 02
1
Wishlist: pass args from demo() to source()
...ce if demo passed max.deparse.length (and other args to source). (2) Also a larger max.deparse.length default would be nice to make it less likely one would have to set it in the first place. > R.version.string # Vista [1] "R version 2.8.0 Patched (2008-10-21 r46766)" > demo("gsubfn-si") demo(gsubfn-si) ---- ~~~~~~~~~ Type <Return> to start : > # given number possibly followed by SI letter (e.g. 32.5k where k means 1000) > # replace letter with e followed by appropriate digits. > # (see formatEng2R by Hans-Joerg Bibiko in the R Wiki)...
2010 Oct 08
4
function using values separated by a comma
Hello, I have a dataframe (tab separated file) which looks like the example below - two values separated by a comma, and tab separation between each of these. [,1] [,2] [,3] [ ,4] [1,] 0,1 1,3 40,10 0,0 [2,] 20,5 4,2 10,40 10,0 [3,] 0,11 1,2 120,10 0,0 I would like to calculate the percentage of the smallest number separated by the comma by: 1) summing the values e.g. for