如何使var无效以执行inner_join函数?

时间:2019-04-12 07:20:39

标签: r dplyr inner-join tidyverse

我正在使用inner_join函数合并两个对象。代码看起来像这样

string(42) "Word word 24H72 word 14D52 14Ad52 14D 14Ab"

我遇到以下错误

combined <- inner_join(weekly,nifty.curr.weekly) %>% as.data.frame()

我尝试过

combined <- inner_join(weekly,nifty.curr.weekly) %>% as.data.frame()
Joining, by = "date"
Error in inner_join_impl(x, y, by$x, by$y, suffix$x, suffix$y, check_na_matches(na_matches)) : 
  unknown group column 'year'

但是没有用。

weekly$year <- NULL 给了我类似的东西

str(weekly)

很明显有“年”,但是'data.frame': 1249557 obs. of 4 variables: $ date : Date, format: "2008-10-10" "2008-10-17" ... $ co_code : int 11 11 11 11 11 11 11 11 11 11 ... $ company_name : chr "20 MICRONS LTD." "20 MICRONS LTD." "20 MICRONS LTD." "20 MICRONS LTD." ... $ weeklyreturns: num -0.3718 -0.0509 -0.3021 0.0568 0.1823 ... - attr(*, "vars")= chr "co_code" "company_name" "year" - attr(*, "drop")= logi TRUE 没有显示任何列作为年。我对R很陌生。请帮帮我。

head(weekly)输出是

dput(head(weekly))

structure(list(date = structure(c(14162, 14169, 14176, 14183, 14190, 14197), class = "Date"), co_code = c(11L, 11L, 11L, 11L, 11L, 11L), company_name = c("20 MICRONS LTD.", "20 MICRONS LTD.", "20 MICRONS LTD.", "20 MICRONS LTD.", "20 MICRONS LTD.", "20 MICRONS LTD." ), weeklyreturns = c(-0.371829432619424, -0.0508551219831974, -0.302077648370433, 0.0567530464383245, 0.182326044668884, -0.123195412632735 )), vars = c("co_code", "company_name", "year"), drop = TRUE, .Names = c("date", "co_code", "company_name", "weeklyreturns"), row.names = c(NA, 6L), class = "data.frame") 输出是

dput(head(nifty.curr.weekly))

0 个答案:

没有答案