array(c(fruits, cost), dim = c(3, 2, 1), dimnames = list(shop_name, : 'dimnames' [2] 的长度不等于数组范围
Error in array(c(fruits, cost), dim = c(3, 2, 1), dimnames = list(shop_name, : length of 'dimnames' [2] not equal to array extent
fruits = c('Apple', 'Banana', 'Grapes')
cost = c(20,10,30)
shop_name = c("Fruits guy", "Champa seller', "Bad mango"")
price = c("cost of fruits")
market_name = c("Jhoom Market")
shops_info = array(c(fruits, cost), dim=c(3,2,1), dimnames=list(shop_name, price, market_name))
print(shops_info)
问题是您的第二维尺寸为二。但是,维度名称 price
只有一个条目。 R 期望它有 2 个条目。这会起作用:
fruits = c('Apple', 'Banana', 'Grapes')
cost = c(20,10,30)
shop_name = c("Fruits guy", "Champa seller", "Bad mango")
price = c("cost of fruits", "Entry needed") #adding fictional name
market_name = c("Jhoom Market")
shops_info = array(c(fruits, cost), dim=c(3,2,1), dimnames=list(shop_name, price, market_name))
print(shops_info)
, , Jhoom Market
cost of fruits Entry needed
Fruits guy "Apple" "20"
Champa seller "Banana" "10"
Bad mango "Grapes" "30"
fruits = c('Apple', 'Banana', 'Grapes')
cost = c(20,10,30)
shop_name = c("Fruits guy", "Champa seller', "Bad mango"")
price = c("cost of fruits")
market_name = c("Jhoom Market")
shops_info = array(c(fruits, cost), dim=c(3,2,1), dimnames=list(shop_name, price, market_name))
print(shops_info)
问题是您的第二维尺寸为二。但是,维度名称 price
只有一个条目。 R 期望它有 2 个条目。这会起作用:
fruits = c('Apple', 'Banana', 'Grapes')
cost = c(20,10,30)
shop_name = c("Fruits guy", "Champa seller", "Bad mango")
price = c("cost of fruits", "Entry needed") #adding fictional name
market_name = c("Jhoom Market")
shops_info = array(c(fruits, cost), dim=c(3,2,1), dimnames=list(shop_name, price, market_name))
print(shops_info)
, , Jhoom Market
cost of fruits Entry needed
Fruits guy "Apple" "20"
Champa seller "Banana" "10"
Bad mango "Grapes" "30"