{"action":"created","issue":{"url":"https://api.github.com/repos/ropensci/rentrez/issues/65","labels_url":"https://api.github.com/repos/ropensci/rentrez/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/ropensci/rentrez/issues/65/comments","events_url":"https://api.github.com/repos/ropensci/rentrez/issues/65/events","html_url":"https://github.com/ropensci/rentrez/issues/65","id":106881018,"number":65,"title":"extract_form_esummary matrix cannot be cleanly written to csv","user":{"login":"Monty9","id":13947738,"avatar_url":"https://avatars.githubusercontent.com/u/13947738?v=3","gravatar_id":"","url":"https://api.github.com/users/Monty9","html_url":"https://github.com/Monty9","followers_url":"https://api.github.com/users/Monty9/followers","following_url":"https://api.github.com/users/Monty9/following{/other_user}","gists_url":"https://api.github.com/users/Monty9/gists{/gist_id}","starred_url":"https://api.github.com/users/Monty9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Monty9/subscriptions","organizations_url":"https://api.github.com/users/Monty9/orgs","repos_url":"https://api.github.com/users/Monty9/repos","events_url":"https://api.github.com/users/Monty9/events{/privacy}","received_events_url":"https://api.github.com/users/Monty9/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-16T22:59:01Z","updated_at":"2015-10-12T17:54:05Z","closed_at":"2015-09-17T01:47:08Z","body":"Hi David,\r\nBelow is the example. I did not understand why title, fulljournalname, pubtype has the text data extending to second column. \r\n```\r\nPM.ID <- c(\"26287849\", \"25979833\", \"25667274\", \"25430497\", \"24968756\", \"24846037\", \"24296758\", \"24281417\", \"24128713\", \"24055406\",\"23489023\")\r\np.data <- entrez_summary(db = \"pubmed\", id = PM.ID  )\r\npubrecord.table <- extract_from_esummary(esummaries = p.data , elements = c(\"uid\",\"title\",\"fulljournalname\", \"pubtype\", \"volume\", \"issue\", \"pages\",                                                                           \"lastauthor\",\"pmcrefcount\", \"issn\", \"pubdate\" ))\r\nis(pubrecord.table) #  \"matrix\"         \"array\"          \"structure\"      \"vector\"         \"vectorORfactor\"\r\npubrecord.table <- t(pubrecord.table) # transpose the rows into columns\r\nwrite.csv(pubrecord.table , file = \"test12.csv\" )\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ropensci/rentrez/issues/comments/147474792","html_url":"https://github.com/ropensci/rentrez/issues/65#issuecomment-147474792","issue_url":"https://api.github.com/repos/ropensci/rentrez/issues/65","id":147474792,"user":{"login":"dwinter","id":103573,"avatar_url":"https://avatars.githubusercontent.com/u/103573?v=3","gravatar_id":"","url":"https://api.github.com/users/dwinter","html_url":"https://github.com/dwinter","followers_url":"https://api.github.com/users/dwinter/followers","following_url":"https://api.github.com/users/dwinter/following{/other_user}","gists_url":"https://api.github.com/users/dwinter/gists{/gist_id}","starred_url":"https://api.github.com/users/dwinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwinter/subscriptions","organizations_url":"https://api.github.com/users/dwinter/orgs","repos_url":"https://api.github.com/users/dwinter/repos","events_url":"https://api.github.com/users/dwinter/events{/privacy}","received_events_url":"https://api.github.com/users/dwinter/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T17:54:05Z","updated_at":"2015-10-12T17:54:05Z","body":"I'm not sure what you are trying to in the example, but it seems like it's hitting empty fields?\r\n\r\n`extract_form_esummary ` is really a wrapper to `sapply`, it doesn't return `data.frames` because I think most users don't expect `data.frame` columns to contain _vectors_ like \r\n\r\n```r\r\ndf <- as.data.frame(t(pubrecord.table))\r\ndf$pubtype\r\n```\r\n\r\n```\r\n$`26287849`\r\n[1] \"Journal Article\"   \"Multicenter Study\"\r\n\r\n$`25979833`\r\n[1] \"Journal Article\"             \"Randomized Controlled Trial\"\r\n\r\n$`25667274`\r\n[1] \"Journal Article\"\r\n.\r\n.\r\n.\r\n```\r\n\r\nStructured data like that would seem to fit a list better than a `data.frame`, and you can get that by setting `simplify=FALSE`."}}