-4

How can I divide the data in a single column to multiple columns

[10,
 11,
 12,
 13,
 14,
 15,
 .
 .
 .
]

Now I ant to divide this data into multiple columns like this and assign column values

[a,b,c
 10,11,12
 13,14,15
 16,17,18
.,.,.,
.,.,.,
.,.,.,]

How can I do this R.

Jack Daniel
  • 2,527
  • 3
  • 31
  • 52

1 Answers1

0

If it is a column, we can change it to matrix by

matrix(df1$v1, ncol = 3, byrow=TRUE)

or use the dim

m1 <- df1$v1
dim(m1) <- c(10, 3) #dimension depends on the length of column
akrun
  • 874,273
  • 37
  • 540
  • 662