Assignment10 - Returning test and training data

Assignment10 - Returning test and training data

by Iciar Iturmendi Sabater -
Number of replies: 3

Hello,

For function 1A in ClassificationUtilities.R: I can't find a way to return two different objects in one function (trainSet and testSet) so I have made a single list with both trainSet and testSet and returned the list as a way around this problem. However, this affects my ability to use the trainSet and testSet as independent arguments for the following functions. Is it ok to use the list with both trainSet and testSet as an argument for the following functions and specify within those function which object of the list (trainSet or testSet) the models should be built on?

Thank you!

In reply to Iciar Iturmendi Sabater

Re: Assignment10 - Returning test and training data

by Boyan Konstantinov Tsankov -
The way I did it is I called function 1a in the driver script and assigned the returned list of train and test data to a variable. Then I assigned the train and test subsets to new variables in the driver script using the $ operator. This now allowed me to pass the train and test data independently into my subsequent functions
In reply to Iciar Iturmendi Sabater

Re: Assignment10 - Returning test and training data

by Erik Spence -
You can only return a single value (object, whatever), in R. As such, the only way to return multiple things is to bundle them into a container type, such as a list. In this case you may hard-code the names of your training and testing variables into your driver script, since you will pass the training or testing data into your functions.