The solution is much simpler (thanks Phil!)


new_data = data[!data$"legal status" %in% c("Private","Private
(Op","Unknown"),]


...works nicely.









frenchcr wrote:
> 
> hello folks,
> 
> Im trying to clean out a large file with data i dont need.
> The column im manipulating in the file is called "legal_status"
> There are three kinds of rows i want to remove. Those that have "Private",
> "Private (Op", or "Unknown" in the legal_status column.
> 
> 
> I wrote this code but i get errors and it says im missing a TRUE/ False
> thingy...im lost...heres the code...
> 
> 
> 
> cleanse <- function(a){
> data1<-a
> 
>   for (i in 1:dim(data1)[1])
>   {
>     if (data1[i,"legal_status"] == "Private")
>     {
>     data1[i,"legal_status"]<-data1[-i,"legal_status"]
>     }
>     if (data1[i,"legal_status"] == "Private (Op"){
>     data1[i,"legal_status"]<-data1[-i,"legal_status"]
>     }
>     if (data1[i,"legal_status"] == "Unknown"){
>     data1[i,"legal_status"]<-data1[-i,"legal_status"]
>     }
>  }
> 
>  return(data1)
> }
> new_data<-cleanse(data)
> 
> 
> 
> 
> Any ideas?
> 

-- 
View this message in context: 
http://old.nabble.com/cleanse-columns-and-unwanted-rows-tp26342169p26350874.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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