# [R] Importing data in text file into R

From: amarjit singh sethi <ajss_gndu_at_yahoo.com>
Date: Fri, 23 May 2008 20:40:32 -0700 (PDT)
```Year	C1	C2	C3	C4	C5	C6
Y1	3.5	13.8	9.5	6.8	0.4	24.2
Y2	3.8	13.9	9.9	7.6	0.7	12.8
Y3	4.5	14.5	14.2	9.2	0.6	14.5
Y4	5.9	16.2	24.6	12.7	0.2	24.3
Y5	7.2	20.4	40.6	18.2	0.8	28.2
Y6	5.9	18.6	37.4	14.5	0.3	36.9
Y7	8.0	16.1	88.6	24.1	0.1	34.6
Y8	13.6	21.1	56.3	19.0	0.7	33.3

```

I wish to import the file into R and make certain computations, like intercorrelation matrix. I tried the following syntax:

# Inputting the data file (saved in text format) df="trial.txt"
idt
# To generate intercorrelatio matrix
r = cor(idt)
r=round(r, 4)
r

The seems to have been read, but further computations not made, with the following output:

> # Inputting the data file (saved in text format)
> df="trial.txt"
> 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
> r=round(r, 4)

> r

Kindly advise me as to how to get rid of the error message.

AJSS

R-help_at_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. Received on Sat 24 May 2008 - 03:45:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 24 May 2008 - 07:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.