UndefVarError: transform not defined

I got this error and my code is

using MultivariateStats, RDatasets, Plots

# load iris dataset
iris = dataset("datasets", "iris")

# take half of the dataset
X = Matrix(iris[1:2:end,1:4])'
X_labels = Vector(iris[1:2:end,5])
M = fit(PCA, X; maxoutdim=2)
X_transform = transform(M,X)
PC1 = X_transform[1,:]
PC2 = X_transform[2,:]

Which package has transform function?

It seems to be in MultivariateStats. But deprecated in favor of predict.
So try predict(M,X).