Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Paul Johnson
Henrik's proposal works well, so far. Thanks very much. I could not have figured that out (without much more suffering). Here's the working example in case future googlers find their way to this thread. ## Paul Johnson ## 2012-01-30 ## Special thanks to r-help email list contributors, ## espe

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Duncan Murdoch
On 30/01/2012 1:26 PM, Paul Johnson wrote: A user question today has me stumped. Can you advise me, please? User wants a matrix that has some numbers, some variables, possibly even some function names. So that has to be a character matrix. It might make more sense for it to be a list-mode ma

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Gabor Grothendieck
On Mon, Jan 30, 2012 at 1:26 PM, Paul Johnson wrote: > A user question today has me stumped.  Can you advise me, please? > > User wants a matrix that has some numbers, some variables, possibly > even some function names.  So that has to be a character matrix. > Consider: > >> BM <- matrix("0.1", 5

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Henrik Bengtsson
The quick solution: parseAndEval <- function(x, ...) eval(parse(text=x)) apply(BM, MARGIN=c(1,2), FUN=parseAndEval) My $.02 /Henrik On Mon, Jan 30, 2012 at 10:26 AM, Paul Johnson wrote: > A user question today has me stumped.  Can you advise me, please? > > User wants a matrix that has some nu

Re: [R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Richard M. Heiberger
Are you sure this isn't a dataframe? Some minor rethinking of the structure might get it there. Rich On Mon, Jan 30, 2012 at 1:26 PM, Paul Johnson wrote: > A user question today has me stumped. Can you advise me, please? > > User wants a matrix that has some numbers, some variables, possibly

[R] replacing characters in matrix. substitute, delayedAssign, huh?

2012-01-30 Thread Paul Johnson
A user question today has me stumped. Can you advise me, please? User wants a matrix that has some numbers, some variables, possibly even some function names. So that has to be a character matrix. Consider: > BM <- matrix("0.1", 5, 5) Use data.entry(BM) or similar to set some to more abstract

Re: [R] Replacing characters

2010-08-10 Thread Henrique Dallazuanna
Try this: library(RMySQL) #conn <- dbConnect(...) mysqlEscapeStrings(conn, "tes't") On Tue, Aug 10, 2010 at 3:02 AM, Orvalho Augusto wrote: > Hello guys! May be I am lazy but > > I need to replace a character like \ or ' or to escape them in a character > vector to write a SQL statement. > > Ho

Re: [R] Replacing characters

2010-08-10 Thread David Winsemius
On Aug 10, 2010, at 2:02 AM, Orvalho Augusto wrote: Hello guys! May be I am lazy but I need to replace a character like \ or ' or to escape them in a character vector to write a SQL statement. ?sub ?regex How can I do that? Caveman -- David Winsemius, MD West Hartford, CT ___

[R] Replacing characters

2010-08-09 Thread Orvalho Augusto
Hello guys! May be I am lazy but I need to replace a character like \ or ' or to escape them in a character vector to write a SQL statement. How can I do that? Caveman [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] replacing characters in formulae / models

2008-11-06 Thread Gabor Grothendieck
Try this: library(alr3) library(gsubfn) example(delta.method) # defines m1 num <- 2 fn$delta.method(m1, "-b1/($num*b2)") See gsubfn home page at: http://gsubfn.googlecode.com On Thu, Nov 6, 2008 at 12:13 PM, Christoph Scherber <[EMAIL PROTECTED]> wrote: > Dear all, Dear Keith, > > Well, of cou

Re: [R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber
Dear all, Dear Keith, Well, of course in fact the problem is more complicated than that. The example was just for illustration. I have several statistical models for which I want to retrieve predictions using delta.method (from library(alr3)). Now for this I need a character string such as

Re: [R] replacing characters in formulae / models

2008-11-06 Thread Keith Jewell
Hi, Firstly, I'd recommend using '<-' for assignment, rather than '='; it saves confusion Secondly, I don't think you want 'a*x+b' as a formula, I think you want an expression. Thirdly, your 'y' has only one term, a 9 character constant = "a * x + b" Consider instead, y <- expression(a*x+b) a

Re: [R] replacing characters in formulae / models

2008-11-06 Thread Charles C. Berry
On Thu, 6 Nov 2008, Christoph Scherber wrote: Dear all, How can I replace text in objects that are of class "formula"? y="a * x + b" class(y)="formula" grep("x",y) y[1] What exactly are you trying to accomplish?? And why did you assign 'formula' as the class of a character string? 'y' is

[R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber
Dear all, How can I replace text in objects that are of class "formula"? y="a * x + b" class(y)="formula" grep("x",y) y[1] Suppose I would like to replace the "x" by "w" in the formula object "y". How can this be done? Somehow, the methods that can be used in character objects do not work 1:1