r - Trouble getting function to return TRUE -


i have code check see if input function valid state. have csv file state column , states care about. made code loop check if input matches of states in list, , if so, return value true.

valid_state <- function(state) {     csv <- read.csv("outcome-of-care-measures.csv")     (i in range(length(unique(csv$state)))) {         if (state == unique(csv$state)[i]) {             return (true)         }     } } 

all returns null. know valid state entered looking @ csv file myself. think problem starts when try introduce problem don't know why. basically, input possible match 1 state on list, , if does, should return logical vector 1 true.

maybe this. common mistake forget preceeding "1:":

valid_state <- function(state) {     csv <- read.csv("outcome-of-care-measures.csv")     (i in 1:length(unique(csv$state))) {         if (state == unique(csv$state)[i]) {             return (true)         }     } } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -