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 vector "y", you could do:

set.seed(123)
y=c(NA,rnorm(5),NA)
y
y[!is.na(y)]


HTH,

Jorge



On Tue, Jul 1, 2008 at 1:49 PM, <[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
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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