Question: When I tried to run this script, nothing came out. Also, there are errors as indicated by * install.packages(ggplot2) install.packages(correlation) # Number 1 toyota.df
When I tried to run this script, nothing came out. Also, there are errors as indicated by *
install.packages("ggplot2")
install.packages("correlation")
# Number 1
toyota.df<-read.csv("C:\\Users\\andyt\\OneDrive\\Documents\\ToyotaCorolla.csv",header=TRUE, stringsAsFactors=FALSE)
toyota_corr <- subset(toyota.df, select= -c(Model, Fuel_Type, Color))
cor(toyota_corr, hjust =1)
toyota_corr_matrix <- data.frame(cor(toyota_corr))
toyota.plot <- ggplot(toyota.df)+geom_point(aes(toyota.df$Mfg_Year, toyota.df$Price))
toyota.plot2 <- ggplot(toyota.df)+geom_point(aes(toyota.df$Mfg_Year, toyota.df$Age_08_04))
toyota.plot3 <- ggplot(toyota.df)+geom_col(aes(toyota.df$Mfg_Year, toyota.df$Boardcomputer))
toyota.plot4 <- ggplot(toyota.df)+geom_point(aes(toyota.df$Id, toyota.df$Age_08_04))
ggplot2(toyota.plot, toyota.plot2, toyota.plot3, toyota.plot4, ncol = 2, nrow = 2)
# Dummies
set.seed(1)
install.packages("dummies")
toyota.df$Model <- as.character(toyota.df$Model)
toyota.df.dum <- dummy.data.frame(toyota.df, sep = ".", dummy.class = "factor")
toyota.df.dum <- toyota.df.dum[, -c(10,13)] # drop one of the dummy variables from Color and Fuel_Type.
head(t(t(names(toyota.df.dum))),22)
[,1] * Error message- unexpected token
# Number 2
set.seed(0)
train.rows <- sample(rownames(toyota.df.dum), dim(toyota.df)[1]*0.5)
valid.rows <- sample(setdiff(rownames(toyota.df.dum), train.rows),
dim(toyota.df)[1]*0.3)
test.rows <- setdiff(rownames(toyota.df.dum), union(train.rows, valid.rows))
train.data <- toyota.df[train.rows, ]
valid.data <- toyota.df[valid.rows, ]
test.data <- toyota.df[test.rows, ]
Error message- Error in `[.data.frame`(toyota.df, test.rows, ) :
object 'test.rows' not found
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
