r - Dataframe not being converted to a vector -


i'm trying convert dataframe vector. here's sample:

mydataframe <- data.frame(1:4,5:8,9:12)  #create data frame myvector <- as.vector(mydataframe) class(myvector)  #this not vector 

for type of dataframe, can use unlist creating vector includes names , unname(unlist()) remove names. such as:

mydataframe <- data.frame(1:4,5:8,9:12)  #create data frame myvector <- unname(unlist(mydataframe)) #create vector dataframe  myvector is.vector(myvector) 

unlist works in case because simplifies dataframe list structure while as.vector removes attributes. see andrew macdonald's data structure posts more information on why unlist preferred on as.vector


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -