我正在 R 中創建雷達圖,但不斷收到此錯誤。我正在在線瀏覽資源,并且對我如何擁有錯誤數量的引數感到非常困惑。
我的代碼:
library(fmsb)
# Data
soccer_stats <- data.frame(
row.names = c("Successful Dribbles", "Attempted Dribbles", "Successful %",
"# of Players Dribbled Past"),
Galvan = c(22, 32, 68.8, 22),
LeagueAverage = c(11.5, 19.9, 60.4, 12.4)
)
soccer_stats
# Define the variable ranges: maximum and minimum
max_min <- data.frame(
SuccessfulDribbles = c(25, 10), AttemptedDribbles = c(35, 15),
SuccessfulPercentage = c(70, 55), NumOfPlayersDribbled = c(25, 10)
)
rownames(max_min) <- c("Max", "Min")
# Bind the variable ranges to the data
df <- rbind(max_min, soccer_stats)
df
當我運行它時,它給了我以下錯誤:
df <- rbind(max_min, Football_stats) rbind(deparse.level, ...) 錯誤:引數列數不匹配
我應該輸入哪些其他論點?
uj5u.com熱心網友回復:
錯誤訊息實際上是說引數的列不匹配。在 rbind 中,您將矩陣粘合在一起,一個在另一個之上。這意味著它們都需要具有相同數量的列。如您所見,max_min 有 4 列,而 Football_stats 有 2 列。也許您正在尋找 cbind。如果是這樣,只需洗掉 max_min 的行名以避免出現警告訊息。
cbind(max_min,soccer_stats)
這是 rind/cbind 幫助檔案中的相關參考:
如果有多個矩陣引數,它們都必須具有相同的列(或行)數,這將是結果的列(或行)數。
uj5u.com熱心網友回復:
rbind需要兩個資料框具有相同數量的變數和相同的名稱。你的不滿足這些條件中的任何一個
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/356528.html
標籤:r
上一篇:R中的資料框行重復
下一篇:從資料框中洗掉不包含任何數值的行
