Re: [R] (no subject)

From: Hans-Jörg Bibiko <>
Date: Thu, 19 Jun 2008 08:25:32 +0200

On 19.06.2008, at 07:24, Paul Adams wrote:

> Hello everyone,
> I am wanting to replace an element in a matrix with NA. I have used
> the following code
> dat<-read.table(file="C:\\Documents and Settings\
> \....txt",header=T,row.names=1)
>"C:\\Documents and Settings\\....txt")
> Z.matrix<-as.matrix(dat)
> Y<-dat[,46:63]
> X<-dat[1,51]
> dat[1,51]<-NA
> Whenever I use this code I get the original value when I type show
> (X).I run the script and type
> show(X) and the original value is still there.What am I doing wrong?

Well, actually nothing.
R works line by line. You set X<-dat[1,51] with let's say '4711'. Fine X is now '4711'. Then you change the cell dat[1,51]<-NA. Fine. If you type show(dat) you'll see that the cell 1,51 is now NA. But X is still the same, because X is NOT bound to the content of the cell dat[1,51].

--Hans mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 19 Jun 2008 - 06:27:29 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 Thu 19 Jun 2008 - 07:31:06 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive