cars <- read_csv("cars.csv")
# Number of Rows
num_rows <- nrow(cars)
# Number of columns
num_cols <- ncol(cars)
cat("Number of Rows:", num_rows, "\n")
## Number of Rows: 428
cat("Number of Columns:", num_cols)
## Number of Columns: 19
# Average horsepower
avg_hp <- mean(cars$horsepower, na.rm = TRUE)
print(paste("Average Horsepower:", round(avg_hp, 2)))
## [1] "Average Horsepower: 215.89"
# Maximum horsepower
max_hp <- max(cars$horsepower, na.rm = TRUE)
print(paste("Maximum Horsepower:", max_hp))
## [1] "Maximum Horsepower: 500"
cars$Price <- as.numeric(cars$Price)
# Select only the name and price for a clean display
most_expensive_details <- cars[which.max(cars$Price), c("name", "Price")]
most_expensive_details
## # A tibble: 1 × 2
## name Price
## <chr> <dbl>
## 1 Porsche 911 GT2 2dr 192465