Hi, can anyone help me in this problem :(. I am a total beginner in R software. It took me 2 days just to look into this problem. Due to this problem. I cant do looping. i want to find the distance between x and DSi
> DSi i Si 1 1 (5, 20) 2 2 (20, 2) 3 3 (25, 32) 4 4 (8, 39) 5 5 (10, 17) 6 6 (35, 20) 7 7 (38, 10) > str (DSi) 'data.frame': 7 obs. of 2 variables: $ i : int 1 2 3 4 5 6 7 $ Si: Factor w/ 7 levels "(10, 17)","(20, 2)",..: 6 2 3 7 1 4 5 > > x <- c(15, 45) > y <- DSi [,2] > dist <- function (point1, point2) + { + diff <- point1-point2 + distance <- sqrt(sum(diff^2)) + distance + } > dist (x, y) [1] NA Warning message: In Ops.factor(point1, point2) : - not meaningful for factors > Regards, Nadiah -- View this message in context: http://r.789695.n4.nabble.com/Ops-factor-point1-point2-not-meaningful-for-factors-tp4644971.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.