|
Hello,
I have many hundred variables in my longitudinal dataset and lots of missings. In order to plot data I need to remove missings. If I do > data <- na.omit(data) that will reduce my dataset to 2% of its original size ;) So I only need to listwise delete missings on 3 variables (the ones I am plotting). data$variable1 <-na.omit(data$variable1) does not work. Thank you [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. |
|
On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote: > Hello, > > I have many hundred variables in my longitudinal dataset and lots of > missings. In order to plot data I need to remove missings. > > If I do >> data <- na.omit(data) > that will reduce my dataset to 2% of its original size ;) > > So I only need to listwise delete missings on 3 variables (the ones > I am > plotting). > > data$variable1 <-na.omit(data$variable1) ?complete.cases # returns a logical vector data[ complete.cases( data[ , c("var1", "var2", "var3"]) , ] David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] 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. |
|
Be careful!! The plots could be potentially misleading. The problem is the
nature of the missingness. The approach you are taking is based on assuming MCAR missingness (look it up, if necessary). If that is not the case -- e.g. if there is censoring, MAR, or informative missingness -- the plots may be completely misleading. Missingness in longitudinal data is a very difficult issue. If this is something you don't know about already, I strongly suggest that you consult a statistician who does -- not all of us do (I know almost nothing, for example). -- Bert On Thu, Jul 5, 2012 at 10:34 AM, David Winsemius <[hidden email]>wrote: > > On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote: > > Hello, >> >> I have many hundred variables in my longitudinal dataset and lots of >> missings. In order to plot data I need to remove missings. >> >> If I do >> >>> data <- na.omit(data) >>> >> that will reduce my dataset to 2% of its original size ;) >> >> So I only need to listwise delete missings on 3 variables (the ones I am >> plotting). >> >> data$variable1 <-na.omit(data$variable1) >> > > ?complete.cases # returns a logical vector > > data[ complete.cases( data[ , c("var1", "var2", "var3"]) , ] > > > David Winsemius, MD > West Hartford, CT > > ______________________________**________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. |
|
In reply to this post by torvon
HI,
Try this: set.seed(1) dat1<-data.frame(var1=c(rep(NA,3),1:3),var2=c(1:4,NA,5),var3=c(1:5,NA),var4=rnorm(6,15),var5=runif(6,0.2),var6=rep(NA,6)) dat1[rowSums(is.na(dat1[,c("var1","var2","var3")]))==0,] var1 var2 var3 var4 var5 var6 4 1 4 4 16.59528 0.5981594 NA A.K. ----- Original Message ----- From: Eiko Fried <[hidden email]> To: [hidden email] Cc: Sent: Thursday, July 5, 2012 1:25 PM Subject: [R] Exclude missing values on only 1 variable Hello, I have many hundred variables in my longitudinal dataset and lots of missings. In order to plot data I need to remove missings. If I do > data <- na.omit(data) that will reduce my dataset to 2% of its original size ;) So I only need to listwise delete missings on 3 variables (the ones I am plotting). data$variable1 <-na.omit(data$variable1) does not work. Thank you [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. Hi,Try this: ______________________________________________ [hidden email] 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. |
|
HI,
Try this: set.seed(1) dat1<-data.frame(var1=c(rep(NA,3),1:3),var2=c(1:4,NA,5),var3=c(1:5,NA),var4=rnorm(6,15),var5=runif(6,0.2),var6=rep(NA,6)) dat1[rowSums(is.na(dat1[,c("var1","var2","var3")]))==0,] var1 var2 var3 var4 var5 var6 4 1 4 4 16.59528 0.5981594 NA A.K. ----- Original Message ----- From: Eiko Fried <[hidden email]> To: [hidden email] Cc: Sent: Thursday, July 5, 2012 1:25 PM Subject: [R] Exclude missing values on only 1 variable Hello, I have many hundred variables in my longitudinal dataset and lots of missings. In order to plot data I need to remove missings. If I do > data <- na.omit(data) that will reduce my dataset to 2% of its original size ;) So I only need to listwise delete missings on 3 variables (the ones I am plotting). data$variable1 <-na.omit(data$variable1) does not work. Thank you [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. Hi,Try this: ______________________________________________ [hidden email] 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. |
|
In reply to this post by David Winsemius
On Jul 5, 2012, at 1:34 PM, David Winsemius wrote: > > On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote: > >> Hello, >> >> I have many hundred variables in my longitudinal dataset and lots of >> missings. In order to plot data I need to remove missings. >> >> If I do >>> data <- na.omit(data) >> that will reduce my dataset to 2% of its original size ;) >> >> So I only need to listwise delete missings on 3 variables (the ones >> I am >> plotting). >> >> data$variable1 <-na.omit(data$variable1) > > ?complete.cases # returns a logical vector > > data[ complete.cases( data[ , c("var1", "var2", "var3"]) , ] > > data[ complete.cases( data[ , c("var1", "var2", "var3") ] ) , ] > -- David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] 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. |
| Powered by Nabble | Edit this page |
