建议看一下hadley的advanced R中的style guide, 如下是formatR的输出
lmwK = function(x, y) {
    I1 = array(1, dim = c(ncol(y), 1))
    ty = t(y)
    IY1 = I1 %*% ty
    IY2 = y %*% t(I1)
    IY3 = IY2 - IY1
    JIY3 = abs(IY3)
    IY5 = IY3 + JIY3
    IY6 = IY5/2
    IY7 = IY6/IY6
    IY7[is.na(IY7)] = 0
    IY = IY7
    w9 = IY %*% x
    w8 = w9/ncol(y)
    w7 = w8^2
    w = apply(w7, 2, mean)
    w1 = as.data.frame(w)
    w2 = t(w1)
    dim(w2)
    class(w2)
    w3 = as.data.frame(w2)
    rownames(w3)
    colnames(w3) = colnames(x)
    w4 = sort(w3, decreasing = T)
    wk = w4[1:30]
    l30 = colnames(wk)
    x1.select30 = as.matrix(x[, l30])
    x.30 = as.data.frame(x1.select30)
    Y = as.data.frame(y)
    MY = cbind(x.30, Y)
    fit = lm(formula = y ~ ., data = MY)
    r2 <- cor(y, fit$fitted.values)^2
    cat("Original R-square =", r2, "\n")
}
y = as.matrix(yX17.AAG)
lmwk(x, y)