Re: [R] charactor matrix convert to numeric matrix

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Wed, 02 Jun 2010 09:38:48 -0400

Hi Jian,

Try

matrix(as.numeric(a), ncol = 2)

HTH,
Jorge

On Wed, Jun 2, 2010 at 8:15 AM, Yuan Jian <> wrote:

> Hello R experts,
> can you tell me a simple way to convert a charactor matrix to numeric
> matrix?
> if I use as.numeric, the matrix is converted to a vector.
>
> a<-cbind(c("23","54","65"),c("1","2","3"))
> a
> [,1] [,2]
> [1,] "23" "1"
> [2,] "54" "2"
> [3,] "65" "3"
>
> as.numeric(a)
> [1] 23 54 65 1 2 3
>
> thanks
> Jian
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jun 2010 - 13:42:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 13:50:27 GMT.

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

list of date sections of archive