R错误:过滤器比时间序列长

时间:2017-04-03 15:35:13

标签: r

我正在尝试重现以下代码:https://gist.github.com/jdavidson/8591371

我收到以下错误:

  

过滤器出错(geocode_summary,rounds $ funding_year == year):     '过滤器'比时间序列长

这发生在第44-48行:

saveGIF({
for(year in years) {
    print(ggmap(us_map) +
      theme(legend.position=c(.9,.2),
        legend.key = element_rect(fill=alpha("white", .2)),
        legend.background = element_rect(fill=alpha("white", .9)),
        axis.line=element_blank(), axis.text.x=element_blank(),
        axis.text.y=element_blank(), axis.ticks=element_blank(),
        axis.title.x=element_blank(), axis.title.y=element_blank()) +
      ggtitle(paste(year)) +
      geom_point(data=filter(geocode_summary, rounds$funded_year == year),
        aes(x=lon, y=lat, size=raised_amount_usd / 1e9), alpha=.6, color="blue") +
      scale_size_area(name="Billions ($)", max_size=20,
        limits=c(1, max(geocode_summary$raised_amount_usd / 1e9))))
}
}, interval=2, movie.name="raised-year.gif", ani.width=640, ani.height=640)

可重复的例子:

这是rounds

structure(list(company_permalink = c("/organization/1-800-dentist", "/organization/1-800-dentist", "/organization/1000-corks","/organization/1000-markets", "/organization/1000-markets", "/organization/1000-markets", "/organization/1000memories", "/organization/1000memories", "/organization/1000memories", "/organization/1000memories"), company_name = c("1-800-DENTIST", "1-800-DENTIST", "1000 Corks", "1000 Markets", "1000 Markets", "1000 Markets","1000memories", "1000memories", "1000memories", "1000memories"), company_category_list = c("|Health and Wellness|", "|Health and Wellness|", "|Search|", "|Marketplaces|Art|E-Commerce|", "|Marketplaces|Art|E-Commerce|", "|Marketplaces|Art|E-Commerce|", "|Curated Web|", "|Curated Web|", "|Curated Web|", "|Curated Web|"), company_market = c("Health and Wellness", "Health and Wellness", "Search", "Marketplaces", "Marketplaces", "Marketplaces", "Curated Web", "Curated Web", "Curated Web", "Curated Web"), company_country_code = c("USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA"), company_state_code = c("CA", "CA", "OR", "WA", "WA", "WA", "CA", "CA", "CA", "CA"), company_region = c("LOS ANGELES", "LOS ANGELES", "PORTLAND, OREGON", "SEATTLE", "SEATTLE", "SEATTLE", "SF BAY AREA", "SF BAY AREA", "SF BAY AREA", "SF BAY AREA"), company_city = c("LOS ANGELES", "LOS ANGELES", "LAKE OSWEGO", "SEATTLE", "SEATTLE", "SEATTLE", "SAN FRANCISCO", "SAN FRANCISCO", "SAN FRANCISCO", "SAN FRANCISCO"), investor_permalink = c("/organization/bain-capital-ventures", "/organization/cue-ball", "/organization/start-up-chile", "/organization/ff-angel-llc", "/organization/true-ventures", "/person/jon-callaghan", "/organization/founder-collective", "/organization/y-combinator", "/organization/felicis-ventures", "/organization/floodgate"), investor_name = c("Bain Capital Ventures", "Cue Ball", "Start-Up Chile", "FF Angel LLC", "True Ventures", "Jon Callaghan", "Founder Collective", "Y Combinator", "Felicis Ventures", "FLOODGATE"), investor_category_list = c("", "|SaaS|Cloud Data Services|Big Data Analytics|Big Data|Information Services|Digital Media|Enterprise Software|", "", "", "|Venture Capital|", "", "|SaaS|Mobile|Quantified Self|E-Commerce|Internet of Things|Software|", "|Startups|Consulting|Venture Capital|Finance|", "|Investment Management|", "|Startups|Venture Capital|Finance|"), investor_market = c("", "Enterprise Software", "", "", "Venture Capital", "", "Software", "Finance", "Investment Management", "Venture Capital"), investor_country_code = c("USA", "USA", "CHL", "USA", "USA", "", "USA", "USA", "USA", "USA"), 
investor_state_code = c("MA", "MA", "", "CA", "CA", "", "MA", 
"CA", "CA", "CA"), investor_region = c("Boston", "Boston", 
"Santiago", "SF Bay Area", "SF Bay Area", "", "Boston", "SF Bay Area", 
"SF Bay Area", "SF Bay Area"), investor_city = c("Boston", 
"Boston", "Santiago", "San Francisco", "Palo Alto", "", "Cambridge", 
"Mountain View", "Palo Alto", "Palo Alto"), funding_round_permalink = c("/funding-round/5274aacc211163fc7c86539ce94bbacc", 
"/funding-round/5274aacc211163fc7c86539ce94bbacc", "/funding-round/8f4fa70e24269ddd8bdf6658906b356b", 
"/funding-round/ce6749b6441f52ccaf38b6d5578779fd", "/funding-round/ce6749b6441f52ccaf38b6d5578779fd", 
"/funding-round/ce6749b6441f52ccaf38b6d5578779fd", "/funding-round/f5fb428ed1e63321f88b3e646ba85f00", 
"/funding-round/f5fb428ed1e63321f88b3e646ba85f00", "/funding-round/502bd0e50c27616995e4bdad24605ef8", 
"/funding-round/502bd0e50c27616995e4bdad24605ef8"), funding_round_type = c("undisclosed", 
"undisclosed", "seed", "seed", "seed", "seed", "seed", "seed", 
"venture", "venture"), funding_round_code = c("", "", "", 
"", "", "", "", "", "A", "A"), funded_at = structure(c(14822, 
14822, 15187, 14365, 14365, 14365, 14610, 14610, 15006, 15006
), class = "Date"), funded_month = c("2010-08", "2010-08", 
"2011-08", "2009-05", "2009-05", "2009-05", "2010-01", "2010-01", 
"2011-02", "2011-02"), funded_quarter = c("2010-Q3", "2010-Q3", 
"2011-Q3", "2009-Q2", "2009-Q2", "2009-Q2", "2010-Q1", "2010-Q1", 
"2011-Q1", "2011-Q1"), funded_year = c(2010L, 2010L, 2011L, 
2009L, 2009L, 2009L, 2010L, 2010L, 2011L, 2011L), raised_amount_usd = c(NA, 
NA, 40000, 5e+05, 5e+05, 5e+05, 15000, 15000, 2520000, 2520000
), geocode = c("LOS ANGELES CA USA", "LOS ANGELES CA USA", 
"PORTLAND, OREGON OR USA", "SEATTLE WA USA", "SEATTLE WA USA", 
"SEATTLE WA USA", "SF BAY AREA CA USA", "SF BAY AREA CA USA", 
"SF BAY AREA CA USA", "SF BAY AREA CA USA")), .Names = c("company_permalink", "company_name", "company_category_list", "company_market", "company_country_code", "company_state_code", "company_region", "company_city", "investor_permalink", "investor_name", "investor_category_list", "investor_market", "investor_country_code", "investor_state_code", "investor_region", "investor_city", "funding_round_permalink", "funding_round_type", "funding_round_code", "funded_at", "funded_month", "funded_quarter", "funded_year", "raised_amount_usd", "geocode"), row.names = c(NA, 10L), class = c("data.table", "data.frame"))

这是geocode_summary

structure(list(geocode = c("LOS ANGELES CA USA", "PORTLAND, OREGON OR USA", 
"SEATTLE WA USA", "SF BAY AREA CA USA", "SF BAY AREA CA USA", 
"SEATTLE WA USA", "NEW YORK CITY NY USA", "HUNTSVILLE AL USA", 
"PROVIDENCE RI USA", "LOS ANGELES CA USA"), funded_year = c(2010L, 
2011L, 2009L, 2010L, 2011L, 2011L, 2010L, 2011L, 2012L, 2012L
), rounds = c(302L, 107L, 180L, 2829L, 3903L, 265L, 841L, 1L, 
27L, 287L), raised_amount_usd = c(2699217887, 807773000, 15172711760, 
29348141361, 51835224232, 1428015838, 4839925602, 1800000, 104189000, 
3206791194), X = c(1L, 2L, 3L, 4L, 4L, 3L, 5L, 6L, 7L, 1L), lon = c(-118.2436849, 
-122.6764816, -122.3320708, -122.2913078, -122.2913078, -122.3320708, 
-74.0059413, -86.5861037, -71.4128343, -118.2436849), lat = c(34.0522342, 
45.5230622, 47.6062095, 37.8271784, 37.8271784, 47.6062095, 40.7127837, 
34.7303688, 41.8239891, 34.0522342)), .Names = c("geocode", "funded_year", 
"rounds", "raised_amount_usd", "X", "lon", "lat"), row.names = c(NA, 
10L), class = "data.frame")

0 个答案:

没有答案