Modified from https://cran.r-project.org/web/packages/jsonlite/vignettes/json-apis.html
library(jsonlite)
#search for articles
article_key <- "api-key=472caa3965d74ec48511e3b169351c6a"
url <- "http://api.nytimes.com/svc/topstories/v2/national.json?"
req <- fromJSON(paste0(url, article_key))
#convert data to dataframe
df <- data.frame(
title <- req$results$title,
published_date <- req$results$published_date,
short_url <- req$results$short_url,
abstract <- req$results$abstract
)
names(df) = c("Title", "Date", "Reference URL", "Abstract")
library(knitr )
kable(df)
Title | Date | Reference URL | Abstract |
---|---|---|---|
Sexual Misconduct in California’s Capitol Is Difficult to Escape | 2017-10-29T15:47:43-04:00 | https://nyti.ms/2iK14uQ | Women in Sacramento complain of a culture of rampant sexual misconduct and of a system that does not seriously address their complaints. |
Refusing Weinstein’s Hush Money, Rose McGowan Calls Out Hollywood | 2017-10-28T14:56:23-04:00 | https://nyti.ms/2yW7VFO | The former actress, who has said that Harvey Weinstein sexually assaulted her, talks about the producer and about becoming an advocate for mistreated women. |
Puerto Rico Cancels Whitefish Energy Contract to Rebuild Power Lines | 2017-10-29T13:07:16-04:00 | https://nyti.ms/2yVnMnQ | The move came following concerns about how the small Montana company won a contract for up to $300 million to rebuild part of the island’s hurricane-ravaged electrical grid. |
Ever Heard of Burmese Sushi Counters? You’ve Probably Been to One | 2017-10-29T03:00:17-04:00 | https://nyti.ms/2iHtVQB | Immigrants from Myanmar have found a business niche rolling and selling a Japanese delicacy in grocery stores across the country. |
‘You’re a Quadriplegic’: A Las Vegas Victim Faces a Hard Reality | 2017-10-28T12:15:21-04:00 | https://nyti.ms/2iJs5yv | Kim Gervais and two friends went to hear country music. Then the gunfire began. She was gravely injured, one of her friends died and one survived. |
A Roadshow of Hate: Supremacist Rallies Fueled by Travelers From Afar | 2017-10-28T10:29:51-04:00 | https://nyti.ms/2iGZav2 | At two demonstrations in Tennessee on Saturday, as at many white nationalist events, local police faced unfamiliar crowds coming mostly from out of town. |
At Women’s Convention in Detroit, a Test of Momentum and Focus | 2017-10-28T11:55:46-04:00 | https://nyti.ms/2iFTK3z | Nine months after the Women’s March, thousands gathered to discuss a wide range of issues, with sexual harassment being “the gorilla in the room.” |
The U.S. Nursed an Undocumented 10-Year-Old. Now It May Deport Her. | 2017-10-27T19:19:36-04:00 | https://nyti.ms/2yS54xj | The case of a girl with cerebral palsy, who was brought illegally to Texas so she could get medical care, goes to the heart of the immigration debate. |
Roger Stone Suspended From Twitter After Expletive-Laden Tweets | 2017-10-29T18:30:14-04:00 | https://nyti.ms/2yWRsRs | The longtime supporter of President Trump lobbed insults at CNN anchors and contributors, leading to a suspension of his Twitter account. |
In Niger, Where U.S. Troops Died, a Lawless and Shifting Landscape | 2017-10-29T18:14:45-04:00 | https://nyti.ms/2yYA5jz | Militants and smugglers operate in the impoverished African country, where the scale of American military involvement has surprised even high-ranking senators. |
2 Navy SEALs Under Suspicion in Strangling of Green Beret in Mali | 2017-10-29T14:58:14-04:00 | https://nyti.ms/2yVwtyp | Staff Sgt. Logan J. Melgar, 34, a veteran of two deployments to Afghanistan, was found dead on June 4, and his superiors almost immediately suspected foul play. |
Democrats Attack Tax Bill as a ‘Middle-Class Con Job’ | 2017-10-29T13:23:28-04:00 | https://nyti.ms/2iJm9FG | Democrats hope to turn back a Republican bill, painting it as a windfall for business and the rich, and instead work with President Trump on bipartisan legislation. |
Trump Tries to Shift Focus as First Charges Reportedly Loom in Russia Case | 2017-10-29T12:53:25-04:00 | https://nyti.ms/2yW54MV | In a series of Twitter posts, President Trump attacked Hillary Clinton, saying Republicans were now pushing back against the Russia allegations by looking into her. |
How a 672,000-Gallon Oil Spill Was Nearly Invisible | 2017-10-29T12:25:32-04:00 | https://nyti.ms/2iKZJnv | When a pipeline in the Gulf of Mexico cracked recently, most of the oil wasn’t perceptible. The depth was one reason, but environmental forces were another. |
A 40-Foot Cross Has Honored War Dead for 90 Years. Is It Unlawful? | 2017-10-29T09:17:10-04:00 | https://nyti.ms/2yXid8E | An appeals court ruled against the longstanding monument in Maryland, potentially setting up a Supreme Court decision on when religious symbols can be on public property. |
‘Bedlam Out Here in Arizona’ After Jeff Flake Departs Senate Race | 2017-10-29T09:12:16-04:00 | https://nyti.ms/2iIvgXq | The Republican senator’s surprise announcement not to run for re-election has thrown open the race to succeed him, igniting divisions in both major parties. |