Importing JSON Files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Importing JSON Files

reichmaj
r-help Forum

Struggling with importing and creating a data.fram from a JSON file.  I used the jsonlite package (fromJSON function) and I can see the resulting table but one of the attributes is a list (of lists) So I have something that looks like .....

favorites (attribute)
list(favoriteValue = c("12345", 23456"), resourceType = c("abc", "def"), classification = c("xxx","yyy"))

So when I attempt to create a data.frame R errors out.  I'm assuming it is because of the list(s).  Don't know what to do with it (the list).  I need the "favoriteValue (s)."

Ultimate I want to run the arules package

Jeff Reichman

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Importing JSON Files

K. Elo-2
Hi!

Have you tried to use 'fromJSON' with the parameter 'simplifyDataFrame'
set to TRUE?

See:
https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html
 -> Section "Data Frames" explains how this affects the data frame
structure. IMHO this should solve your problem...

Best,
Kimmo

2018-11-05 19:00 +0000, JEFFERY REICHMAN wrote:

> r-help Forum
>
> Struggling with importing and creating a data.fram from a JSON
> file.  I used the jsonlite package (fromJSON function) and I can see
> the resulting table but one of the attributes is a list (of lists) So
> I have something that looks like .....
>
> favorites (attribute)
> list(favoriteValue = c("12345", 23456"), resourceType = c("abc",
> "def"), classification = c("xxx","yyy"))
>
> So when I attempt to create a data.frame R errors out.  I'm assuming
> it is because of the list(s).  Don't know what to do with it (the
> list).  I need the "favoriteValue (s)."
>
> Ultimate I want to run the arules package
>
> Jeff Reichman
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Importing JSON Files

reichmaj
Kimmo

Didn't perform exactly how I wanted but got me looking in the right area.
Thank you

Jeff

-----Original Message-----
From: R-help <[hidden email]> On Behalf Of K. Elo
Sent: Monday, November 5, 2018 1:14 PM
To: [hidden email]
Subject: Re: [R] Importing JSON Files

Hi!

Have you tried to use 'fromJSON' with the parameter 'simplifyDataFrame'
set to TRUE?

See:
https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart
.html
 -> Section "Data Frames" explains how this affects the data frame
structure. IMHO this should solve your problem...

Best,
Kimmo

2018-11-05 19:00 +0000, JEFFERY REICHMAN wrote:

> r-help Forum
>
> Struggling with importing and creating a data.fram from a JSON file.  
> I used the jsonlite package (fromJSON function) and I can see the
> resulting table but one of the attributes is a list (of lists) So I
> have something that looks like .....
>
> favorites (attribute)
> list(favoriteValue = c("12345", 23456"), resourceType = c("abc",
> "def"), classification = c("xxx","yyy"))
>
> So when I attempt to create a data.frame R errors out.  I'm assuming
> it is because of the list(s).  Don't know what to do with it (the
> list).  I need the "favoriteValue (s)."
>
> Ultimate I want to run the arules package
>
> Jeff Reichman
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.