Re: [R] gsub in data frame

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Wed 05 Apr 2006 - 22:38:50 EST


Hi

On 5 Apr 2006 at 7:48, Lapointe, Pierre wrote:

From:           	"Lapointe, Pierre" <Pierre.Lapointe@nbf.ca>
To:             	"'r-help@stat.math.ethz.ch'" <r-help@stat.math.ethz.ch>
Date sent:      	Wed, 5 Apr 2006 07:48:33 -0400
Subject:        	[R] gsub in data frame

> Hello,
>
> I have this data frame:
>
> ### begin
>
> d <-data.frame(matrix(c("1","--","bla",2),2,2))
> d
>
> # I want to replace the "--" by "\N" and still get a data frame.

>
> # I tried:
>
> out <-gsub("--","\\\\N",as.matrix(d)) #using as.matrix to get rid of
> factors out cat(out)
>
> # But I lost my data frame
>
> ### end
>
> Any idea?

re formate it back?

data.frame(matrix(out,2,2))

    X1 X2
 1 1 bla
 2 \\N 2

HTH
Petr

>
>
> Regards,
>
> Pierre Lapointe
>
> **************************************************
> AVIS DE NON-RESPONSABILITE: Ce document transmis par
> courrie...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Apr 05 23:06:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 06 Apr 2006 - 00:09:32 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.