r - Convert an array into a dataframe while adding new row.name column -


i need convert array data frame in such way row.names first column of data frame. example have array of 4 elements:

big small verybig verysmall 12   3     24       20 

converting as.data.frame gives me (big, small, verybig, verysmall) row.rames. want data.frame looks this:

row   column1   column2 1     big       12 2     small     3 3     verybig   24 4     verysmall 20 

where row.names (1,2,3,4) , (big, small, verybig, verysmall) in first data column.

thanks in advance

what want is:

vec <- c(big=12, small=3, verybig=24, verysmall=20) df <- data.frame(col1=names(vec), col2=vec, row.names=null) 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -