[R] If Statement Help

David Winsemius dwinsemius at comcast.net
Sun Oct 24 07:37:38 CEST 2010


On Oct 23, 2010, at 7:44 PM, Jason Kwok wrote:

> Thanks Jorge.  It works.
>
> Is there a way to keep the actual price in the price column instead of
> TRUE/FALSE but filtering on when price>100?

Huh? When I use subset I get what you ask for:

 > subset(x, Price > 100)
            Price
2010-10-12   101
2010-10-13   102
2010-10-14   103
2010-10-20   101
2010-10-21   101
2010-10-22   101

>
> Thanks,
>
> Jay
>
> On Sat, Oct 23, 2010 at 10:37 PM, Jorge Ivan Velez <jorgeivanvelez at gmail.com
>> wrote:
>
>> Hi Jay,
>>
>> If "x" is your data, you could use subset() to do what you want:
>>
>> subset(x, Price > 100)
>>
>> See ?subset for more information.
>>
>> HTH,
>> Jorge
>>
>>
>> On Sat, Oct 23, 2010 at 9:56 PM, Jason Kwok <> wrote:
>>
>>>                   Price
>>> 2010-10-11     99
>>> 2010-10-12    101
>>> 2010-10-13    102
>>> 2010-10-14    103
>>> 2010-10-15     99
>>> 2010-10-18     98
>>> 2010-10-19     97
>>> 2010-10-20    101
>>> 2010-10-21    101
>>> 2010-10-22    101
>>>
>>> I have this dataset and I only want to return instances when the  
>>> Price is
>>>>
>>> 100.
>>>
>>> If I use the code: Price > 100 then it will evaluate each entry as  
>>> "TRUE"
>>> or
>>> "FALSE".  What is the code to only return "TRUE" results?
>>>
>>> Thanks,
>>>
>>> Jay
>>>
>>>       [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list