Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to generate a complex json from R dataframe #390

Open
redleafnew opened this issue May 25, 2022 · 0 comments
Open

How to generate a complex json from R dataframe #390

redleafnew opened this issue May 25, 2022 · 0 comments

Comments

@redleafnew
Copy link

redleafnew commented May 25, 2022

Now:

[
  {
    "full": "NATURE REVIEWS DRUG DISCOVERY",
    "ab": "NAT REV DRUG DISCOV",
    "ifc": "84.694",
    "if5": "80.543"
  },
  {
    "full": "LANCET",
    "ab": "LANCET",
    "ifc": "79.321",
    "if5": "77.237"
  }
] 

Expect:

{ 
  "NATURE REVIEWS DRUG DISCOVERY" : ["NAT REV DRUG DISCOV", "84.694", "80.543"],
  "LANCET" : ["LANCET", "79.321", "77.237"]
}

MWE:

ifsxls <- structure(list(full = c("NATURE REVIEWS DRUG DISCOVERY", "LANCET"
), ab = c("NAT REV DRUG DISCOV", "LANCET"), ifc = c("84.694", 
                                                    "79.321"), if5 = c("80.543", "77.237")), row.names = c(NA, -2L
                                                    ), class = c("tbl_df", "tbl", "data.frame"))
toJSON(ifsxls, pretty=TRUE)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant