How well do you understand functions and the programming language of the Arduino. That is the essence of the solution to your problem of merging.
you must make a sort of choice/menu system on top level and from that calling one function that does what you want.
you have now sketch1 with a loop and sketch2 with a loop and your new program should become (in pseudo code)
int choice = MenuChoice(); // KeyPress;
case 1: loop1(); break; // use better names that reflect the function e.g. sinus, triangel square etc
case 2: loop2(); break;
case 3: loop3(); break;
case 4: loop4(); break;
default: // do nothing
void loop1() ...