Convert the unknown file format to dataframe in R

r
dataframe

#1

I have a .dat file, the contents are not in a csv or tsv file, it’s contents look like the below:

[1] "<Overall Rating>4"                                                                                                                
[2] "<Avg. Price>$173"                                                                                                                 
[3] "<URL>http://www.tripadvisor.com/ShowUserReviews-g60878-d72572-r23327047-Best_Western_Pioneer_Square_Hotel-Seattle_Washington.html"
[4] ""                                                                                                                                 
[5] "<Author>everywhereman2"

I want to know how to convert this into a dataframe in R. The contents between the < and > would be the column name and following should be the corresponding entry.
I realize I could hard code string extraction corresponding to every column, but is there any inbuilt method?
Please help!


#2

you can use memisc to import stata .dta file into R

also read this


#3

@ajay_ohri The link that you have provided deals with tables as input. I have the data in the format that you can see in the question, I have edited the question to make that clearer. Please edit your answer accordingly.

Thanks!


#4

You might need to .check levels and drop them if needed. You can use
as.data.frame(your file name)

to convert it into data frame