How to reshape a dataset in R



Hi all,

i am new to R so please help me solving below query.

Query:i need create a data frame of 3 vectors with random values in it and convert 3 vectors to 1 vector without using Reshape package.

To make it simple i need to convert 3 columns to 1 column without Reshape package.

Can that be done.


Hi @sivateja,

just curious, why is it necessary to not use Reshape package?


Hi @jalFaizy,

No specific reason but this is an assignment given to me


Well although I don’t know R, a simple thing you can do is to consider each vector as a string value and concatenate them.

For example,

A, B, C
0.1, 0.2, 0.1
0.3, 0.1, 0.2

Concatenating these up with the formula “str(A) + "-" + str(B) + "-" + str(C )” will result in the following



Thank you, will try this.


Hi Siva,
Please use the below mentioned function to get the required output without using reshape

Creating a data set

a <- c(1,2,3)
b <- c(4,5,6)
d <- c(7,8,9)

e <-,b,d))

#####Function to get the desired output ########
datalist = list()
for (i in 1:nrow(e)) {
f <- paste(e$a[i], “,”, e$b[i],",",e$d[i])
datalist[[i]] <- f

h <-, datalist)