Hi - i am not super familiar with R, but need to modify my predecessor's R code so that if a variable is >0 and < 0.5, it will be replaced with <1. I have looked at a bunch of forum threads on the subject, but cannot seem to get anything to work Any help at what i might be doing wrong much appreciated. I am definitely an R newbie!
current code that works: v_lbs_list <- "" for (j in 2:(p_num_years+1)) { if (is.na(v_trends_lbs[i, j])) { v_lbs <- ' 0 ' } else if (v_trends_lbs[i, j] < 0.5) { v_lbs <- ' $<$1 ' } else { v_lbs <- format(round(v_trends_lbs[i, j]), big.mark=",", scientific=FALSE) } v_lbs_list <- paste(v_lbs_list, ' & ', v_lbs) } my attempt to add a >0 that gets an error pointing at the & sign: v_lbs_list <- "" for (j in 2:(p_num_years+1)) { if (is.na(v_trends_lbs[i, j])) { v_lbs <- ' 0 ' } else if (v_trends_lbs[i, j] < 0.5) & (v_trends_lbs[i, j] > 0) { v_lbs <- ' $<$1 ' } else { v_lbs <- format(round(v_trends_lbs[i, j]), big.mark=",", scientific=FALSE) } v_lbs_list <- paste(v_lbs_list, ' & ', v_lbs) } Thanks for any help! CONFIDENTIALITY NOTICE: This e-mail message, including a...{{dropped:10}} ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.