R operator for inline if, like C# ? - Matlab, R project and Python | futures.io
futures.io futures trading

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python

R operator for inline if, like C# ?
Started:December 3rd, 2013 (03:42 AM) by Big Mike Views / Replies:3,621 / 1
Last Reply:December 3rd, 2013 (03:42 AM) Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

R operator for inline if, like C# ?

Old December 3rd, 2013, 03:42 AM   #1 (permalink)
Site Administrator
Manta, Ecuador
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
Big Mike's Avatar
Posts: 45,428 since Jun 2009
Thanks: 28,836 given, 79,544 received

R operator for inline if, like C# ?

Just sticking this here for safekeeping.

In R, you can do the equivalent of a C# inline if, like:

var = (a==b ? true : false)

With this:

var <- ifelse(a==b, true, false)

> ifelse(1==1, "yes","no")
[1] "yes"
> ifelse(1==11, "yes","no")
[1] "no"

Hope it helps someone else.


Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:

Old December 3rd, 2013, 03:42 AM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.



futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python > R operator for inline if, like C# ?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

Corey Rosenbloom: Tips, Tactics, and Real Trades: Trading Intraday Trend Reversals

Elite only

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
OR operator rather than AND in condition builder toddma NinjaTrader 4 May 26th, 2016 06:42 PM
C# inline 'if' with multiple statements Big Mike NinjaTrader Programming 5 August 9th, 2012 03:05 PM
AND NOT operator on Ninja Trader script?!? vgbouchet NinjaTrader Programming 3 November 26th, 2011 11:53 PM
Which OR operator to use in C# please? Al2010 NinjaTrader Programming 16 December 11th, 2010 10:44 AM

All times are GMT -4. The time now is 05:24 AM.

Copyright © 2016 by futures.io. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-21 in 0.06 seconds with 19 queries on phoenix via your IP