[R] Convert list to data frame

Karim Mezhoud kmezhoud at gmail.com
Sat Feb 27 16:52:06 CET 2016


To known the format of your object, please use
class(Data)
str(Data)

Be sure to have regular space between strings in your file.txt.
Karim

On Sat, Feb 27, 2016 at 3:56 PM, Ivan Calandra <ivan.calandra at univ-reims.fr>
wrote:

> Hi,
>
> I have seen this question a few days/weeks ago...
>
> Data.frames are special list, so it's normal.
> Read the help for read.table(), especially the "value" section (where the
> output of the function is described). And read also some introductory
> material, where the different data types are explained.
>
> HTH,
> Ivan
>
> --
> Ivan Calandra, PhD
> University of Reims Champagne-Ardenne
> GEGENAA - EA 3795
> CREA - 2 esplanade Roland Garros
> 51100 Reims, France
> +33(0)3 26 77 36 89
> ivan.calandra at univ-reims.fr
> --
> https://www.researchgate.net/profile/Ivan_Calandra
> https://publons.com/author/705639/
>
>
> Le 27/02/2016 15:04, asma.rabe at gmail.com a écrit :
>
>> Hi,
>>
>> I  read data from file as follows
>>
>> Data<-read.table("file.txt",header=T,sep="\t")
>>
>> mode(Data)
>> list
>>
>> 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
>>
>> 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
>>
>>
>> Sent from my iPhone
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>>
>>
> ______________________________________________
> R-help at r-project.org 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list