Re: [R] delete "-character from strings in matrix

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Sun 12 Jun 2005 - 21:42:17 EST


Please define "does not work". Here's what I get:

> m <- matrix(paste(letters[1:4], "does not work."), 2, 2)
> m

     [,1] [,2]

[1,] "a does not work." "c does not work."
[2,] "b does not work." "d does not work."

> gsub("does not work.", "", m)

[1] "a " "b " "c " "d "
> structure(gsub("does not work.", "", m), dim=dim(m))

     [,1] [,2]
[1,] "a " "c "
[2,] "b " "d "

R-2.1.0 on WinXPPro.

Andy

> From: Werner Wernersen
>
> Hi!
>

> I have strings where occasionally some "-chars occur.
> How can I delete these chars?
>
> I tried it with gsub but using "" as replace does not
> work.
>
> Thanks a lot for any hint!
> Regards,
> Werner
>
> ______________________________________________
> 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
>
>
>



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 Sun Jun 12 21:47:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:32 EST