[R] gsub in data frame

Lapointe, Pierre Pierre.Lapointe at nbf.ca
Wed Apr 5 13:48:33 CEST 2006


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?

Regards,

Pierre Lapointe

**************************************************
AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{dropped}}




More information about the R-help mailing list