Hello R list subscribers,

I am trying to use the "by" command to create line-specific variance covariance 
matrices (where "x" is the original data matrix):

by(x, x$line, function(d) {
d.clean <- d[,-1]})
write.table(d.clean$line[1,1], sep = ",", file = "covariances.csv", col.names = 
FALSE, row.names = FALSE, append = TRUE)
write.table("", sep = ",", file = "covariances.csv", col.names = FALSE, 
row.names = FALSE, append = TRUE)
x.cov <- cov(d.clean, y= NULL, use= "complete.obs", method= c("pearson"))
})

When I run this code, I get an error:

> by(x, x$line, function(d) {
+ d.clean <- d[,-1]})
Error in names(IND) <- deparse(substitute(INDICES))[1] : 
  'names' attribute [1] must be the same length as the vector [0]

Any suggestions on how to improve my code? Thanks in advance.

Sincerely, Josh


      
        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to