I have the following array and I would like to convert it to a dataframe with the column names(Time and DepressionCount). I am pretty much a complete beginner to R and some help is greatly appreciated.
2004 2004.25 2004.5 2004.75 2005 2005.25 2005.5 2005.75
875 820 785 857 844 841 726 766
This is what you want:
dd=data.frame(t(array))
colnames(dd) = c("Time", "DepressionCount")
t(array) changes the two lines array into a two columns array, data.frame simply converts the array to a data.frame and colnames changes the column names of the data.frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With