Hey
I have a problem with the Plot function because I get an error message, because it seems a variable is not correctly defined while for me everything is okay. so I don't understand why R says that it is unknown or not specified.
here you are with the reprex
# To clean up the memory of your current R session run the following line
rm(list=ls(all=TRUE))
#install tidyverse and reprex
install.packages("tidyverse")
#> Installing package into 'C:/Users/walid/Documents/R/win-library/3.4'
#> (as 'lib' is unspecified)
#> package 'tidyverse' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\walid\AppData\Local\Temp\RtmpsN9QMt\downloaded_packages
library(reprex)
# Set your directory to the folder where you have downloaded the SKU dataset
# install readr
library(readr)
# Let's load our dataset
data <- read_delim('CO2_passenger_cars_v14.csv', "\t", escape_double = FALSE, trim_ws = TRUE)# The function read.table enables us to read flat files such as .csv files
#> Error: 'CO2_passenger_cars_v14.csv' does not exist in current working directory ('C:/Users/walid/AppData/Local/Temp/RtmpA70859').
View(data)
#> Error in as.data.frame.default(x): impossible de convertir automatiquement la classe ""function"" en un tableau de données (data.frame)
# Now let's have a look at our variables and see some summary statistics
class(data)
#> [1] "function"
dim(data)
#> NULL
str(data) # The str() function shows the structure of your dataset and details the type of variables that it contains
#> function (..., list = character(), package = NULL, lib.loc = NULL,
#> verbose = getOption("verbose"), envir = .GlobalEnv)
summary(data) # The summary() function provides for each variable in your dataset the minimum, mean, maximum and quartiles
#> Error in object[[i]]: objet de type 'closure' non indiçable
names(data)
#> NULL
#Choice of the explanatory variables for the regression
data <- data[,c("id", "MS", "Mk", "Cn", "r", "e (g/km)", "m (kg)", "Ft", "ec (cm3)", "ep (KW)")]
#> Error in data[, c("id", "MS", "Mk", "Cn", "r", "e (g/km)", "m (kg)", "Ft", : objet de type 'closure' non indiçable
View(data)
#> Error in as.data.frame.default(x): impossible de convertir automatiquement la classe ""function"" en un tableau de données (data.frame)
#Column names
names(data) <- c("Id", "MemberState", "Manufacturor", "BrandName", "TotalNewRegistration", "CO2Emission(g/km)", "Weight(kg)", "FuelType", "EngineCapacity(cm3)", "EnginePower(KW)")
#> Error in names(data) <- c("Id", "MemberState", "Manufacturor", "BrandName", : names() appliqué à un object autre qu'un vecteur
#Remove NA rows
data_NA_Free <- na.omit(data)
summary(data_NA_Free)
#> Error in object[[i]]: objet de type 'closure' non indiçable
# Let's plot our data to see if we can identify groups visually
plot(data_NA_Free$MemberState, data_NA_Free$CO2Emission(g/km), main = "Emission per country", xlab = "Country Name", ylab = "CO2 Emission")
#> Error in data_NA_Free$MemberState: objet de type 'closure' non indiçable
Created on 2018-04-09 by the reprex package (v0.2.0).
you can find a sample of the data. at
https://www.dropbox.com/s/err4xn5usrb6ngl/data_sample.csv?dl=0
thanks for your help
walid