Posted by: mero_naam_ho July 20, 2015
R-programming. Need help -Code Troubleshooting.
Login in to Rate this Post:     0       ?        
1. I haven't looked much at the code when i found that your code was not reading the file. It was returning a function instead of data with bunch of errors.

2. Not sure what are you trying to do at this line

subset_data <- subset(data, data$State=="state")

I guess you are trying to read the variable (state) but as you have enclosed it with double quotation sign, instead of reading the variable it will always be "state" and thus will return no matching data.

3. I am not sure what "output" == "state" does? or don't know what are you trying to do here. cause that statement always returns false because here again you are trying to compare a string with another string. Even if you meant to use "output" as a variable I don't see any output variable anywhere in the code.

4. at the end the statement return(dat$Hospital.Name) is invalid because the variable dat has local scope (i.e . it is valid within the if statement only) and since it doesn't have a global scope that statement will result an error.

After that I stopped looking at your code and started getting help from google.

Glad that it helped.
Last edited: 20-Jul-15 05:31 PM
Last edited: 20-Jul-15 05:32 PM
Read Full Discussion Thread for this article