Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204742

Apply function to each row in dataset when conditions are met

$
0
0

I have a boolean variable (parent_boolean). If parent_boolean = True then I want to apply a function to table_name, if parent_boolean = False then I want to apply a different function to table_name in the data set. What is the easiest way to do this in DPLYR?

table_name    parent_table  parent_boolean column_count
 <chr>                                             <chr>                              <lgl>             <dbl>
1 table_1       table_1      TRUE                     1
2 table_2       table_1     FALSE                     3                                      

dp_child <- function(table_name, parent_table) { function runs SQL statement against database) 

dp_parent <- function(table_name) {function runs SQL statement against database) 

I want to run the dp_parent function on each row that the table_name is the parent_table and I want to run the dp_child function on each row that the table_name is not the parent_table.


Viewing all articles
Browse latest Browse all 204742

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>