On Fri, 23-May-2008 at 08:40PM -0700, amarjit singh sethi wrote:

|> Dear all,
|> I am quite new to R; facing certain problems:
|> Say, I have a text file( named as "try"):


|> > idt=read.table(df,header=T, sep="\t")
|> > idt
|>   Year   C1   C2   C3   C4  C5   C6
|> 1   Y1  3.5 13.8  9.5  6.8 0.4 24.2
|> 2   Y2  3.8 13.9  9.9  7.6 0.7 12.8
|> 3   Y3  4.5 14.5 14.2  9.2 0.6 14.5
|> 4   Y4  5.9 16.2 24.6 12.7 0.2 24.3
|> 5   Y5  7.2 20.4 40.6 18.2 0.8 28.2
|> 6   Y6  5.9 18.6 37.4 14.5 0.3 36.9
|> 7   Y7  8.0 16.1 88.6 24.1 0.1 34.6
|> 8   Y8 13.6 21.1 56.3 19.0 0.7 33.3
|> > # To generate intercorrelatio matrix
|> > r = cor(idt)
|> Error in cor(idt) : missing observations in cov/cor
|> In addition: Warning message:
|> In cor(idt) : NAs introduced by coercion


The help file for cor says this about x and y:

       x: a numeric vector, matrix or data frame.

       y: 'NULL' (default) or a vector, matrix or data frame with
          compatible dimensions to 'x'.  The default is equivalent to
          'y = x' (but more efficient).

Your x isn't a numeric vector, matrix or data frame.

x[,-1] is, and that might give what you want, but read the rest of the
help file to determine if that's what you want it to do.  Having
rownames on your dataframe might help seeing what is happening.  The
easiest way I can see to get row names is in your read.table line.
Add row.names = 1.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                         Great minds discuss ideas    
 _( Y )_                        Middle minds discuss events 
(:_~*~_:)                        Small minds discuss people  
 (_)-(_)                                   ..... Anon
          
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
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