Skip to content

R - If/else conditions not evaluating as expected #1359

Answered by kubu4
kubu4 asked this question in Q&A
Discussion options

You must be logged in to vote

Serendipitously, got this functional code during the SAFS monthly DEI community meeting from @lisannepetracca! Thanks so much!

# Vector of treatments
treatments <- c(1:4)

# Vector of comparisons
comparisons <- c("all", "f_v_m", "c_v_e")

for (comparison in comparisons) {

  # Create data frame with coefficients of variation for each Treatment group
  for (treatment in treatments)  {

    # Print statements to track loop progress
    print(paste("evaluating", comparison, sep = " "))
    print(paste("treatment is", treatment, sep = " "))

    if (comparison == "all") {
      print(paste("Working on comparison: ", comparison, sep = " "))
      print("") } else if (comparison == "f_v_m" & (t…

Replies: 1 comment

Comment options

kubu4
Jan 18, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by kubu4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
R code Any and all computer "coding" issues.
1 participant