簡體   English   中英

-0.01 * 高度中的錯誤:R 中二元運算符的非數字參數

[英]Error in -0.01 * height : non-numeric argument to binary operator in R

#我正在嘗試在 plot 欄中可視化我的數據,(我剛開始使用 R,所以嘗試了一下)。 類似的語法適用於前兩個圖表,但是,對於這個,我不知道問題是什么!

s22 <- list("SUP Bottle"= 517.36, "Bottle Caps"= 10.52, "SUP Cups"= 37.96, "Tin"= 58.4, "SUP Bag"= 792.79, "Food Container"= 71.09, "Cloth"= 20.26, "Polyester bag"= 75.8, "Tetra Pack"= 11.09, "Packaging"= 347.36, "Wood"= 246.68, "Rubber"= 670, "Cardboard"= 470.73, "Iron Rod"= 344.21, "plastic pipe"= 40, "Aluminum"= 64, "lubricant bottle"= 102.17, "shoe"= 470.88)

barplot(s22, main = "Site 2.2", horiz = T, xlab = "Mass (g)", col="#69b3a2", las = 3, cex.axis = 1, las=2, cex.main = 2)

執行時顯示錯誤

“-0.01 * 高度錯誤:二元運算符的非數字參數”

然后我嘗試了

value <- c (517.36, 10.52, 37.96, 58.4,792.79, 71.09, 20.26, 75.8,11.09, 347.36, 246.68, 670, 470.73, 344.21,   40, 64,102.17, 470.88)
N <- C("SUP Bottle", "Bottle Caps", "SUP Cups","Tin","SUP Bag", "Food Container","Cloth", "Polyester bag", "Tetra Pack","Packaging", "Wood", "Rubber", "Cardboard","Iron Rod", "plastic pipe","Aluminum", "lubricant bottle", "shoe")
names(value) <- N

但它給出了另一個錯誤

C 中的錯誤(“SUP 瓶”、“瓶蓋”、“SUP 杯”、“錫”、“SUP 袋”,:object 無法解釋為一個因素”

將列表轉換為數據框。 然后運行你的代碼。

s22 <- list("SUP Bottle"= 517.36, "Bottle Caps"= 10.52, "SUP Cups"= 37.96, "Tin"= 58.4, "SUP Bag"= 792.79, "Food Container"= 71.09, "Cloth"= 20.26, "Polyester bag"= 75.8, "Tetra Pack"= 11.09, "Packaging"= 347.36, "Wood"= 246.68, "Rubber"= 670, "Cardboard"= 470.73, "Iron Rod"= 344.21, "plastic pipe"= 40, "Aluminum"= 64, "lubricant bottle"= 102.17, "shoe"= 470.88)

barplot(unlist(s22), main = "Site 2.2", horiz = T, xlab = "Mass (g)", col="#69b3a2", las = 3, cex.axis = 1, las=2, cex.main = 2)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM