I have been putting r code concerning knn into the power bi r script. In r studio it was kind of working but in power b it says errors error is cause by last line:
# 'dataset' holds the input data for this script
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x))) }
mpg_n <- as.data.frame(lapply(c(3,5,8,9), normalize))
mpg_train<-mpg_n[101:234,]
mpg_test<-mpg_n[1:100,]
mpg_train_labels<-mpg_n[101:234,2]
mpg_test_labels<-mpg_n[1:100,2]
install.packages("class")
install.packages("kknn")
library("class")
library("kknn")
mpg_test_pred <- knn(train = mpg_train, test = mpg_test,cl= mpg_train_labels, k = 12)
the error announcement is following:
Błąd w poleceniu 'knn(train = mpg_train, test = mpg_test, cl = mpg_train_labels, ':
żadne brakujące wartości nie są dozwolone
Wykonywanie wstrzymane
Details:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Instalowanie pakietu w 'C:/Users/bancyr/AppData/Local/Radio/Library'
(ponieważ 'lib' nie jest określony)
próbowanie adresu URL 'https://mran.microsoft.com/snapshot/2017-05-01/bin/windows/contrib/3.4/class_7.3-14.zip'
Content type 'application/zip' length 106322 bytes (103 KB)
==================================================
downloaded 103 KB
Instalowanie pakietu w 'C:/Users/bancyr/AppData/Local/Radio/Library'
(ponieważ 'lib' nie jest określony)
próbowanie adresu URL 'https://mran.microsoft.com/snapshot/2017-05-01/bin/windows/contrib/3.4/kknn_1.3.1.zip'
Content type 'application/zip' length 334769 bytes (326 KB)
==================================================
downloaded 326 KB
Błąd w poleceniu 'knn(train = mpg_train, test = mpg_test, cl = mpg_train_labels, ':
żadne brakujące wartości nie są dozwolone
Wykonywanie wstrzymane
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Radio.RScriptRuntimeException