試圖將結果列從df2分離爲2個單獨的列(「Winner」,「Loser」),並使用下面的代碼從每個新列中刪除數字,但會收到以下錯誤消息。進行糾正?dplyr單獨返回錯誤
df2 <- data.frame(Year = c(2015:1903), Results = c("Winner", "Loser"))
df2 %>% separate(type, c("Winner", "Loser"), ",")
Error in if (!after) c(values, x) else if (after >= lengx) c(x, values) else c(x[1L:after], :
argument is of length zero
DF2
Year Results MVP
1 2015 Royals 4, Mets 1 Salvador Perez
2 2014 Giants 4, Royals 3 Madison Bumgarner
3 2013 Red Sox 4, Cardinals 2 David Ortiz
4 2012 Giants 4, Tigers 0 Pablo Sandoval
5 2011 Cardinals 4, Rangers 3 David Freese
.
.
125 1906 Chicago White Sox 4, Chicago Cubs 2 --
126 1905 NY Giants 4, Philadelphia A's 1 --
128 1903 Boston Red Sox 5, Pittsburgh 3 --
你已經檢查了'DF2 <做到這一點 - 數據。框架(...'這是給我錯誤 – akrun
你也可以使用'separate_' –