[R] Convert list to data frame

Sarah Goslee sarah.goslee at gmail.com
Mon Feb 15 20:08:30 CET 2016


On Monday, February 15, 2016, <asma.rabe at gmail.com> wrote:

> Hi,
>
> I  read data from file as follows
>
> Data<-read.table("file.txt",header=T,sep="\t")
>
> mode(Data)
> list


Data is a data frame; that's what read.table() produces. A data frame is a
special type of list.

Take a look at
class(Data)



>
> I want to convert data to data frame, I tried the following:
>
> as.data.frame(Data)
> data.frame(Data)
>
> But the Data did not change


Because it was already a data frame.



>
> When I tried
> as.data.frame(unlist(Data))
>
> The Data converted to a vector not to a data frame. Any idea ?
>
> Thank you in advance
>
> ______________________________________________
> R-help at r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE and
> more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

	[[alternative HTML version deleted]]



More information about the R-help mailing list