R if条件> 1长度错误的语句

时间:2018-08-28 10:30:29

标签: r if-statement

我正在尝试运行if语句,如果23个值中的任何一个低于某个值,我都希望在其中运行某些内容。

import { connect } from "react-redux";
import { trueBrowse,trueCart, trueHome, trueMessages,     trueServices,falseBrowse,
falseCart, falseHome,falseMessages, falseServices} from "../actions/index";

const mapStateToProps = state => {
return { home: state.home, browse: state.browse,cart: state.cart, messages: state.messages };
};
const mapDispatchToProps = dispatch => {
    return {
    trueBrowse: browse => dispatch(trueBrowse(browse)),
    trueServices: services => dispatch(trueServices(services)),
    trueHome: home => dispatch(trueHome(home)),
    trueMessages: messages => dispatch(trueMessages(messages)),
    trueCart: cart => dispatch(trueCart(cart)),
    falseServices: services => dispatch(falseServices(services)),
    falseMessages: messages => dispatch(falseMessages(messages)),
    falseHome: home => dispatch(falseHome(home)),
    falseCart: cart => dispatch(falseCart(cart)),
    falseBrowse: browse => dispatch(falseBrowse(browse))
};

};

//The condition
navig(setter){
    let set = ["Home","Messages" ,"Browse","Cart",];
    let page = set.indexOf(setter);
    console.log(page+1);
    for( let value in set){
        if(set[value] != setter){
         //   this.setState({[set[value]]: false});
            this.props.false+[set[value]]+(set[value].toLowerCase())
        }
    }
    this.setState({[setter]: true});
    this.viewPager.setPage(page);
}

我得到一个错误,该条件的长度大于1,并且仅使用第一个元素。哪个是正确的...没有人知道如何测试if语句是否包含23个值,而不必一个个地键入它们?

谢谢!

2 个答案:

答案 0 :(得分:1)

请参见函数allany isTRUE,以及在R的较新版本isFALSE中,其中后两个在某种程度上处理了{ {1}}和NULL

例如:

NA

答案 1 :(得分:0)

您可以尝试以下操作:

date