I'm facing an unexpected behavior with base R.
I want to retrieve the first row of a dataframe with its colnames as a vector, and this common method works perfectly for most cases.
df = data.frame(A=c(12,13), B=c(24,25))
unlist(df[1,]) #class=numeric
# A B
# 12 24
But when the dataframe is only composed of one column, the result is coerced to an unnamed vector:
df = data.frame(A=c(12,13))
unlist(df[1,]) #class=numeric too
# 12
How to keep the name is the second case?