The New York Times web site provides a rich set of APIs, as described here: http://developer.nytimes.com/docs You’ll need to start by signing up for an API key. Your task is to choose one of the New York Times APIs, construct an interface in R to read in the JSON data, and transform it to an R data frame.
After Obtaining the API key I used the fromJSON function from the JsonLite package.This allowed me to extract the top news articles from the NY Times Website.The request downloaded 28 observation with 23 columns.I only extracted 4 columns from the universe that I later renamed.Finally, I use the Kable function to format the data frame into a well formatted table.
url = "https://api.nytimes.com/svc/topstories/v2/home.json?sectionresponse_format"
api ="&api-key=31b11f11ba3f431d8f769aed3720d527"
getdata = fromJSON(paste0(url,api))
NYTimesData = data.frame(getdata)
FilterData = NYTimesData[, c("results.title", "results.abstract","results.byline","results.url" )]
colnames( FilterData) = c("Title","Snipet","Author","Link")
kable(FilterData)
| Title | Snipet | Author | Link |
|---|---|---|---|
| Hillary Clinton Assails James Comey, Calling Email Decision ‘Deeply Troubling’ | Mrs. Clintons campaign opened a coordinated attack on Mr. Comey, the F.B.I. director, accusing him of smearing her with innuendo late in the race. | By PATRICK HEALY and JONATHAN MARTIN | http://www.nytimes.com/2016/10/30/us/politics/hillary-clinton-emails-fbi-anthony-weiner.html |
| Justice Dept. Strongly Discouraged Comey on Move in Clinton Email Case | Senior officials warned the F.B.I. director on policies against talking about current criminal investigations or being seen as meddling in elections. | By MATT APUZZO, ADAM GOLDMAN, MICHAEL S. SCHMIDT and WILLIAM K. RASHBAUM | http://www.nytimes.com/2016/10/30/us/politics/comey-clinton-email-justice.html |
| A Scandal Too Far? Huma Abedin, Hillary Clinton, and a Test of Loyalty | Ms. Abedin once seemed like sure thing for a Clinton White House. But when your estranged husband calls himself “Carlos Danger,” all bets are off. | By AMY CHOZICK and MARK LANDLER | http://www.nytimes.com/2016/10/30/us/politics/huma-abedin-anthony-weiner-clinton.html |
| WikiLeaks Lays Bare a Clinton Insiders Emphatic Cheers and Jeers | Neera Tanden, through her leaked emails, has emerged as a loyal but insistent straight-talker and acute assessor of her candidates stubbornness and weaknesses. | By STEVE EDER and NICHOLAS CONFESSORE | http://www.nytimes.com/2016/10/30/us/politics/neera-tanden-wikileaks.html |
| Increase in Health Act Premiums May Affect Arizona Vote | Republican candidates here seized on the rate hikes, counting on the issue to buoy them with Election Day imminent and Donald J. Trump losing ground. | By ABBY GOODNOUGH | http://www.nytimes.com/2016/10/30/us/politics/affordable-health-care-premiums-arizona.html |
| Peter Thiel Defends His Most Contrarian Move Yet: Supporting Trump | The tech billionaire is known for bucking convention, but his backing of Mr. Trumps presidential bid has outraged much of Silicon Valley. | By DAVID STREITFELD | http://www.nytimes.com/2016/10/31/technology/peter-thiel-defends-his-most-contrarian-move-yet-supporting-trump.html |
| N.S.A. Appears to Have Missed ‘Big Red Flags’ in Suspects Behavior | Harold T. Martin III kept his security clearance despite a record that included drinking problems, unpaid tax bills and an episode in which he posed as a police officer. | By SCOTT SHANE and JO BECKER | http://www.nytimes.com/2016/10/30/us/harold-martin-nsa.html |
| Indians Rout Cubs and Move One Win From Series Title | Cleveland starter Corey Kluber pitched his second solid game of the Series and received plenty of offensive support, with Carlos Santana and Jason Kipnis hitting home runs. | By DAVID WALDSTEIN | http://www.nytimes.com/2016/10/30/sports/baseball/world-series-cleveland-indians-chicago-cubs.html |
| Seeking Clues to ISIS Strategy in Corpses and Cellphones Left in Kirkuk | The militants sudden move against Kirkuk provides a window into their strategy of taking sniper positions, stirring Sunni grievances and keeping forces in reserve. | By MICHAEL R. GORDON | http://www.nytimes.com/2016/10/30/world/middleeast/isis-counterterrorism-kirkuk-iraq.html |
| Doubts About the Promised Bounty of Genetically Modified Crops | Higher yields with less pesticides was the sales pitch for genetically modified seeds. But that has not proved to be the outcome in the United States. | By DANNY HAKIM | http://www.nytimes.com/2016/10/30/business/gmo-promise-falls-short.html |
| 2008 Was a Celebration. 2016 Is the Opposite. | Now its eight years later, at the end of a revolution that has not yet happened. | By KAITLYN GREENIDGE | http://www.nytimes.com/2016/10/30/opinion/sunday/2008-was-a-celebration-2016-is-the-opposite.html |
| In Defense of Politics, Now More Than Ever | It has been, and can again be, “the greatest and most honorable adventure.” | By PETER WEHNER | http://www.nytimes.com/2016/10/30/opinion/campaign-stops/in-defense-of-politics-now-more-than-ever.html |
| Comey, Clinton and This Steaming Mess | In the email saga, a fresh twist summons familiar hysteria. | By FRANK BRUNI | http://www.nytimes.com/2016/10/29/opinion/comey-clinton-and-this-steaming-mess.html |
| How to Run Across the Country Faster Than Anyone | It takes more than training to complete a transcontinental run. You need a crew and the belief that youre part of something greater than yourself. | By C. NATHAN DeWALL | http://www.nytimes.com/2016/10/26/well/move/how-to-run-across-the-country-faster-than-anyone.html |
| Talking to Your Therapist About Election Anxiety | Therapists say that some of the campaign issues safety, secrecy and boundaries play into our deepest worries. | By LESLEY ALDERMAN | http://www.nytimes.com/2016/10/20/well/mind/talking-to-your-therapist-about-election-anxiety.html |
| Long Before Twitter, Martin Luther Was a Media Pioneer | The 500th anniversary of Luthers 95 theses is being celebrated at institutions across the country, showing how deftly he used the media of his day. | By TANYA MOHN | http://www.nytimes.com/2016/10/30/arts/design/long-before-twitter-martin-luther-was-a-media-pioneer.html |
| Judging Others by Their Email Tics | Signoffs, the well-placed emoji, the use of exclamation points (or not). Its a minefield out there. | By JESSICA BENNETT | http://www.nytimes.com/2016/10/30/fashion/email-tone-signoff-emoji-punctuation.html |
| Guess Whats Back From the Grave? ‘Night of the Living Dead’ | George A. Romeros classic shuffler from 1968 has been restored and will be shown at MoMA. The original investors might even make a little money out of it. | By GLENN KENNY | http://www.nytimes.com/2016/10/30/movies/night-of-the-living-dead-back-from-the-grave.html |
| No Kegs, No Liquor: College Crackdown Targets Drinking and Sexual Assault | Dozens of universities have introduced stricter rules on alcohol, especially at fraternities. We sent reporters to five campuses to examine the new measures. | By THE NEW YORK TIMES | http://www.nytimes.com/2016/10/30/us/college-crackdown-drinking-sexual-assault.html |
| Powder Tossed at Metropolitan Opera May Have Been Human Ashes, Police Say | The Metropolitan Opera canceled a show before the final act after a man sprinkled a powdery substance into the orchestra pit. | By MICHAEL COOPER and CHRISTOPHER MELE | http://www.nytimes.com/2016/10/30/nyregion/metropolitan-opera-cancels-performance-white-substance.html |
| Medicaid Finds Opportune Time to Offer Birth Control: Right After Birth | In South Carolina, the program offers long-acting contraceptives during a new mothers hospital stay, while she is still eligible for the benefit. Other states are following suit. | By SABRINA TAVERNISE | http://www.nytimes.com/2016/10/29/health/birth-control-medicaid.html |
| Unhittable? Aroldis Chapman and His 105-M.P.H. Fastball | Even major league hitters struggle against the blazing pitches of the Chicago Cubs closer. But no pitcher can rely on velocity alone. | By TYLER KEPNER | http://www.nytimes.com/2016/10/30/sports/baseball/aroldis-chapman-105-mph-chicago-cubs.html |
| Jose Fernandez Had Cocaine and Alcohol in System When He Died in Boat Crash | It is not clear if the Marlins pitcher, 24, was steering his boat at the time it crashed on Sept. 25, killing him and two friends. | By THE ASSOCIATED PRESS | http://www.nytimes.com/2016/10/30/sports/baseball/jose-fernandez-had-cocaine-and-alcohol-in-system-when-he-died-in-boat-crash.html |
| Merciless End for a Long Island Cop Killer | John MacKenzie, who murdered Officer Matthew Giglio in 1975, repented and became a model inmate, but was repeatedly denied parole. It was too much for him to bear. | By JOSEPH GOLDSTEIN | http://www.nytimes.com/2016/10/30/nyregion/merciless-end-for-a-long-island-cop-killer.html |
| Growing Up in New York, the City That Never Naps | The New York Times asked readers to recall a moment when their child, or a child they knew well, said or did something that made them think, “This is a New York City kid.” Here is a selection of those responses. | By AMY ZERBA | http://www.nytimes.com/2016/10/30/nyregion/growing-up-in-new-york-the-city-that-never-naps.html |
| Telecoms Ambitions on Targeted Ads Seen Curbed by F.C.C.s New Privacy Rules | AT&Ts and Verizons hopes of collecting and analyzing customer data to sell advertising may be dashed if they have to ask customers permission. | By SAPNA MAHESHWARI and CECILIA KANG | http://www.nytimes.com/2016/10/29/business/media/telecoms-ambitions-on-targeted-ads-seen-curbed-by-fccs-new-privacy-rules.html |
| The School of Wants and Needs and Wood-Fired Showers | A prep school that prepares students for entry into competitive colleges, but also teaches them how to raise livestock, grow vegetables and chop wood. | By RON LIEBER | http://www.nytimes.com/2016/10/29/your-money/california-prep-school-teaches-self-reliance.html |
| Populist Wave Likely to Lift Icelands Pirate Party | The anti-establishment party is poised to make big gains in Icelands general election, with voters expressing anger over government corruption. | By KIMIKO DE FREYTAS-TAMURA | http://www.nytimes.com/2016/10/30/world/europe/pirate-party-iceland-election.html |