library(ggplot2)
ggplot(data1,aes(x, weight=count)) + geom_histogram(binwidth=1) + xlim(0,400) + ggtitle(“title”)
library(ggplot2)
ggplot(data1,aes(x, weight=count)) + geom_histogram(binwidth=1) + xlim(0,400) + ggtitle(“title”)
File “points.txt” contains the X, Y coordinates of the points. We want to customize the distance calculation and feed into DBSCAN as a distance object.
x y 5 8 6 7 6 5 2 4 3 4 5 4 7 4 9 4 3 3 8 2 7 5
library(dbscan) data=read.table("d:/temp/points.txt", sep="\t", header=TRUE) distance=matrix(,nrow=nrow(data),ncol=nrow(data)) for(i in 1:nrow(data)){ for(j in i:nrow(data)){ dx=abs(data$x[i]-data$x[j])^0.5 dy=abs(data$y[i]-data$y[j])^0.5 distance[i,j]=(dx+dy)^2 distance[j,i]=(dx+dy)^2 } } result=dbscan(as.dist(distance), eps=4, minPts=3) result$cluster
MyData = read.csv(“D:/temp/iris.txt”,header=FALSE)
colnames(MyData) <- c(“col1″,”col2″,”col3″,”col4”)
MyData = read.table(“D:/temp/iris.txt”,sep=”\t”,header=FALSE)
colnames(MyData) <- c(“col1″,”col2″,”col3″,”col4”)
View(MyData)
MyData$col4<-NULL
ls()
rm(MyData)