Is there something similar in R that allows to fit a StandardScaler (resulting into mean=0 and standard deviation=1 features) to the training data and use that scaler model to transform the test data? scale does not offer a way to transform test-data based on the mean and standard deviation from the training data.
Snippet for Python:
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)
Since I'm pretty sure that this is the right way to do so (avoiding the leak of information from the test to the training set) I guess there is a simple solution I'm just unable to find.