Skip to content

one long column of data -> three small columns

7 messages · frenchcr, Peter Alspach, Jorge Ivan Velez +2 more

#
Tena koe

?matrix 

The exact syntax will depend on the class of your 'column of data'.  If
it is a dataframe, for example, then try

matrix(yourData[,1], 3, 3)

HTH ...

Peter Alspach
#
frenchcr wrote:
ok, so matrix(x, 3, 3) works.

what if i have 

a
b
c
a
c
a
c

and want

a b c
a   c
a   c

??
#
On Tue, 03-Nov-2009 at 12:26PM -0800, frenchcr wrote:
|> > How do i do this?
|> > 
|> 
|> ok, so matrix(x, 3, 3) works.
|> 
|> what if i have 
|> 
|> a
|> b
|> c
|> a
|> c
|> a
|> c
|> 
|> and want
|> 
|> a b c
|> a   c
|> a   c
|> 
|> ??

Hint 1: A matrix can use characters or numerics
Hint 2: "" can be considered as a character.

HTH
#
Hello ?,
Have a look at ?matrix
	matrix(c(2, 3, 4, 2, 1, 6, 6, 4, 7), ncol = 3)
Fran?ois

-----Message d'origine-----
De?: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] De la part de frenchcr
Envoy??: mardi 3 novembre 2009 20:06
??: r-help at r-project.org
Objet?: [R] one long column of data -> three small columns


say i have a column of data like this...

2
3
4
2
1
6
6
4
7

and i want it in three columns like this

226
314
467

...so i can make a contour plot.


How do i do this?