Hi,
Try:
dat1<- t(dat[,-1]) 
 colnames(dat1) <- dat[,1]

covmat <- cov(dat1)

A.K.

I'm running into this error and I'm not sure how fix it 
Error: is.numeric(x) || is.logical(x) is not TRUE 

This is my data frame 
geneExpression_Lab10.txt
This is the homework instructions in case you want to see 
Lab10.pdf

This is my code 

dat <-read.delim("~/Dropbox/Homework/R Studio/geneExpression_Lab10.txt", 
header=F) 
dat <- as.matrix(dat) 
dat <- t(as.matrix(dat)) 
covmat <-cov(dat) #Error: is.numeric(x) || is.logical(x) is not TRUE 
eigvec <- eigen(covmat)$vectors 
eigval <- eigen(covmat)$values 
eigvec 
adjusted.dat <- sapply(1:ncol(dat), function(i) dat[,i]- mean(dat[,i])) 
new.dat <- adjusted.dat %*% eigvec 
plot(new.dat) 
cov(new.dat)

______________________________________________
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