Hi Sam,
How about this?
test[apply(test, 1, function(x) !any(x == '#DIV/0!')), ]
HTH,
Jorge
On Wed, Mar 9, 2011 at 3:29 PM, Sam Albers <> wrote:
> Hello Venerable List,
>
> I am trying to loop (I think) an operation through a list of columns in a
> dataframe to remove set of #DIV/0! values. I am trying to do this like so:
>
> #Data.frame
> test <-
read.csv("http://dl.dropbox.com/u/1574243/sample_data.csv",
> header=TRUE, sep=",")
>
>
> #This removes all the rows with #DIV/0! values in the mean column.
> only.mean <- test[!test$mean=="#DIV/0!",]
>
> #This removes the majority of #DIV/0! values as there is a large block of
> these values that extends over every column.
> #However, it doesn't remove then all. Can any recommend a way where I
can
> cycle through all the columns and remove these values other than manually
> like so:
> mean.median <- only.mean[!only.mean$median=="#DIV/0!",] # and
so on through
> each column?
>
> Can anyone recommend a better way of doing this?
>
> Thanks in advance!
>
> Sam
>
> [[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.
>
[[alternative HTML version deleted]]