Create an app with NY Times Developer and create an API key. Load this JSON into a dataframe using libraries (jsonlite, stringr etc)
#Retrieve data from NYTimes API
nyc_df <- fromJSON("https://api.nytimes.com/svc/mostpopular/v2/emailed/1.json?api-key=rwOfaQmATwYG0nznEENYpGw3XOjBUKMr")
#Since there are multiple nestings of data, jsonlite packages created a list instead of a dataframe. The fourth element in the list contains teh results
nyc_results <- nyc_df[4]
#Create a null data frame
nyc_final_df <- NULL
#Iterator over the list of results and load the data into data frame
for (i in 1:length(nyc_results)) {
row <- nyc_results[i]
nyc_final_df <- rbind(nyc_final_df, data.frame(row))
}
#Update the colnames to remove a redundant string 'results.'
colnames(nyc_final_df) <- colnames(nyc_final_df) %>% str_replace_all("results.", "")
#Load the data frame into a table using kable_extra package
nyc_final_df[1:20] %>% kable() %>% kable_styling(bootstrap_options = c("striped", "hover"), fixed_thead = T) %>% scroll_box(width = "1250px", height = "600px")
| url | adx_keywords | subsection | email_count | count_type | column | eta_id | section | id | asset_id | nytdsection | byline | type | title | abstract | published_date | source | updated | des_facet | org_facet |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| https://www.nytimes.com/2019/03/28/health/woman-pain-anxiety.html | Pain;Anxiety and Stress;Cameron, Jo;Srivastava, Devjit;British Journal of Anaesthesia;Genetics and Heredity;Opioids and Opiates;Pain-Relieving Drugs;University College London;Scotland | 1 | EMAILED | NA | 0 | Health | 1e+14 | 1e+14 | health | By HEATHER MURPHY | Article | At 71, She’s Never Felt Pain or Anxiety. Now Scientists Know Why. | Scientists discovered a previously unidentified genetic mutation in a Scottish woman. They hope it could lead to the development of new pain treatment. | 2019-03-28 | The New York Times | 2019-03-30 16:43:35 | c(“ANXIETY AND STRESS”, “GENETICS AND HEREDITY”, “OPIOIDS AND OPIATES”, “PAIN-RELIEVING DRUGS”) | c(“PAIN”, “BRITISH JOURNAL OF ANAESTHESIA”, “UNIVERSITY COLLEGE LONDON”) | |
| https://www.nytimes.com/2019/03/28/well/eat/food-mood-depression-anxiety-nutrition-psychiatry.html | Diet and Nutrition;Mental Health and Disorders;Depression (Mental);Brain;Omega-3 Fatty Acids;Anxiety and Stress;Cooking and Cookbooks;Vegetables | eat | 2 | EMAILED | NA | 0 | Well | 1e+14 | 1e+14 | well | By RICHARD SCHIFFMAN | Article | Can What We Eat Affect How We Feel? | Nutritional psychiatrists counsel patients on how better eating may be another tool in helping to ease depression and anxiety and may lead to better mental health. | 2019-03-28 | The New York Times | 2019-03-29 15:06:41 | c(“DIET AND NUTRITION”, “MENTAL HEALTH AND DISORDERS”, “ANXIETY AND STRESS”, “COOKING AND COOKBOOKS”) | c(“DEPRESSION (MENTAL)”, “BRAIN”, “OMEGA-3 FATTY ACIDS”, “VEGETABLES”) |
| https://www.nytimes.com/2019/03/25/smarter-living/why-you-procrastinate-it-has-nothing-to-do-with-self-control.html | Procrastination;Emotions;Psychology and Psychologists;Anxiety and Stress;Boredom | 3 | EMAILED | NA | 0 | Smarter Living | 1e+14 | 1e+14 | smarter living | By CHARLOTTE LIEBERMAN | Article | Why You Procrastinate (It Has Nothing to Do With Self-Control) | If procrastination isn’t about laziness, then what is it about? | 2019-03-25 | The New York Times | 2019-03-28 11:08:43 | c(“PROCRASTINATION”, “PSYCHOLOGY AND PSYCHOLOGISTS”, “ANXIETY AND STRESS”) | c(“EMOTIONS”, “BOREDOM”) | |
| https://www.nytimes.com/2019/03/29/opinion/california-super-bloom-.html | Deserts;Hikes and Hiking;Flowers and Plants;Parks and Other Recreation Areas;National Parks, Monuments and Seashores;Sierra Club;James, Henry;Muir, John;Olmsted, Frederick Law;California;Yosemite National Park (Calif);San Diego (Calif) | 4 | EMAILED | NA | 0 | Opinion | 1e+14 | 1e+14 | opinion | By MIRIAM PAWEL | Article | California Is Swooning Over a Heavenly Super Bloom of Wildflowers | Exceptional beauty is a welcome respite in a place that has been battered by extreme climate conditions. | 2019-03-29 | The New York Times | 2019-03-30 15:06:56 | c(“DESERTS”, “HIKES AND HIKING”, “FLOWERS AND PLANTS”) | c(“PARKS AND OTHER RECREATION AREAS”, “NATIONAL PARKS, MONUMENTS AND SEASHORES”, “SIERRA CLUB”) | |
| https://www.nytimes.com/2019/03/28/opinion/internet-cleanse.html | Social Media;Philosophy;News and News Media;United States Politics and Government;Art;Fujimura, Makoto;Heschel, Abraham Joshua;Jews and Judaism | 5 | EMAILED | NA | 0 | Opinion | 1e+14 | 1e+14 | opinion | By DAVID BROOKS | Article | Longing for an Internet Cleanse | A small rebellion against the quickening of time. | 2019-03-28 | The New York Times | 2019-03-29 22:14:32 | c(“SOCIAL MEDIA”, “NEWS AND NEWS MEDIA”, “UNITED STATES POLITICS AND GOVERNMENT”, “ART”, “JEWS AND JUDAISM”) | PHILOSOPHY | |
| https://www.nytimes.com/2019/03/29/science/dinosaurs-extinction-asteroid.html | Paleontology;Dinosaurs;Fossils;Meteors and Meteorites;North Dakota;Endangered and Extinct Species;Asteroids;Geology;Alvarez, Walter (1940- );DePalma, Robert A;Manning, Phillip L;Proceedings of the National Academy of Sciences;your-feed-science | 6 | EMAILED | NA | 0 | Science | 1e+14 | 1e+14 | science | By WILLIAM J. BROAD and KENNETH CHANG | Article | Fossil Site Reveals Day That Meteor Hit Earth and, Maybe, Wiped Out Dinosaurs | A jumble of entombed plants and creatures offers a vivid glimpse of the apocalypse that all but ended life 66 million years ago. | 2019-03-29 | The New York Times | 2019-03-30 17:34:52 | c(“PALEONTOLOGY”, “DINOSAURS”, “ASTEROIDS”, “GEOLOGY”, “YOUR-FEED-SCIENCE”) | c(“FOSSILS”, “METEORS AND METEORITES”, “ENDANGERED AND EXTINCT SPECIES”, “PROCEEDINGS OF THE NATIONAL ACADEMY OF SCIENCES”) | |
| https://www.nytimes.com/2019/03/28/magazine/battle-over-bds-israel-palestinians-antisemitism.html | United States Politics and Government;Israel;Boycott, Divestment and Sanctions (BDS);Anti-Semitism;Palestinians;Jews and Judaism;Israeli Settlements;United States International Relations;Freedom of Speech and Expression;Boycotts;American Israel Public Affairs Committee;American Jewish Committee;Democratic Party;Hillel, The Foundation for Jewish Campus Life;House of Representatives;Omar, Ilhan | 7 | EMAILED | Feature | 0 | Magazine | 1e+14 | 1e+14 | magazine | By NATHAN THRALL | Article | How the Battle Over Israel and Anti-Semitism Is Fracturing American Politics | The growing prominence of the B.D.S. movement — and the backlash to it — is widening fault lines from college campuses to Capitol Hill. | 2019-03-28 | The New York Times | 2019-03-29 22:14:22 | c(“PALESTINIANS”, “ISRAELI SETTLEMENTS”) | c(“UNITED STATES POLITICS AND GOVERNMENT”, “BOYCOTT, DIVESTMENT AND SANCTIONS (BDS)”, “ANTI-SEMITISM”, “JEWS AND JUDAISM”, “UNITED STATES INTERNATIONAL RELATIONS”, “FREEDOM OF SPEECH AND EXPRESSION”, “BOYCOTTS”, “AMERICAN ISRAEL PUBLIC AFFAIRS COMMITTEE”, “AMERICAN JEWISH COMMITTEE”, “DEMOCRATIC PARTY”, “HILLEL, THE FOUNDATION FOR JEWISH CAMPUS LIFE”, “HOUSE OF REPRESENTATIVES”) | |
| https://www.nytimes.com/2019/03/29/realestate/the-gurus-of-tidiness-if-you-like-marie-kondo.html | Real Estate and Housing (Residential);Orderliness and Clutter;Books and Literature;Kondo, Marie;The Life-Changing Magic of Tidying Up (Book);Rubin, Gretchen;Outer Order, Inner Calm: Declutter and Organize to Make More Room for Happiness (Book);Shearer, Clea (Author);Teplin, Joanna (Author);The Home Edit: A Guide to Organizing and Realizing Your House Goals (Book);The Minimalist Home: A Room-by-Room Guide to a Decluttered, Refocused Life (Book);Becker, Joshua (Author) | 8 | EMAILED | NA | 0 | Real Estate | 1e+14 | 1e+14 | real estate | By RONDA KAYSEN | Article | The Gurus of Tidiness: If You Like Marie Kondo … | The Japanese organizer may be the star of the moment, but others have equally appealing theories and strategies for decluttering your home. | 2019-03-29 | The New York Times | 2019-03-29 18:22:45 | c(“REAL ESTATE AND HOUSING (RESIDENTIAL)”, “ORDERLINESS AND CLUTTER”) | BOOKS AND LITERATURE | |
| https://www.nytimes.com/2019/03/29/sunday-review/biosphere-2-climate-change.html | Greenhouse Gas Emissions;Sustainable Living;University of Arizona;Biosphere 2;Bass, Edward P (1945- ) | 9 | EMAILED | news analysis | 0 | Sunday Review | 1e+14 | 1e+14 | sunday review | By CARL ZIMMER | Article | The Lost History of One of the World’s Strangest Science Experiments | The hummingbirds were dying. Cockroaches were everywhere. And then Steve Bannon showed up. | 2019-03-29 | The New York Times | 2019-03-30 00:40:03 | c(“GREENHOUSE GAS EMISSIONS”, “SUSTAINABLE LIVING”, “UNIVERSITY OF ARIZONA”) | ||
| https://www.nytimes.com/2019/03/28/smarter-living/productivity-isnt-about-time-management-its-about-attention-management.html | Creativity;Boredom;attention;Productivity | 10 | EMAILED | NA | 0 | Smarter Living | 1e+14 | 1e+14 | smarter living | By ADAM GRANT | Article | Productivity Isn’t About Time Management. It’s About Attention Management. | “Time management” is not a solution — it’s actually part of the problem. | 2019-03-28 | The New York Times | 2019-03-30 17:44:20 | c(“BOREDOM”, “PRODUCTIVITY”) | CREATIVITY | |
| https://www.nytimes.com/2019/03/29/style/mary-boone-tax-evasion.html | Art;Boone, Mary (1951- );Tax Evasion;Boone, Mary, Gallery;Baldwin, Alec;Basquiat, Jean-Michel;Bleckner, Ross | 11 | EMAILED | NA | 0 | Style | 1e+14 | 1e+14 | style | By JACOB BERNSTEIN | Article | Mary Boone Is Not Done | One of New York’s leading art dealers, convicted of tax evasion, will report to prison in May. She’s already plotting her return. | 2019-03-29 | The New York Times | 2019-03-30 13:28:35 | ART | c(“TAX EVASION”, “BOONE, MARY, GALLERY”) | |
| https://www.nytimes.com/2019/03/29/opinion/theresa-may.html | Great Britain Withdrawal from EU (Brexit);Politics and Government;Conservative Party (Great Britain);May, Theresa M;Great Britain | 12 | EMAILED | NA | 0 | Opinion | 1e+14 | 1e+14 | opinion | By JENNI RUSSELL | Article | Is Theresa May the Worst Politician Ever? | The British prime minister’s deal has failed. Again. | 2019-03-29 | The New York Times | 2019-03-30 04:35:10 | c(“GREAT BRITAIN WITHDRAWAL FROM EU (BREXIT)”, “POLITICS AND GOVERNMENT”) | CONSERVATIVE PARTY (GREAT BRITAIN) | |
| https://www.nytimes.com/2019/03/28/opinion/trump-obamacare.html | Health Insurance and Managed Care;Patient Protection and Affordable Care Act (2010);Trump, Donald J;Republican Party;Democratic Party;House of Representatives;Senate;United States Politics and Government;Presidential Election of 2020 | 13 | EMAILED | NA | 0 | Opinion | 1e+14 | 1e+14 | opinion | By PAUL KRUGMAN | Article | G.O.P. Cruelty Is a Pre-existing Condition | Republicans just won’t stop trying to take away health care. | 2019-03-28 | The New York Times | 2019-03-29 22:14:32 | c(“HEALTH INSURANCE AND MANAGED CARE”, “PATIENT PROTECTION AND AFFORDABLE CARE ACT (2010)”, “UNITED STATES POLITICS AND GOVERNMENT”, “PRESIDENTIAL ELECTION OF 2020”) | c(“REPUBLICAN PARTY”, “DEMOCRATIC PARTY”, “HOUSE OF REPRESENTATIVES”, “SENATE”) | |
| https://www.nytimes.com/2019/03/28/us/politics/buttigieg-2020-president.html | Buttigieg, Pete (1982- );Democratic Party;Presidential Election of 2020;United States Politics and Government;Polls and Public Opinion;South Bend (Ind) | politics | 14 | EMAILED | NA | 0 | U.S. | 1e+14 | 1e+14 | u.s. | By TRIP GABRIEL | Article | Pete Buttigieg (It’s ‘Boot-Edge-Edge’) Is Making Waves in the 2020 Race | Pete Buttigieg may have a challenging last name and an unconventional résumé. But he’s drawing big crowds and has jumped to third place in a poll of Iowa voters. | 2019-03-28 | The New York Times | 2019-03-29 13:17:05 | c(“PRESIDENTIAL ELECTION OF 2020”, “UNITED STATES POLITICS AND GOVERNMENT”) | c(“DEMOCRATIC PARTY”, “POLLS AND PUBLIC OPINION”) |
| https://www.nytimes.com/2019/03/28/theater/the-lehman-trilogy-review-sam-mendes.html | Theater;The Lehman Trilogy (Play);Miles, Ben (1976- );Godley, Adam;Beale, Simon Russell;Mendes, Sam;Massini, Stefano;Power, Ben (Playwright);Park Avenue Armory (Manhattan, NY) | 15 | EMAILED | Critic’s Pick | 0 | Theater | 1e+14 | 1e+14 | theater | By BEN BRANTLEY | Article | Review: A Magnificent Road to Ruin in ‘The Lehman Trilogy’ | This three-hour-plus portrait of the creation and destruction of the house of Lehman, directed by Sam Mendes, is an endlessly absorbing epic tragedy. | 2019-03-28 | The New York Times | 2019-03-29 14:22:19 | THEATER | PARK AVENUE ARMORY (MANHATTAN, NY) | |
| https://www.nytimes.com/2019/03/29/obituaries/agnes-varda-dead.html | Varda, Agnes;Deaths (Obituaries);Movies;The Gleaners and I (Movie);One Sings, the Other Doesn’t (Movie);France | 16 | EMAILED | NA | 0 | Obituaries | 1e+14 | 1e+14 | obituaries | By JOHN ANDERSON | Article | Agnès Varda, Influential French New Wave Filmmaker, Dies at 90 | Ms. Varda was closely associated with the movement known as the New Wave, although her reimagining of cinematic conventions actually predated it. | 2019-03-29 | The New York Times | 2019-03-30 15:30:28 | MOVIES | DEATHS (OBITUARIES) | |
| https://www.nytimes.com/2019/03/29/world/europe/garfield-phones-france.html | Garfield (Fictional Character);France;Ships and Shipping;Plastics;Water Pollution;Brittany (France) | europe | 17 | EMAILED | NA | 0 | World | 1e+14 | 1e+14 | world | By PALKO KARASZ | Article | Why Do Garfield Phones Keep Washing Up on This Beach? | Bright orange plastic novelty phones, shaped like Garfield, the grumpy cartoon cat, have littered French shores for decades. Nobody knew why, until a group of volunteers followed a tip. | 2019-03-29 | The New York Times | 2019-03-30 04:11:42 | c(“GARFIELD (FICTIONAL CHARACTER)”, “SHIPS AND SHIPPING”, “PLASTICS”) | WATER POLLUTION |
| https://www.nytimes.com/2019/03/29/opinion/trump-climate-lawsuit-juliana.html | Greenhouse Gas Emissions;Federal Lands;Oil (Petroleum) and Gasoline;Interior Department;Bernhardt, David L;Western States (US) | 18 | EMAILED | NA | 0 | Opinion | 1e+14 | 1e+14 | opinion | By TIMOTHY EGAN | Article | Your Public Lands Are Killing You | We are squandering millions of acres of our children’s inheritance and using it to destroy the planet. | 2019-03-29 | The New York Times | 2019-03-30 13:34:32 | c(“GREENHOUSE GAS EMISSIONS”, “FEDERAL LANDS”, “OIL (PETROLEUM) AND GASOLINE”) | INTERIOR DEPARTMENT | |
| https://www.nytimes.com/2019/03/27/well/move/what-your-exercise-habits-might-say-about-how-long-youll-live.html | Athletics and Sports;Longevity;Exercise;Heart;Deaths (Fatalities);Age, Chronological | move | 19 | EMAILED | Phys Ed | 0 | Well | 1e+14 | 1e+14 | well | By GRETCHEN REYNOLDS | Article | What Your Exercise Habits Might Say About How Long You’ll Live | If people start to exercise in midlife, even if they have not worked out for years, they can rapidly gain most of the longevity benefits of working out. | 2019-03-27 | The New York Times | 2019-03-28 09:43:09 | c(“ATHLETICS AND SPORTS”, “LONGEVITY”, “EXERCISE”, “AGE, CHRONOLOGICAL”) | c(“HEART”, “DEATHS (FATALITIES)”) |
| https://www.nytimes.com/2019/03/29/travel/airline-booking-strategies.html | Budget Travel;Prices (Fares, Fees and Rates);Travel and Vacations;Airlines and Airplanes | 20 | EMAILED | Frugal Traveler | 0 | Travel | 1e+14 | 1e+14 | travel | By ELAINE GLUSAC | Article | Airline Booking Hacks: What Works, and What Might Get You in Trouble | Finding the lowest airfare has become a favorite frugal pastime, and there are websites to help you nail down cheap fares. Some strategies, however, are dicey. | 2019-03-29 | The New York Times | 2019-03-30 10:05:03 | c(“BUDGET TRAVEL”, “PRICES (FARES, FEES AND RATES)”, “AIRLINES AND AIRPLANES”) | TRAVEL AND VACATIONS |