mardi 8 septembre 2020

Conditional in Rstudio

I'm trying to chose diferent dataframes by using If conditionals. I know the code is quite wrong but the idea about what I'm looking for is so clear. I'm a beginner in using R so please, I'll really apreciate if you could help me.

Here is the code:

qwerty = external input

Data1 <- if ( qwerty = "IG"|| qwerty == "HY") {
      
                  filter(plot_data, plot_data$`IG/HY` == qwerty)
                  
                  }else if ( qwerty == "All Sectors") {
                  
                 plot_data
                  
                  }else {
                  
                 filter(plot_data, plot_data$SECTOR == qwerty)
                  
                  }
    

Aucun commentaire:

Enregistrer un commentaire