[R] Select only cases with negative values

Henrique Dallazuanna wwwhsd at gmail.com
Sat Oct 18 23:22:06 CEST 2008


Works for me.

dat.lm <-lm(c~d, data = dat, subset=d < 0)

Please see if you have dat with d and c columns names.

On Sat, Oct 18, 2008 at 7:18 PM, Michael Just <mgjust at gmail.com> wrote:
> Henrique,
> Thanks for the rapid response. I tried the following to no avail:
>
>> dat.lm <-lm(c~d, dat=dat, subset= d <0)
> Error in eval(expr, envir, enclos) : invalid 'envir' argument
>> dat.lm <-lm(c~d, dat=dat, subset= (d <0))
> Error in eval(expr, envir, enclos) : invalid 'envir' argument
>> dat.lm <-lm(c~d, dat=dat, subset= c(d <0))
> Error in eval(expr, envir, enclos) : invalid 'envir' argument
>
> Any other suggestions?
> Thanks,
> Michael Just
>
> On Sat, Oct 18, 2008 at 5:15 PM, Henrique Dallazuanna <wwwhsd at gmail.com> wrote:
>> Try this:
>>
>> dat.lm <-lm(c~d, subset=d < 0)
>>
>>
>> On Sat, Oct 18, 2008 at 7:03 PM, Michael Just <mgjust at gmail.com> wrote:
>>> Hello,
>>> I was wondering if there was a way to only select cases my from data
>>> frame that contained a negative value?
>>>
>>>> c<-c(1,2,3,4,5,6,7,8,9,10)
>>>> d<- c(-1,2,-3,-4,5,6,-7,8,-9,10)
>>>> f <- cbind(c,d)
>>>> dat <-data.frame(f)
>>>> dat.lm <-lm(c~d)
>>>
>>> If I wanted to only use the rows that had a negative value in column d
>>> for my regression, how could I make that selection?
>>>
>>> Thanks,
>>> Michael Just
>>>
>>> ______________________________________________
>>> R-help at 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.
>>>
>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list