Some corrections on the lecture

This commit is contained in:
2019-11-03 13:12:58 -05:00
parent cf80ff9f6a
commit 050956c01b
7 changed files with 246 additions and 104 deletions

16
R/norme.R Normal file
View File

@@ -0,0 +1,16 @@
#' @export
norm <- function(data,l=2) {
no <- function(x,y) sum(abs(data[x,]-data[y,])^l)^(1/l)
n = nrow(data)
d = matrix(0,nrow = n,ncol = n)
for (i in 1:n)
for (j in i:n) {
d[i,j] <- no(i,j)
d[j,i] <- d[i,j]
}
rownames(d) = rownames(data)
colnames(d) = rownames(data)
as.dist(d)
}