Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert vector from 1-row table in R

Tags:

r

vector

row

In R, I have a 1-row table. How do I convert that to a vector?

Specifically, the table is this:

 0  1  2  3  4 
21 35 46 62 36 

I've tried bracket notation but to no avail!

like image 513
user5243421 Avatar asked Sep 30 '09 07:09

user5243421


People also ask

How do I convert a row to a vector in R?

If we want to turn a dataframe row into a character vector then we can use as. character() method In R, we can construct a character vector by enclosing the vector values in double quotation marks, but if we want to create a character vector from data frame row values, we can use the as character function.

How do I convert a row vector to a column vector in R?

Rotating or transposing R objects frame so that the rows become the columns and the columns become the rows. That is, you transpose the rows and columns. You simply use the t() command. The result of the t() command is always a matrix object.

How do I convert something to a vector in R?

To convert List to Vector in R, use the unlist() function. The unlist() function simplifies to produce a vector by preserving all atomic components.


1 Answers

or you could use as.vector(x)

like image 62
rcs Avatar answered Oct 19 '22 09:10

rcs