I need to display name of the car which has max cylinders. Only name nothing else
#READING THE AUTO FILE
myfile=read.csv("Auto.csv")
#creating the matrix
mpg =c(myfile$mpg)
cylinders=c(myfile$cylinders)
displacement=c(myfile$displacement)
horsepower=c(myfile$horsepower)
weight=c(myfile$weight)
acceleration=c(myfile$acceleration)
year=c(myfile$year)
origin=c(myfile$origin)
name=c(myfile$name)
matrixAuto=matrix(c(mpg,cylinders,displacement,horsepower,weight,acceleration,year,origin),20,8)
matrixAuto
rownames(matrixAuto)=c("chevrolet chevelle malibu","buick skylark 320","plymouth satellite","amc rebel sst","ford torino","ford galaxie 500","chevrolet impala","plymouth fury iii","pontiac catalina","amc ambassador dpl","dodge challenger se","plymouth 'cuda 340","chevrolet monte carlo","buick estate wagon (sw)","toyota corona mark ii","plymouth duster","amc hornet","ford maverick","datsun pl510","volkswagen 1131 deluxe sedan")
matrixAuto
colnames(matrixAuto)=c("mpg","cylinders","displacement","horsepower","weight","accelaration","year","origin")
m=max(cylinders)==cylinders
HOW DO I RETRIEVE THE car NAME USING m?
Also I solved it but didn't understand why this worked rownames(matrixAuto[m,])