Hi

Try

line[,line<=-0.7,drop=F]

drop=F,keep the dimensions.

On Mon, Apr 19, 2010 at 5:15 PM, Duncan Elkins <duncan@duncanelkins.com>wrote:

> Hi, list-
>    I've got a large list of multi-column data and I'd like to filter
> it according to a threshold, such as, "show me the values that are
> above 0.4 for each line."
>
> For instance, if the line of data were:
> > line
>     v1     v2    v3      v4     v5     v6    v7    v8      v9
> 1 -0.32 0.66 -0.35 -0.82 0.38 0.66 -0.02 -0.11 -0.64
>
> I can do this
> > line[,line >= 0.4]
>    v2   v6
> 1 0.66 0.66
>
> and
>
> > names(line[,line >= 0.4])
> [1] "v2" "v6"
>
> That's great.  But, if there's only one value which passes the test, as in:
>
> > line[,line <= -0.7]
> [1] -0.82
>
> The single value loses its name attribute (in this case, I want "v4").
>  I guess I could kludge this by adding a dummy column that always
> passes and trimming it out of the output, later, but it seems like
> there ought to be an easier way.  Am I misusing the bracket notation,
> or ignorant of some obvious way to subset just one column and retain
> its name?
>
> Thanks,
> Duncan
>
> ______________________________________________
> 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.
>



-- 
Tengfei Yin
MCDB PhD student
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name
English Blog: www.tengfei.name/en
Chinese Blog: www.tengfei.name/ch

	[[alternative HTML version deleted]]

