Using New York Times API a JSON file of science articles were scraped. Selected information can be stored into a data frame in r.
library(htmlTable)
## Warning: package 'htmlTable' was built under R version 4.3.3
library(magrittr)
library(jsonlite)
library(tableHTML)
## Warning: package 'tableHTML' was built under R version 4.3.3
library(rjson)
##
## Attaching package: 'rjson'
## The following objects are masked from 'package:jsonlite':
##
## fromJSON, toJSON
library(XML)
library(xml2)
## Warning: package 'xml2' was built under R version 4.3.3
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks magrittr::extract()
## ✖ dplyr::filter() masks stats::filter()
## ✖ purrr::flatten() masks jsonlite::flatten()
## ✖ rjson::fromJSON() masks jsonlite::fromJSON()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::set_names() masks magrittr::set_names()
## ✖ rjson::toJSON() masks jsonlite::toJSON()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(RCurl)
##
## Attaching package: 'RCurl'
##
## The following object is masked from 'package:tidyr':
##
## complete
library(RJSONIO)
##
## Attaching package: 'RJSONIO'
##
## The following objects are masked from 'package:rjson':
##
## fromJSON, toJSON
##
## The following objects are masked from 'package:jsonlite':
##
## fromJSON, toJSON
library(knitr)
## Warning: package 'knitr' was built under R version 4.3.3
library(httr)
httr and jsonlite are the key libraries.
apiurl2 <- GET("https://api.nytimes.com/svc/topstories/v2/science.json?api-key=XZGLFNQG2GlkOtKByTaiAQMgjON1PXGT")
#read in the api data for science articles
apiurl2$status_code
## [1] 200
#status should be 200 for successful connection
api_char <- rawToChar(apiurl2$content)
#convert the raw file to something that can be read for fromJSON extract only the content which contains the articles and their information
api_JSON <- fromJSON(api_char, flatten = TRUE)
class(api_JSON)
## [1] "list"
#fromJSON interprets the JSON code and converts it into a list.
jsonresult <- api_JSON$results
#"results" contains the articles in the list api_JSON
class(jsonresult)
## [1] "list"
#currently a list
length(jsonresult)
## [1] 26
glimpse(jsonresult)
## List of 26
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Sign Up for the Science Times Newsletter"
## ..$ abstract : chr "Every week, we’ll bring you stories that capture the wonders of the human body, nature and the cosmos."
## ..$ url : chr "null"
## ..$ uri : chr "nyt://embeddedinteractive/daba9d03-29b8-5cfc-8cbd-74b8abf54a07"
## ..$ byline : chr ""
## ..$ item_type : chr "EmbeddedInteractive"
## ..$ updated_date : chr "2018-04-07T13:23:25-04:00"
## ..$ created_date : chr "2016-02-05T18:18:53-05:00"
## ..$ published_date : chr "2016-02-05T18:18:53-05:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "admin"
## ..$ subsection : chr ""
## ..$ title : chr ""
## ..$ abstract : chr ""
## ..$ url : chr ""
## ..$ uri : chr "nyt://embeddedinteractive/6cb185ed-65ac-50a5-ace3-5bab81934245"
## ..$ byline : chr ""
## ..$ item_type : chr "EmbeddedInteractive"
## ..$ updated_date : chr "2015-07-20T13:45:03-04:00"
## ..$ created_date : chr "2015-04-16T14:13:18-04:00"
## ..$ published_date : chr "2015-04-16T14:13:18-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia : NULL
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "us"
## ..$ subsection : chr "politics"
## ..$ title : chr "4 Takeaways From the Abortion Pill Arguments"
## ..$ abstract : chr "Several justices questioned the remedy of applying nationwide restrictions to mifepristone because it would be "| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/26/us/politics/abortion-pill-supreme-court-takeaways.html"
## ..$ uri : chr "nyt://article/90f34b44-5c13-5d03-9173-11baee3ada21"
## ..$ byline : chr "By Pam Belluck"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T16:20:07-04:00"
## ..$ created_date : chr "2024-03-26T15:53:14-04:00"
## ..$ published_date : chr "2024-03-26T15:53:14-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:3] "United States Politics and Government" "Abortion" "Drugs (Pharmaceuticals)"
## ..$ org_facet : chr [1:2] "Supreme Court (US)" "Food and Drug Administration"
## ..$ per_facet : chr [1:4] "Gorsuch, Neil M" "Barrett, Amy Coney" "Jackson, Ketanji Brown (1970- )" "Thomas, Clarence"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "us"
## ..$ subsection : chr "politics"
## ..$ title : chr "Abortion Pill Dispute Centers on Central Question: Who Can Sue?"
## ..$ abstract : chr "The parties in the fight over access to the abortion pill sharply disagree on whether anti-abortion doctors and"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/26/us/politics/abortion-pill-lawsuits-doctors.html"
## ..$ uri : chr "nyt://article/362701c3-3803-5069-9fad-2bbd9a341992"
## ..$ byline : chr "By Abbie VanSickle and Pam Belluck"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T05:02:32-04:00"
## ..$ created_date : chr "2024-03-26T05:02:32-04:00"
## ..$ published_date : chr "2024-03-26T05:02:32-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:5] "Abortion" "Abortion Drugs" "Suits and Litigation (Civil)" "Doctors" ...
## ..$ org_facet : chr [1:2] "Food and Drug Administration" "Supreme Court (US)"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "health"
## ..$ subsection : chr ""
## ..$ title : chr "Use of Abortion Pills Has Risen Significantly Post Roe, Research Shows"
## ..$ abstract : chr "Two new studies show fast-growing use of the pills on the eve of the Supreme Court’s consideration of a case se"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/25/health/abortion-pills.html"
## ..$ uri : chr "nyt://article/82b2e589-4ba3-56aa-af6e-c9db18427957"
## ..$ byline : chr "By Pam Belluck"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T13:24:28-04:00"
## ..$ created_date : chr "2024-03-25T11:05:06-04:00"
## ..$ published_date : chr "2024-03-25T11:05:06-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:8] "your-feed-health" "your-feed-healthcare" "Abortion" "Abortion Drugs" ...
## ..$ org_facet : chr [1:3] "Guttmacher Institute" "Journal of the American Medical Assn" "Supreme Court (US)"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "United States"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "climate"
## ..$ subsection : chr ""
## ..$ title : chr "Energy Dept. Awards $6 Billion for Green Steel, Cement and Even Macaroni Factories"
## ..$ abstract : chr "Industries produce 25 percent of America’s planet-warming emissions but so far have proved very hard to clean u"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/25/climate/energy-department-grants-decarbonize-industry.html"
## ..$ uri : chr "nyt://article/6c2c3ba0-6c66-5254-9426-60acdce11540"
## ..$ byline : chr "By Brad Plumer"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T23:45:38-04:00"
## ..$ created_date : chr "2024-03-25T05:03:32-04:00"
## ..$ published_date : chr "2024-03-25T05:03:32-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Global Warming" "Greenhouse Gas Emissions" "Steel and Iron" "Factories and Manufacturing" ...
## ..$ org_facet : chr "Energy Department"
## ..$ per_facet : chr [1:2] "Biden, Joseph R Jr" "Granholm, Jennifer M"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "world"
## ..$ subsection : chr "europe"
## ..$ title : chr "To Live Past 100, Mangia a Lot Less: Italian Expert’s Ideas on Aging"
## ..$ abstract : chr "Valter Longo, who wants to live to a healthy 120 or 130, sees the key to longevity in diet — legumes and fish —"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/25/world/europe/italy-aging-valter-longo.html"
## ..$ uri : chr "nyt://article/3679914d-0947-57e7-8249-9457f8f6c791"
## ..$ byline : chr "By Jason Horowitz"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T15:18:52-04:00"
## ..$ created_date : chr "2024-03-25T00:01:18-04:00"
## ..$ published_date : chr "2024-03-25T00:01:18-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Longevity" "Diet and Nutrition" "Elderly" "Medicine and Health" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr [1:3] "Calabria (Italy)" "Genoa (Italy)" "Italy"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "A Lunar Eclipse Warms Up the Moon for April’s Solar Eclipse"
## ..$ abstract : chr "The subtle event, known as a penumbral eclipse, can be observed by everyone on Earth’s nightside."
## ..$ url : chr "https://www.nytimes.com/2024/03/24/science/lunar-eclipse-moon-penumbral.html"
## ..$ uri : chr "nyt://article/5988fe25-73e5-51c2-b172-f16ed01f30e9"
## ..$ byline : chr "By Katrina Miller"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T14:47:20-04:00"
## ..$ created_date : chr "2024-03-24T05:01:56-04:00"
## ..$ published_date : chr "2024-03-24T05:01:56-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:4] "Eclipses" "Moon" "Space and Astronomy" "Content Type: Service"
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "style"
## ..$ subsection : chr ""
## ..$ title : chr "Choosing to Skip Sex and Go Straight to I.V.F."
## ..$ abstract : chr "Well aware of how difficult conception or carrying a baby to term can be, some couples who hope to exercise a b"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/24/style/ivf-process-couples.html"
## ..$ uri : chr "nyt://article/0d42b59d-7ed0-5f42-ac06-e0f6203939a1"
## ..$ byline : chr "By Alyson Krueger"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T12:50:15-04:00"
## ..$ created_date : chr "2024-03-24T05:00:33-04:00"
## ..$ published_date : chr "2024-03-24T05:00:33-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:5] "In Vitro Fertilization" "Embryos (Human)" "Egg Donation and Freezing" "Reproduction (Biological)" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "health"
## ..$ subsection : chr ""
## ..$ title : chr "Patients Hate ‘Forever’ Drugs. Is Wegovy Different?"
## ..$ abstract : chr "The new obesity drugs might be an exception to a chronic, deadly problem: the failure to stick with medication."
## ..$ url : chr "https://www.nytimes.com/2024/03/24/health/ozempic-wegovy-forever-drugs.html"
## ..$ uri : chr "nyt://article/ec5b45d5-488e-5c54-9eff-d319cfe37eff"
## ..$ byline : chr "By Gina Kolata"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T08:49:38-04:00"
## ..$ created_date : chr "2024-03-24T02:59:02-04:00"
## ..$ published_date : chr "2024-03-24T02:59:02-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Semaglutide (Drug)" "Obesity" "Weight" "Drugs (Pharmaceuticals)" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "It’s a Golden Age for Shipwreck Discoveries. Why?"
## ..$ abstract : chr "More lost shipwrecks are being found because of new technology, climate change and more vessels scanning the oc"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/23/science/shipwreck-sinking-sea-why.html"
## ..$ uri : chr "nyt://article/521078c0-7fd0-52a0-a11e-921b33c8f360"
## ..$ byline : chr "By Michael Levenson"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T13:32:26-04:00"
## ..$ created_date : chr "2024-03-23T08:00:12-04:00"
## ..$ published_date : chr "2024-03-23T08:00:12-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:4] "Shipwrecks (Historic)" "Archaeology and Anthropology" "Global Warming" "Exploration and Explorers"
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "Canada"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "world"
## ..$ subsection : chr "europe"
## ..$ title : chr "A Rock Fell From Space Into Sweden. Who Owns It on Earth?"
## ..$ abstract : chr "Sweden’s courts have been debating claims to a meteorite that fell north of Stockholm, including whether the ri"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/22/world/europe/sweden-meteorite-ownership.html"
## ..$ uri : chr "nyt://article/534d0657-51eb-5c42-8e5a-dbe4ee8fd76e"
## ..$ byline : chr "By Christina Anderson"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T10:08:19-04:00"
## ..$ created_date : chr "2024-03-22T12:56:00-04:00"
## ..$ published_date : chr "2024-03-22T12:56:00-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:8] "Meteors and Meteorites" "Decisions and Verdicts" "Courts and the Judiciary" "Space and Astronomy" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "Sweden"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "health"
## ..$ subsection : chr ""
## ..$ title : chr "What’s Next for the Coronavirus?"
## ..$ abstract : chr "Scientists studying the virus’s continuing evolution, and the body’s immune responses, hope to head off a resur"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/22/health/coronavirus-evolution-immunity.html"
## ..$ uri : chr "nyt://article/9db8c1a9-e492-5eb4-acc6-63e228b84a21"
## ..$ byline : chr "By Apoorva Mandavilli"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-23T13:37:32-04:00"
## ..$ created_date : chr "2024-03-22T12:05:59-04:00"
## ..$ published_date : chr "2024-03-22T12:05:59-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:13] "Coronavirus (2019-nCoV)" "Disease Rates" "Vaccination and Immunization" "Immune System" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "United States"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "climate"
## ..$ subsection : chr ""
## ..$ title : chr "How Toyota, a Laggard on Electric Cars, Got Its Fight Back"
## ..$ abstract : chr "The auto giant lobbied hard against tougher pollution rules. This week, the E.P.A.’s new rules proved favorable"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/22/climate/toyota-hybrid-epa-pollution.html"
## ..$ uri : chr "nyt://article/c2e08dc8-09b3-5df4-b15d-80e006e361e4"
## ..$ byline : chr "By Hiroko Tabuchi"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T22:40:17-04:00"
## ..$ created_date : chr "2024-03-22T10:54:32-04:00"
## ..$ published_date : chr "2024-03-22T10:54:32-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Global Warming" "Greenhouse Gas Emissions" "Automobiles" "Electric and Hybrid Vehicles" ...
## ..$ org_facet : chr [1:2] "Environmental Protection Agency" "Toyota Motor Corp"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Ice Skating and the Brain"
## ..$ abstract : chr "How champion skaters' brains keep them from falling or feeling dizzy"
## ..$ url : chr "https://www.nytimes.com/interactive/2024/03/22/science/ice-skating-brain.html"
## ..$ uri : chr "nyt://interactive/bfdab2d4-255c-576b-bf5f-7864b6728243"
## ..$ byline : chr "By Pam Belluck"
## ..$ item_type : chr "Interactive"
## ..$ updated_date : chr "2024-03-22T15:13:49-04:00"
## ..$ created_date : chr "2024-03-22T05:07:19-04:00"
## ..$ published_date : chr "2024-03-22T05:07:19-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:5] "Brain" "Figure Skating" "Speedskating" "World Figure Skating Championships" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : chr [1:3] "Chen, Nathan" "Kwan, Michelle" "Malinin, Ilia (2004- )"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "us"
## ..$ subsection : chr ""
## ..$ title : chr "A Quiet Maine County Braces for the Eclipse. ‘Where Are 20,000 People Going to Pee?’"
## ..$ abstract : chr "Businesses and planning committees are eager for visitors, but some in remote Aroostook County are not sure how"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/22/us/maine-total-solar-eclipse.html"
## ..$ uri : chr "nyt://article/246f91df-4946-5969-8dbc-5dd18839bcfa"
## ..$ byline : chr "By Jenna Russell and Greta Rybus"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-23T22:12:38-04:00"
## ..$ created_date : chr "2024-03-22T05:04:23-04:00"
## ..$ published_date : chr "2024-03-22T05:04:23-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:4] "Eclipses" "Travel and Vacations" "Rural Areas" "Hotels and Travel Lodgings"
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr [1:2] "Maine" "Houlton (Me)"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Prehistoric Amphibian Ancestor Is Named for Kermit the Frog"
## ..$ abstract : chr "The species seemed to have bug eyes and a smile, so a team of researchers named it Kermitops gratus in honor of"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/21/science/kermitops-amphibian-kermit-frog-texas.html"
## ..$ uri : chr "nyt://article/55dd8a78-9149-56f0-a066-5acb59ee854c"
## ..$ byline : chr "By Michael Levenson"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-22T09:46:38-04:00"
## ..$ created_date : chr "2024-03-21T18:51:12-04:00"
## ..$ published_date : chr "2024-03-21T18:51:12-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:8] "Names, Organizational" "Paleontology" "Fossils" "Museums" ...
## ..$ org_facet : chr [1:2] "Smithsonian Institution" "George Washington University"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "obituaries"
## ..$ subsection : chr ""
## ..$ title : chr "Overlooked No More: Yvonne Barr, Who Helped Discover a Cancer-Causing Virus"
## ..$ abstract : chr "A virologist, she worked with the pathologist Anthony Epstein, who died last month, in finding for the first ti"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/21/obituaries/yvonne-barr-overlooked.html"
## ..$ uri : chr "nyt://article/280c377e-8416-5b35-be10-02df2b51a326"
## ..$ byline : chr "By Delthia Ricks"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T12:50:30-04:00"
## ..$ created_date : chr "2024-03-21T15:03:12-04:00"
## ..$ published_date : chr "2024-03-21T15:03:12-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:4] "Research" "Viruses" "Biographical Information" "Content Type: Personal Profile"
## ..$ org_facet : chr "Middlesex Hospital"
## ..$ per_facet : chr [1:2] "Barr, Yvonne (1932-2016)" "Epstein, Anthony (1921-2024)"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Toddlers Smell Like Flowers, Teens Smell ‘Goatlike,’ Study Finds"
## ..$ abstract : chr "Two musky steroids, and higher levels of odorous acids, distinguish the body odors of adolescents and tots."
## ..$ url : chr "https://www.nytimes.com/2024/03/21/science/odor-adolescents-chemistry.html"
## ..$ uri : chr "nyt://article/39262fc0-5e53-560e-bc6e-962811e1cd52"
## ..$ byline : chr "By Emily Anthes"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-23T21:20:04-04:00"
## ..$ created_date : chr "2024-03-21T12:00:06-04:00"
## ..$ published_date : chr "2024-03-21T12:00:06-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:8] "Research" "Smells and Odors" "Children and Childhood" "Babies and Infants" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "health"
## ..$ subsection : chr ""
## ..$ title : chr "The Psychedelic Evangelist"
## ..$ abstract : chr "A Johns Hopkins scientist was known for rigorous studies of psychedelics. Was he a true believer?"
## ..$ url : chr "https://www.nytimes.com/2024/03/21/health/psychedelics-roland-griffiths-johns-hopkins.html"
## ..$ uri : chr "nyt://article/004c2082-b24c-5e8a-a53f-dd10e8a222da"
## ..$ byline : chr "By Brendan Borrell"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-26T18:42:10-04:00"
## ..$ created_date : chr "2024-03-21T11:00:13-04:00"
## ..$ published_date : chr "2024-03-21T11:00:13-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:11] "Psychedelic and Hallucinogenic Drugs" "Psilocybin Mushrooms" "Ethics and Official Misconduct" "Research" ...
## ..$ org_facet : chr "Johns Hopkins Hospital (Baltimore, Md)"
## ..$ per_facet : chr "Griffiths, Roland R"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "health"
## ..$ subsection : chr ""
## ..$ title : chr "Surgeons Transplant Pig Kidney Into a Patient, a Medical Milestone"
## ..$ abstract : chr "The man continues to improve, doctors said. Organs from genetically engineered pigs one day may make dialysis obsolete."
## ..$ url : chr "https://www.nytimes.com/2024/03/21/health/pig-kidney-organ-transplant.html"
## ..$ uri : chr "nyt://article/69b6695e-4442-5fe6-bfca-1fd1763c67d1"
## ..$ byline : chr "By Roni Caryn Rabin"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-25T16:08:49-04:00"
## ..$ created_date : chr "2024-03-21T09:30:06-04:00"
## ..$ published_date : chr "2024-03-21T09:30:06-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:8] "Transplants" "Kidneys" "Pigs" "Genetic Engineering" ...
## ..$ org_facet : chr [1:2] "Massachusetts General Hospital" "eGenesis"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Long Before Amsterdam’s Coffee Shops, There Were Hallucinogenic Seeds"
## ..$ abstract : chr "A nearly 2,000-year-old stash pouch provides the first evidence of the intentional use of a powerful psychedeli"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/21/science/archaeology-hallucinogens-henbane.html"
## ..$ uri : chr "nyt://article/8b4faf36-d20e-56bb-9cc6-bfc7372b3a50"
## ..$ byline : chr "By Rachel Nuwer"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-21T05:03:37-04:00"
## ..$ created_date : chr "2024-03-21T05:03:37-04:00"
## ..$ published_date : chr "2024-03-21T05:03:37-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr "Trilobites"
## ..$ des_facet : chr [1:6] "Archaeology and Anthropology" "Roman Civilization" "Psychedelic and Hallucinogenic Drugs" "Flowers and Plants" ...
## ..$ org_facet : chr "Antiquity (Journal)"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "Netherlands"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "climate"
## ..$ subsection : chr ""
## ..$ title : chr "Climate Change Made an Early Heat Wave in West Africa 10 Times as Likely"
## ..$ abstract : chr "Temperatures in the region rose above 40 degrees Celsius in February, with humidity pushing the heat index even higher."
## ..$ url : chr "https://www.nytimes.com/2024/03/21/climate/climate-change-heat-wave-west-africa.html"
## ..$ uri : chr "nyt://article/18b45ccf-3107-5e3c-b8ab-9101da3f443a"
## ..$ byline : chr "By Delger Erdenesanaa"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-21T23:37:29-04:00"
## ..$ created_date : chr "2024-03-21T02:01:06-04:00"
## ..$ published_date : chr "2024-03-21T02:01:06-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:3] "Global Warming" "Greenhouse Gas Emissions" "Heat and Heat Waves"
## ..$ org_facet : chr "World Weather Attribution"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "West Africa"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Frans de Waal, Who Found the Origins of Morality in Apes, Dies at 75"
## ..$ abstract : chr "An unusually popular primatologist, he drew the attention of Newt Gingrich, Isabella Rossellini, the philosophe"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/20/science/frans-de-waal-died.html"
## ..$ uri : chr "nyt://article/059a3d5b-00e4-507c-a7f3-358eceb2d8f7"
## ..$ byline : chr "By Alex Traub"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-23T13:39:31-04:00"
## ..$ created_date : chr "2024-03-20T17:56:06-04:00"
## ..$ published_date : chr "2024-03-20T17:56:06-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Deaths (Obituaries)" "Books and Literature" "Animal Behavior" "Monkeys and Apes" ...
## ..$ org_facet : chr "Emory University"
## ..$ per_facet : chr "de Waal, Frans"
## ..$ geo_facet : chr "Netherlands"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "More Studies by Columbia Cancer Researchers Are Retracted"
## ..$ abstract : chr "The studies, pulled because of copied data, illustrate the sluggishness of scientific publishers to address ser"| __truncated__
## ..$ url : chr "https://www.nytimes.com/2024/03/20/science/columbia-cancer-research-retractions.html"
## ..$ uri : chr "nyt://article/d8bcaed5-36ef-55af-9537-bd485363bf21"
## ..$ byline : chr "By Benjamin Mueller"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-22T13:42:52-04:00"
## ..$ created_date : chr "2024-03-20T14:34:35-04:00"
## ..$ published_date : chr "2024-03-20T14:34:35-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr ""
## ..$ des_facet : chr [1:7] "Academic and Scientific Journals" "Falsification of Data" "Ethics and Official Misconduct" "Research" ...
## ..$ org_facet : chr "Columbia University"
## ..$ per_facet : chr [1:3] "Yoon, Sam S" "Yoon, Changhwan" "David, Sholto"
## ..$ geo_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
## $ :List of 19
## ..$ section : chr "science"
## ..$ subsection : chr ""
## ..$ title : chr "Fossil Trove From 74,000 Years Ago Points to Remarkably Adaptive Humans"
## ..$ abstract : chr "An archaeological site in Ethiopia revealed the oldest-known arrowheads and the remnants of a major volcanic eruption."
## ..$ url : chr "https://www.nytimes.com/2024/03/20/science/early-humans-arrowheads-volcano.html"
## ..$ uri : chr "nyt://article/6705cd9f-668e-5f84-b32f-4c51aee82735"
## ..$ byline : chr "By Carl Zimmer"
## ..$ item_type : chr "Article"
## ..$ updated_date : chr "2024-03-21T22:00:57-04:00"
## ..$ created_date : chr "2024-03-20T12:00:24-04:00"
## ..$ published_date : chr "2024-03-20T12:00:24-04:00"
## ..$ material_type_facet: chr ""
## ..$ kicker : chr "Origins"
## ..$ des_facet : chr [1:5] "Research" "Fossils" "Archaeology and Anthropology" "Paleontology" ...
## ..$ org_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ per_facet : list()
## .. ..- attr(*, "class")= chr "AsIs"
## ..$ geo_facet : chr "Ethiopia"
## ..$ multimedia :List of 3
## .. ..$ :List of 8
## .. ..$ :List of 8
## .. ..$ :List of 8
## ..$ short_url : chr ""
science_articles <- data.frame(c(1:length(jsonresult)))
#initialize a data frame called science articles to store the science article information
for(x in 1:length(jsonresult)){
science_articles[x,2] <- jsonresult[[x]]$title
science_articles[x,3] <- jsonresult[[x]]$url
science_articles[x,4] <- jsonresult[[x]]$published_date
}
#can extract title abstract etc. from the list and store it into a dataframe using a for loop. not optimal but it does transform parts of the list to a dataframe.
glimpse(science_articles)
## Rows: 26
## Columns: 4
## $ c.1.length.jsonresult.. <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,…
## $ V2 <chr> "Sign Up for the Science Times Newsletter", ""…
## $ V3 <chr> "null", "", "https://www.nytimes.com/2024/03/2…
## $ V4 <chr> "2016-02-05T18:18:53-05:00", "2015-04-16T14:13…
class(science_articles)
## [1] "data.frame"
science_articles
## c.1.length.jsonresult..
## 1 1
## 2 2
## 3 3
## 4 4
## 5 5
## 6 6
## 7 7
## 8 8
## 9 9
## 10 10
## 11 11
## 12 12
## 13 13
## 14 14
## 15 15
## 16 16
## 17 17
## 18 18
## 19 19
## 20 20
## 21 21
## 22 22
## 23 23
## 24 24
## 25 25
## 26 26
## V2
## 1 Sign Up for the Science Times Newsletter
## 2
## 3 4 Takeaways From the Abortion Pill Arguments
## 4 Abortion Pill Dispute Centers on Central Question: Who Can Sue?
## 5 Use of Abortion Pills Has Risen Significantly Post Roe, Research Shows
## 6 Energy Dept. Awards $6 Billion for Green Steel, Cement and Even Macaroni Factories
## 7 To Live Past 100, Mangia a Lot Less: Italian Expert’s Ideas on Aging
## 8 A Lunar Eclipse Warms Up the Moon for April’s Solar Eclipse
## 9 Choosing to Skip Sex and Go Straight to I.V.F.
## 10 Patients Hate ‘Forever’ Drugs. Is Wegovy Different?
## 11 It’s a Golden Age for Shipwreck Discoveries. Why?
## 12 A Rock Fell From Space Into Sweden. Who Owns It on Earth?
## 13 What’s Next for the Coronavirus?
## 14 How Toyota, a Laggard on Electric Cars, Got Its Fight Back
## 15 Ice Skating and the Brain
## 16 A Quiet Maine County Braces for the Eclipse. ‘Where Are 20,000 People Going to Pee?’
## 17 Prehistoric Amphibian Ancestor Is Named for Kermit the Frog
## 18 Overlooked No More: Yvonne Barr, Who Helped Discover a Cancer-Causing Virus
## 19 Toddlers Smell Like Flowers, Teens Smell ‘Goatlike,’ Study Finds
## 20 The Psychedelic Evangelist
## 21 Surgeons Transplant Pig Kidney Into a Patient, a Medical Milestone
## 22 Long Before Amsterdam’s Coffee Shops, There Were Hallucinogenic Seeds
## 23 Climate Change Made an Early Heat Wave in West Africa 10 Times as Likely
## 24 Frans de Waal, Who Found the Origins of Morality in Apes, Dies at 75
## 25 More Studies by Columbia Cancer Researchers Are Retracted
## 26 Fossil Trove From 74,000 Years Ago Points to Remarkably Adaptive Humans
## V3
## 1 null
## 2
## 3 https://www.nytimes.com/2024/03/26/us/politics/abortion-pill-supreme-court-takeaways.html
## 4 https://www.nytimes.com/2024/03/26/us/politics/abortion-pill-lawsuits-doctors.html
## 5 https://www.nytimes.com/2024/03/25/health/abortion-pills.html
## 6 https://www.nytimes.com/2024/03/25/climate/energy-department-grants-decarbonize-industry.html
## 7 https://www.nytimes.com/2024/03/25/world/europe/italy-aging-valter-longo.html
## 8 https://www.nytimes.com/2024/03/24/science/lunar-eclipse-moon-penumbral.html
## 9 https://www.nytimes.com/2024/03/24/style/ivf-process-couples.html
## 10 https://www.nytimes.com/2024/03/24/health/ozempic-wegovy-forever-drugs.html
## 11 https://www.nytimes.com/2024/03/23/science/shipwreck-sinking-sea-why.html
## 12 https://www.nytimes.com/2024/03/22/world/europe/sweden-meteorite-ownership.html
## 13 https://www.nytimes.com/2024/03/22/health/coronavirus-evolution-immunity.html
## 14 https://www.nytimes.com/2024/03/22/climate/toyota-hybrid-epa-pollution.html
## 15 https://www.nytimes.com/interactive/2024/03/22/science/ice-skating-brain.html
## 16 https://www.nytimes.com/2024/03/22/us/maine-total-solar-eclipse.html
## 17 https://www.nytimes.com/2024/03/21/science/kermitops-amphibian-kermit-frog-texas.html
## 18 https://www.nytimes.com/2024/03/21/obituaries/yvonne-barr-overlooked.html
## 19 https://www.nytimes.com/2024/03/21/science/odor-adolescents-chemistry.html
## 20 https://www.nytimes.com/2024/03/21/health/psychedelics-roland-griffiths-johns-hopkins.html
## 21 https://www.nytimes.com/2024/03/21/health/pig-kidney-organ-transplant.html
## 22 https://www.nytimes.com/2024/03/21/science/archaeology-hallucinogens-henbane.html
## 23 https://www.nytimes.com/2024/03/21/climate/climate-change-heat-wave-west-africa.html
## 24 https://www.nytimes.com/2024/03/20/science/frans-de-waal-died.html
## 25 https://www.nytimes.com/2024/03/20/science/columbia-cancer-research-retractions.html
## 26 https://www.nytimes.com/2024/03/20/science/early-humans-arrowheads-volcano.html
## V4
## 1 2016-02-05T18:18:53-05:00
## 2 2015-04-16T14:13:18-04:00
## 3 2024-03-26T15:53:14-04:00
## 4 2024-03-26T05:02:32-04:00
## 5 2024-03-25T11:05:06-04:00
## 6 2024-03-25T05:03:32-04:00
## 7 2024-03-25T00:01:18-04:00
## 8 2024-03-24T05:01:56-04:00
## 9 2024-03-24T05:00:33-04:00
## 10 2024-03-24T02:59:02-04:00
## 11 2024-03-23T08:00:12-04:00
## 12 2024-03-22T12:56:00-04:00
## 13 2024-03-22T12:05:59-04:00
## 14 2024-03-22T10:54:32-04:00
## 15 2024-03-22T05:07:19-04:00
## 16 2024-03-22T05:04:23-04:00
## 17 2024-03-21T18:51:12-04:00
## 18 2024-03-21T15:03:12-04:00
## 19 2024-03-21T12:00:06-04:00
## 20 2024-03-21T11:00:13-04:00
## 21 2024-03-21T09:30:06-04:00
## 22 2024-03-21T05:03:37-04:00
## 23 2024-03-21T02:01:06-04:00
## 24 2024-03-20T17:56:06-04:00
## 25 2024-03-20T14:34:35-04:00
## 26 2024-03-20T12:00:24-04:00
Science articles from NYT API was extracted and the JSON file was converted to a list. From the list a data frame was constructed.