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)
The problem is that your second dimension is of size two. However, the name of the dimension price
has only one entry. R is expecting it to have 2 entries. This would work:
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"