2016-04-17 9 views
0

Fehler in Daten - x: nicht-numerisches Argument Binäroperators
Mein Code ist wie folgt:

R Fehler DBSCAN auf dem Datenrahmen

x <- as.factor(c(2, 2, 8, 5, 7, 6, 1, 4)) 

y <- as.factor(c(10, 5, 4, 8, 5, 4, 2, 9)) 

coordinates <- data.frame(x, y) 

colnames(coordinates) <- c("x_coordinate", "y_coordinate") 

print(coordinates) 

point_clusters <- dbscan(coordinates, 2, MinPts = 2, scale = FALSE, 
    method = c("hybrid", "raw", "dist"), seeds = TRUE, 
    showplot = 1, countmode = NULL) 

point_clusters 

Aber ich bin immer folgende Fehler während den obigen Code ausführen:

> point_clusters <- dbscan(coordinates, 2, MinPts = 2, scale = FALSE, method = c("hybrid", "r ..." ... [TRUNCATED] 
Error in data - x : non-numeric argument to binary operator 

ich weiß nicht, was das Problem mit obigem Code ist.

Antwort

0

Ich löste das Problem nach meinem Bedarf. Ich sah irgendwo, dass die Datennumerische Matrix sein müssen, obwohl ich mir nicht sicher bin. So, hier ist das, was ich getan habe:

x <- c(2, 2, 8, 5, 7, 6, 1, 4) 
y <- c(10, 5, 4, 8, 5, 4, 2, 9) 
coordinates <- matrix(c(x, y), nrow = 8, byrow = FALSE) 

Rest Code gleich wie oben ist. Jetzt funktioniert es gut für mich.