Suppose df is a dataframe with one named row of numeric observations. I want
to coerce df into a named vector.

 

as.vector does not work as I expected: as.vector(df) returns the original
dataframe, while as.vector(df,mode="numeric") returns an unnamed vector of
NAs.

 

This works: 

 

> v <- as.numeric(as.matrix(df)); names(v) <- names(df);

 

I just wanted check if there was a better/more natural way of doing this?


	[[alternative HTML version deleted]]

