[R] Importing name/value formatted data

Karl Ove Hufthammer
Tue, 06 Mar 2012 16:06:45 -0000

Hi!

Does anybody know about an R function for importing paired
name/value data, where each pair is separated by a fixed
string (e.g., a semi-colon), and within each pair a
different delimeter is used (e.g., an equals sign).
Example:

x="FirstName=John;LastName=Doe;Age=75;\nFirstName=Jane;LastName=Doe\nLastName=Bloggs;Age=42;FirstName=Joe"

Note that the order of the fields differ between the
rows/records, and not all rows contain all fields.

The result should be a data frame:

FirstName    LastName   Age
John         Doe        75
Jane         Doe
Joe          Bloggs     42

I guess it?s not too difficult to write a function for this,
using a bunch of strsplit functions and perhaps some
rbind.fill and type.convert, but if there already exists such
a function, there?s no need reinventing the wheel. :)

So, does anybody know of such a function? I tried searching
for one, but I don?t know what this type of data format
is called.

--
Karl Ove Hufthammer