Thank you for the help and explanations. I used the "complete.cases" function
and it is working great.
adata[complete.cases(adata[,1:2]),]
-
In theory, practice and theory are the same. In practice, they are not - Albert
Einstein
--
View this message in context:
http://r.789695.n4.nabble.
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Schatzi
> Sent: Wednesday, October 26, 2011 8:25 AM
> To: r-help@r-project.org
> Subject: [R] sometimes removing NAs from code
>
> Sometimes I have NA values within specific columns of a da
Hi,
On Wed, Oct 26, 2011 at 11:25 AM, Schatzi wrote:
> Sometimes I have NA values within specific columns of a dataframe (in this
> example, the first two columns can have NAs). If there are NA values, I
> would like them to be removed.
>
> I have been using the code:
>
> y<-c(NA,5,4,2,5,6,NA)
>
On Oct 26, 2011, at 10:25 AM, Schatzi wrote:
> Sometimes I have NA values within specific columns of a dataframe (in this
> example, the first two columns can have NAs). If there are NA values, I
> would like them to be removed.
>
> I have been using the code:
>
> y<-c(NA,5,4,2,5,6,NA)
> z<-c(NA
?complete.cases
> y<-c(NA,5,4,2,5,6,NA)
> z<-c(NA,3,4,NA,1,3,7)
> x<-1:7
> adata<-data.frame(y,z,x)
> adata
y z x
1 NA NA 1
2 5 3 2
3 4 4 3
4 2 NA 4
5 5 1 5
6 6 3 6
7 NA 7 7
> adata[complete.cases(adata),]
y z x
2 5 3 2
3 4 4 3
5 5 1 5
6 6 3 6
On Wed, Oct 26, 2011 at 11:25 AM, Sc
Hi,
Why don't you give subset a try:
adata <- subset(adata, is.na(z)==FALSE&is.na(y)==FALSE)
I'm not sure if you want to use AND or OR for this statement.
Best wishes,
Natalie
On 26/10/2011 16:25, Schatzi wrote:
Sometimes I have NA values within specific columns of a dataframe (in this
exampl
Sometimes I have NA values within specific columns of a dataframe (in this
example, the first two columns can have NAs). If there are NA values, I
would like them to be removed.
I have been using the code:
y<-c(NA,5,4,2,5,6,NA)
z<-c(NA,3,4,NA,1,3,7)
x<-1:7
adata<-data.frame(y,z,x)
adata<-adata[-w
7 matches
Mail list logo