Re: [R] convert a vector of words into a matrix

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Thu, 24 Jul 2008 08:22:06 -0300

Try this:

print(t(sapply(strings, '[', 1:max(sapply(strings, length)))), na=".")

On 7/24/08, Daren Tan <daren76_at_hotmail.com> wrote:
>
> I want the matrix to look like this:
>
> [,1] [,2] [,3] [,4]
> [1,] "1" "2" "3"
> [2,] "1" "2" [3,] "1" "2" "4" "5"
>
> I tried to use do.call(rbind, strings) but failed due to unequal row lengths.
> > Date: Thu, 24 Jul 2008 09:35:21 +0100> From: pburns@pburns.seanet.com> To: daren76@hotmail.com> CC: r-help@stat.math.ethz.ch> Subject: Re: [R] convert a vector of words into a matrix> > And what should the matrix look like?> > > Patrick Burns> patrick@burns-stat.com> +44 (0)20 8525 0696> http://www.burns-stat.com> (home of S Poetry and "A Guide for the Unwilling S User")> > Daren Tan wrote:> > How to convert the strings into matrix ?> > > > (strings <- strsplit(c("1 2 3", "1 2", "1 3 4 5"), " "))[[1]][1] "1" "2" "3"> > [[2]][1] "1" "2"> > [[3]][1] "1" "3" "4" "5"> > > > _________________________________________________________________> > Easily edit your photos like a pro with Photo Gallery.> >> > [[alternative HTML version deleted]]> >> > ______________________________________________> > R-help@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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
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 Thu 24 Jul 2008 - 11:34:38 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 Thu 24 Jul 2008 - 12:32:26 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