smart sampling techniques in r I have a large data set of about 1.8 million rows with 80 variables.  I would like to find a good technique (code or package) in R that can reduce the amount of training data without damaging the representation of the original data too much.  I'm going to use this data set for two purposes: 


*

*Predicting a binary outcome ( rows that have "true" as a value are only 1.5% of the data).

*Predicting a continuous variable.


Any Idea what technique in R can help with this issue?
 A: Simple random selection of N rows could be done, given x is your data matrix, by
x.subset = x[sample(nrow(x), N), ]

If you consider reducing the number of columns of predictors, you can do principal component analysis or similar methods. However, all depends on the context. 
A: This sounds like you want to take a stratified sample of your data so your sample also contains a 1.5% true outcome on your binary variable.  There are already a few solutions to this on stackoverflow.
As far as the sufficient number of rows, it is impossible to tell without the level of precision (error) you require.  For example, if you want the rate of your binary outcome to be precise within 0.1%, you will need a minimum of 1000 rows before you even attain that level of precision.  For 0.001% you will need 10,000, and so on.  
For the continuous variable you can take a relatively smaller "sample" sample then use the following equation to determine your approximate required sample size.
Required Sample Size = ("Sample" sample size) * (variance of "sample" sample error) * (Z ^ 2)/(Desired variance of error)
Where Z is the number of standard deviations for your desired confidence level (E.g. Z=1.96 for a 95% interval).
A: The function createDataPartition of the caret package is designed for random sampling while balancing the distribution of the critical variable.
Here's an example:
set.seed(12)
binary_var <- rbinom(1e6, 1, 0.015)
mean(binary_var)
# [1] 0.015047
numeric_var <- rnorm(1e6)
# [1] -0.001466279

library(caret)
idx_b <- createDataPartition(binary_var, p = 0.5, list = FALSE)
mean(binary_var[idx_b])
# [1] 0.014926
idx_n <- createDataPartition(numeric_var, p = 0.5, list = FALSE)
mean(numeric_var[idx_n])
# [1] -0.001347959

For more details, have a look at the help page of createDataPartition.
A: From the constructed models consider the model KNN with k = 1, the tree and the randomForest. Build a model by assembling the previous three
Construct an assembled model, that is, for each record, each model makes a prediction for the category. The assembled model must assign to each record the most repeated category of all three. Calculate the correctness of the resulting model.
