Em Ter, 2008-07-01 às 13:49 -0400, [EMAIL PROTECTED] escreveu:
> Hi,
>
> I am extracting data from a table where the rows have different column
> lengths,
> and empty columns have NA in them. Whenever I extract a row with some empty
> columns, the resulting vector carries all the NAs. Is there a
Dear Nina,
If you have a matrix X like this
# Data set
set.seed(123)
X=matrix(rnorm(10*5),ncol=5)
X[1,1]<-NA
X[2,1]<-NA
X[1,5]<-NA
X[5,2]<-NA
X
and you'd like to remove the NA values for a particular row (for example row
1), you can try something like:
X[1,!is.na(X[1,])]
Now, if you have a ve
It depends what you mean by 'ignore'. Some functions have an na.rm
argument which throws out NAs before computing the statistic.
if the vector 'x' has NAs, then
x <- x[!is.na(x)]
may be what you're looking for. This removes NAs from x and reassigns
the value to x.
[EMAIL PROTECTED] wrote:
Hi,
I am extracting data from a table where the rows have different column lengths,
and empty columns have NA in them. Whenever I extract a row with some empty
columns, the resulting vector carries all the NAs. Is there a way to ignore the
empty columns?
Thanks,
-Nina
___
4 matches
Mail list logo