I am new to coding and I received this code from a colleague for research purposes. The original data set for this code had 4 spectral variables, 12 texture variables and a combination of spectra and texture resulting in 16 variables in total. I am running the code only with texture variables but now I only have 6 texture variables in the new data set. I have attached the first part of the original code below where I have 12 texture variables..Please could someone assist me in changing my code using the new data set with 6 texture variables...I have attached an example of how my data is set up which is exactly the way the original data set is set up just with only 6 texture variables at the end.
Here is the image:
#change your work directory
#############################
setwd("C:/Texture")
############################
#output all resuls to a text file
#change apend to TRUE to record all analysis
#sink("Results.txt",append =F)
source("plsrfsource.r")
data<-read.csv("texture0ratios.csv",header=T, na.strings=c(".", "NA", "", "?"))
# Check the dataset
colnames(data)
#select response variable
#this example uses EnumAge
################
y <-data$EnumAge
################
#make sure that your explantory variables are in the same order as the example dataset
#######################
#texture variables only
x<-data[,16:27]
#spectral variables only
#x<-data[,12:15]
#using all the variables
#x<-data[,12:27]
######################
colnames(x)
#there must be 12 texture variables
#4 spectral variables
length (x)
#join the x and y
dataset<-cbind(y,x)
# split into test and training datasets
set.seed(123)
inTrain <- createDataPartition(y, p = 0.7, list = F)
dataTrain<- dataset[inTrain[,1],]
dataTest <- dataset[-inTrain,]
trainY<-dataTrain$y
trainX<-as.matrix(dataTrain[-1])
testY<-dataTest$y
testX<-as.matrix(dataTest[-1])