Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R将JSON数据获取到数据帧中_R_Rjson - Fatal编程技术网

R将JSON数据获取到数据帧中

R将JSON数据获取到数据帧中,r,rjson,R,Rjson,我有这个带有JSON格式数据的文件,但需要将其放入数据框中。最终,我想把地理位置绘制到地图上,但似乎无法先将这些数据输入df json_to_df <- function(file){ file <- lapply(file, function(x) { x[sapply(x, is.null)] <- NA unlist(x) }) df <- do.call("rbind", file)

我有这个带有JSON格式数据的文件,但需要将其放入数据框中。最终,我想把地理位置绘制到地图上,但似乎无法先将这些数据输入df

json_to_df <- function(file){
         file <- lapply(file, function(x) {
         x[sapply(x, is.null)] <- NA
         unlist(x)
     })

     df <- do.call("rbind", file)
     return(df)
}
文件结构如下所示(这只是数据的一部分):

{
“结果”:[
{
“utc_偏移量”:7200000,
“地点”:{
“国家”:“nl”,
“本地化国家名称”:“荷兰”,
“城市”:“卑尔根”,
“地址1”:“16 Notweg”,
“名称”:“卑尔根菲特俱乐部”,
“lon”:4.699218,
“id”:24632049,
“lat”:52.673046,
“repinned”:错误
},
“人数”:0,
“距离”:22.46796989440918,
“可见性”:“公共”,
“等待列表计数”:0,
“已创建”:1467149834000,
“评级”:{
“计数”:0,
“平均”:0
},
“也许”是“计数”:0,
“说明”:“从周一早上的训练营开始一周的训练!!!清新的空气和宁静的沙丘为全身锻炼提供了完美的环境。无论你是一个有着全新健康目标的新手,还是需要一些指导,或者是为了比赛或比赛而训练,我们都是你的训练师!!!8:50见,请登录!

”, “事件url”:https://www.meetup.com/FitClubBergen/events/234936736/", “是的”计数:3, “期限”:3600000, “名称”:“卑尔根沙丘自由训练营”, “id”:“glzqvlyvnbgc”, “时间”:1477292400000, “更新”:1477297999000, “集团”:{ “加入模式”:“打开”, “已创建”:1441658286000, “名称”:“FitClub Bergen沙丘自由训练营”, “集团公司”:4.710000038146973, “id”:18908751, “urlname”:“FitClubBergen”, “集团”:52.66999816894531, “谁”:“FitClubbers” }, “状态”:“过去” }, { “utc_偏移量”:7200000, “地点”:{ “国家”:“nl”, “本地化国家名称”:“荷兰”, “城市”:“卑尔根”, “地址1”:“16 Notweg”, “名称”:“卑尔根菲特俱乐部”, “lon”:4.699218, “id”:24632049, “lat”:52.673046, “repinned”:错误 }, “人数”:0, “距离”:22.46796989440918, “可见性”:“公共”, “等待列表计数”:0, “已创建”:1467149834000, “评级”:{ “计数”:0, “平均”:0 }, “也许”是“计数”:0, “说明”:周一早上的训练营将为你的一周揭开序幕!!!清新的空气和宁静的沙丘为全身训练提供了完美的环境。无论你是一个有着全新健康目标的新手,还是需要一些指导,或者是为了比赛或比赛而训练,我们都是你的训练师!!!8:50见,请登录!

始终免费

适合所有级别的健身

携带:水瓶和能量

“, “事件url”:https://www.meetup.com/FitClubBergen/events/234936737/", “是的”计数:3, “名称”:“卑尔根沙丘星期一晨训练营”, “id”:“flzqvlyvnbgc”, “时间”:1477292400000, “更新”:1477303926000, “集团”:{ “加入模式”:“打开”, “已创建”:1441658286000, “名称”:“FitClub Bergen沙丘自由训练营”, “集团公司”:4.710000038146973, “id”:18908751, “urlname”:“FitClubBergen”, “集团”:52.66999816894531, “谁”:“FitClubbers” }, “状态”:“过去” }, { “utc_偏移量”:7200000, “地点”:{ “国家”:“nl”, “本地化国家名称”:“荷兰”, “城市”:“阿姆斯特丹”, “电话”:“020 4275777”, “地址1”:“Dijksgracht 2”, “地址2”:“1019 BS”, “名称”:“Klimur Central”, “lon”:4.91284, “id”:1143381, “lat”:52.376626, “repinned”:错误 }, “人数”:0, “距离”:1.0689502954483032, “可见性”:“公共”, “等待列表计数”:0, “已创建”:1477215767000, “评级”:{ “计数”:0, “平均”:0 }, “也许”是“计数”:0, “说明”:下班后立即攀爬:未经加工。
安静的大厅,几乎每根绳子都可用;不需要追绳。还有..那天晚上晚些时候还有一些时间做其他事情。带上你的装备和额外的三明治去工作,然后和我一起拉一些塑料。
一些注意事项:
这项活动在17:00开始。如果你不能赶那么早,请评论您可以选择的时间。
请在您的个人资料中填写您的保镖技能。如果您以前从未攀登过或没有保镖技能:请先参加介绍课程a到健身房!最重要的是安全!

“, “事件url”:https://www.meetup.com/The-Amsterdam-indoor-rockclimbing/events/235054729/", “是的”计数:3, “姓名”:“星期一的原始攀登”, “id”:“235054729”, “时间”:1477321200000, “更新”:1477334279000, “集团”:{ “加入模式”:“批准”, “已创建”:1358348565000, “名称”:“阿姆斯特丹室内攀岩”, "
Error in fromJSON(file) : 
  STRING_ELT() can only be applied to a 'character vector', not a 'list'
{

    "results": [
        {
            "utc_offset": 7200000,
            "venue": {
                "country": "nl",
                "localized_country_name": "Netherlands",
                "city": "Bergen",
                "address_1": "16 Notweg",
                "name": "FitClub Bergen",
                "lon": 4.699218,
                "id": 24632049,
                "lat": 52.673046,
                "repinned": false
            },
            "headcount": 0,
            "distance": 22.46796989440918,
            "visibility": "public",
            "waitlist_count": 0,
            "created": 1467149834000,
            "rating": {
                "count": 0,
                "average": 0
            },
            "maybe_rsvp_count": 0,
            "description": "<p>Start your week off right with a Monday Morning Bootcamp!!! The fresh air and peaceful dunes provide the perfect setting for a total body workout. Whether you are a beginner with brand spankin' new health goals and in need of some direction, or training for a race or competition, we're the trainers for you!!! See you at 8:50 for sign-in!</p>",
            "event_url": "https://www.meetup.com/FitClubBergen/events/234936736/",
            "yes_rsvp_count": 3,
            "duration": 3600000,
            "name": "Free Bootcamp in the Bergen Dunes",
            "id": "glzqvlyvnbgc",
            "time": 1477292400000,
            "updated": 1477297999000,
            "group": {
                "join_mode": "open",
                "created": 1441658286000,
                "name": "FitClub Bergen Free Bootcamp in the Dunes",
                "group_lon": 4.710000038146973,
                "id": 18908751,
                "urlname": "FitClubBergen",
                "group_lat": 52.66999816894531,
                "who": "FitClubbers"
            },
            "status": "past"
        },
        {
            "utc_offset": 7200000,
            "venue": {
                "country": "nl",
                "localized_country_name": "Netherlands",
                "city": "Bergen",
                "address_1": "16 Notweg",
                "name": "FitClub Bergen",
                "lon": 4.699218,
                "id": 24632049,
                "lat": 52.673046,
                "repinned": false
            },
            "headcount": 0,
            "distance": 22.46796989440918,
            "visibility": "public",
            "waitlist_count": 0,
            "created": 1467149834000,
            "rating": {
                "count": 0,
                "average": 0
            },
            "maybe_rsvp_count": 0,
            "description": "<p>Start your week off right with a Monday Morning Bootcamp!!! The fresh air and peaceful dunes provide the perfect setting for a total body workout. Whether you are a beginner with brand spankin' new health goals and in need of some direction, or training for a race or competition, we're the trainers for you!!! See you at 8:50 for sign-in!</p> <p>ALWAYS FREE</p> <p>FOR ALL LEVELS OF FITNESS</p> <p>BRING: water bottle and energy</p>",
            "event_url": "https://www.meetup.com/FitClubBergen/events/234936737/",
            "yes_rsvp_count": 3,
            "name": "Monday Morning Bootcamp in the Bergen Dunes",
            "id": "flzqvlyvnbgc",
            "time": 1477292400000,
            "updated": 1477303926000,
            "group": {
                "join_mode": "open",
                "created": 1441658286000,
                "name": "FitClub Bergen Free Bootcamp in the Dunes",
                "group_lon": 4.710000038146973,
                "id": 18908751,
                "urlname": "FitClubBergen",
                "group_lat": 52.66999816894531,
                "who": "FitClubbers"
            },
            "status": "past"
        },
        {
            "utc_offset": 7200000,
            "venue": {
                "country": "nl",
                "localized_country_name": "Netherlands",
                "city": "Amsterdam",
                "phone": "020 4275777",
                "address_1": "Dijksgracht 2",
                "address_2": "1019 BS ",
                "name": "Klimmuur Central",
                "lon": 4.91284,
                "id": 1143381,
                "lat": 52.376626,
                "repinned": false
            },
            "headcount": 0,
            "distance": 1.0689502954483032,
            "visibility": "public",
            "waitlist_count": 0,
            "created": 1477215767000,
            "rating": {
                "count": 0,
                "average": 0
            },
            "maybe_rsvp_count": 0,
            "description": "<p>Climbing Right After Work: RAW.<br/>Quiet hall, pretty much every rope available; no rope chasing necessary. And.. still some time left to do other things later that evening. Take you gear and an extra sandwich to work and join me afterwards pulling some plastic.<br/>Some notes:<br/>- This events starts @17:00. If you can't make it that early, please comment the time you can.<br/>- Please fill in your belaying skills in your profile. If you've never climbed before or don't have belaying skills: follow an introduction course a the gym first! Safety above all!</p>",
            "event_url": "https://www.meetup.com/The-Amsterdam-indoor-rockclimbing/events/235054729/",
            "yes_rsvp_count": 3,
            "name": "Monday's RAW Climb",
            "id": "235054729",
            "time": 1477321200000,
            "updated": 1477334279000,
            "group": {
                "join_mode": "approval",
                "created": 1358348565000,
                "name": "The Amsterdam indoor rockclimbing",
                "group_lon": 4.889999866485596,
                "id": 6689952,
                "urlname": "The-Amsterdam-indoor-rockclimbing",
                "group_lat": 52.369998931884766,
                "who": "Climbers"
            },
            "status": "past"
        },
        {
            "utc_offset": 7200000,
            "venue": {
                "country": "nl",
                "localized_country_name": "Netherlands",
                "city": "Amstelveen",
                "address_1": "Langs de Akker 3",
                "name": "Emergohal",
                "lon": 4.87967,
                "id": 23816542,
                "lat": 52.290199,
                "repinned": false
            },
            "rsvp_limit": 12,
            "headcount": 0,
            "distance": 5.541957378387451,
            "visibility": "public",
            "waitlist_count": 0,
            "created": 1474452073000,
            "fee": {
                "amount": 5.5,
                "accepts": "cash",
                "description": "per person",
                "currency": "EUR",
                "label": "price",
                "required": "0"
            },
            "rating": {
                "count": 0,
                "average": 0
            },
            "maybe_rsvp_count": 0,
            "description": "<p>We will play the Whole Season indoor soccer on Mondays from 18:00 - 19:00 starting 5 September until May 2017 in the Emergohal Amstelveen.</p> <p>Preferred payment is with Paypal EUR 5.50 (in advance)<br/>If this is not possible you may pay cash but then I will ask EUR 6,-<br/>(Please have the exact cash with you)</p> <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p> <p>A couple of Unisys (ex)colleagues and football lovers are playing every Monday in the Emergohal Amstelveen at 6PM on a reasonable good level. We are looking for a compact group of players who are willing/able to play (almost) every Monday playing 5v5 (or 6v6).<br/>We are playing with the FIFA Futsal rules in mind:<br/><a href="http://www.fifa.com/mm/document/footballdevelopment/refereeing/51/44/50/lawsofthegamefutsal2014_15_eneu_neutral.pdf" class="linkified">http://www.fifa.com/mm/document/footballdevelopment/refereeing/51/44/50/lawsofthegamefutsal2014_15_eneu_neutral.pdf</a></p> <p>The Emergohal has dressing rooms and a nice bar for after the game.</p> <p>Hope to see you on Mondays</p> <p>Cheers Jeroen</p> <p>For questions you may call me on[masked], send a text message (SMS) or leave a message on this meetup group.</p>",
            "event_url": "https://www.meetup.com/Futsal_Emergohal_Monday_18-00/events/234290812/",
            "yes_rsvp_count": 11,
            "duration": 4500000,
            "name": "Futsal",
            "id": "234290812",
            "time": 1477323900000,
            "updated": 1477330559000,
            "group": {
                "join_mode": "approval",
                "created": 1474445066000,
                "name": "Futsal_Emergohal_Monday_18.00",
                "group_lon": 4.860000133514404,
                "id": 20450096,
                "urlname": "Futsal_Emergohal_Monday_18-00",
                "group_lat": 52.31999969482422,
                "who": "Players"
            },
            "status": "past"
        }],
    "meta": {
        "next": "https://api.meetup.com/2/open_events?and_text=False&offset=1&city=Amsterdam&sign=True&format=json&lon=4.88999986649&limited_events=False&photo-host=public&page=20&time=-24m%2C&radius=25.0&lat=52.3699989319&status=past&desc=False",
        "method": "OpenEvents",
        "total_count": 643,
        "link": "https://api.meetup.com/2/open_events",
        "count": 20,
        "description": "Searches for recent and upcoming public events hosted by Meetup groups. Its search window  is the past one month through the next three months, and is subject to change. Open Events is optimized to search for current events by location, category, topic, or text, and only lists Meetups that have **3 or more RSVPs**. The number or results returned with each request is not guaranteed to be the same as the page size due to secondary filtering. If you're looking for a particular event or events within a particular group, use the standard [Events](/meetup_api/docs/2/events/) method.",
        "lon": ,
        "title": "Meetup Open Events v2",
        "url": "",
        "signed_url": "{signed_url}",
        "id": "",
        "updated": 1479988687055,
        "lat": 
    }
}
fromJSON('file.json', flatten = TRUE)