Ниже указывается тип каждого столбца, а затем удаляются все нежелательные типы данных из кадра данных.
library(ISLR)
data <- Auto
# Get Data Types of all Columns in the Data Frame
column_types <- sapply(data, class)
# Create a vector to hold all the unwanted data types (Change to what you want)
unwanted_types <- c("factor", "character")
# Remove all the columns which are of the unwanted datatypes
data <- data[, which(!column_types %in% unwanted_types)]
# Get Summary of the DataFrame
summary(data)
mpg cylinders displacement horsepower weight acceleration year origin
Min. : 9.00 Min. :3.000 Min. : 68.0 Min. : 46.0 Min. :1613 Min. : 8.00 Min. :70.00 Min. :1.000
1st Qu.:17.00 1st Qu.:4.000 1st Qu.:105.0 1st Qu.: 75.0 1st Qu.:2225 1st Qu.:13.78 1st Qu.:73.00 1st Qu.:1.000
Median :22.75 Median :4.000 Median :151.0 Median : 93.5 Median :2804 Median :15.50 Median :76.00 Median :1.000
Mean :23.45 Mean :5.472 Mean :194.4 Mean :104.5 Mean :2978 Mean :15.54 Mean :75.98 Mean :1.577
3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:275.8 3rd Qu.:126.0 3rd Qu.:3615 3rd Qu.:17.02 3rd Qu.:79.00 3rd Qu.:2.000
Max. :46.60 Max. :8.000 Max. :455.0 Max. :230.0 Max. :5140 Max. :24.80 Max. :82.00 Max. :3.000
Я бы также предложил прочитать все типы данных, которые использует R.