Rev
August 6, 2020, 11:59pm
1
Hi, I want to generate Test dataset with my trans_NY1A[-inTrain, ] code but it generated blank observations. The code is below.
> inTrain <- createDataPartition(transformed_NY1A$Vrate,
+ p = .80, list= FALSE, times = 50)
> NY1A_train <- transformed_NY1A[ inTrain, ]
> str(NY1A_train)
'data.frame': 20800 obs. of 9 variables:
$ Period : num -0.561 -0.353 -0.435 -0.497 -0.448 ...
$ Lax : num -0.1063 0.061 -0.0915 -0.1187 -0.1059 ...
$ Lot : num 0.5092 0.7231 0.018 0.0264 0.0229 ...
$ Sty : num 0.0396 -0.0867 0.2593 0.2561 0.2299 ...
$ Agri : num -0.33 -0.224 0.383 0.62 0.632 ...
$ NumberT : num -0.0622 -0.3671 0.3006 0.3907 0.1442 ...
$ QS : num -0.0147 -0.0513 -0.5289 -0.285 0.0462 ...
$ Vrate : num 0.353 0.392 0.36 0.196 -0.258 ...
$ Vest: num 0.418 0.02 -0.299 0.129 0.496 ...
> NY1A_test <- transformed_NY1A[-inTrain,]
> str(NY1A_test)
'data.frame': 0 obs. of 9 variables:
$ Period : num
$ Lax : num
$ Lot : num
$ Sty : num
$ Agri : num
$ NumberT : num
$ QS : num
$ Vrate : num
$ Vest: num
Rev
August 7, 2020, 12:07am
2
Hello, I want to generate Test dataset with my trans_NY1A[-inTrain, ] code but it generated blank observations. The code is below.
> inTrain <- createDataPartition(transformed_NY1A$Vrate,
+ p = .80, list= FALSE, times = 50)
> NY1A_train <- transformed_NY1A[ inTrain, ]
> str(NY1A_train)
'data.frame': 20800 obs. of 9 variables:
$ Period : num -0.561 -0.353 -0.435 -0.497 -0.448 ...
$ Lax : num -0.1063 0.061 -0.0915 -0.1187 -0.1059 ...
$ Lot : num 0.5092 0.7231 0.018 0.0264 0.0229 ...
$ Sty : num 0.0396 -0.0867 0.2593 0.2561 0.2299 ...
$ Agri : num -0.33 -0.224 0.383 0.62 0.632 ...
$ NumberT : num -0.0622 -0.3671 0.3006 0.3907 0.1442 ...
$ QS : num -0.0147 -0.0513 -0.5289 -0.285 0.0462 ...
$ Vrate : num 0.353 0.392 0.36 0.196 -0.258 ...
$ Vest: num 0.418 0.02 -0.299 0.129 0.496 ...
> NY1A_test <- transformed_NY1A[-inTrain,]
> str(NY1A_test)
'data.frame': 0 obs. of 9 variables:
$ Period : num
$ Lax : num
$ Lot : num
$ Sty : num
$ Agri : num
$ NumberT : num
$ QS : num
$ Vrate : num
$ Vest: num
Hi,
Welcome to the RStudio community!
The code you provided does not contain any data that we can run, so it's not possible for us to recreate the issue. If you like to get better help, I suggest you create a reprex next time. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
Judging by the code, I have one question/suggestion: what is this Vrate? The code is splitting based on the transformed_NY1A$Vrate
value, and depending on its class and value this might lead to unexpected results. Can you show me a sample of the data you have (see the reprex guide).
Grtz,
PJ
system
Closed
August 28, 2020, 11:52am
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.