0
$\begingroup$

I have 2 tables, the first called GenotypesMaleUp

GenotypesMaleUp = {2.04545, 1.80196, 1.70542, 1.78403, 1.79929, 1.91629, 1.82785, \
1.52171, 1.9913, 1.43151, 1.96283, 1.44868, 2.11816, 2.03117, \
2.16076, 1.55718, 1.74599, 2.41115, 1.96451, 2.20853}

and the second called SurvivorsMaleUp

SurvivorsMaleUp = {0.989309, 0, 0.636673, 0, 0.810913, 0.964202, 0.857113, 0, 0.999606, \
0, 0, 0.350838, 0, 0, 0, 0, 0, 0.414982, 0.99347, 0.79752}

They are both the same length. I want to join the first term of GenotypesMaleUp with the first term of SurvivorsMaleUp, and so on for each other term so it would look like

{2.04545,0.989309}, {1.80196,0},(1.70542,0.636673},...

I tried Table[{GenotypesMaleUp, SurvivorsMaleUp}, 1] but got

{{{2.04545, 1.80196, 1.70542, 1.78403, 1.79929, 1.91629, 1.82785, 
   1.52171, 1.9913, 1.43151, 1.96283, 1.44868, 2.11816, 2.03117, 
   2.16076, 1.55718, 1.74599, 2.41115, 1.96451, 2.20853}, {0.989309, 
   0, 0.636673, 0, 0.810913, 0.964202, 0.857113, 0, 0.999606, 0, 0, 
   0.350838, 0, 0, 0, 0, 0, 0.414982, 0.99347, 0.79752}}}

as the output, so it just joined the lists together at the end of the first and beginning of the second list.

$\endgroup$

2 Answers 2

2
$\begingroup$

You can use Join after transforming each element of GenotypesMaleUp to a list:

Join[List /@ GenotypesMaleUp, SurvivorsMale, 2]

{{2.04545, 0}, {1.80196, 0}, {1.70542, 0}, {1.78403, 0.784521}, {1.79929, 0}, {1.91629, 0.964202}, {1.82785, 0}, {1.52171, 0.304152}, {1.9913, 0}, {1.43151, 0}, {1.96283, 0}, {1.44868, 0}, {2.11816, 0.929934}, {2.03117, 0}, {2.16076, 0}, {1.55718, 0.36051}, {1.74599, 0}, {2.41115, 0}, {1.96451, 0}, {2.20853, 0.79752}}

Alternatively, Transpose after Flattenning SurvivorsMale:

Transpose[{GenotypesMaleUp, Flatten@SurvivorsMale}]

same result

$\endgroup$
6
  • $\begingroup$ THANK YOU SO MUCH. $\endgroup$
    – missalyssa
    Commented Jun 6, 2019 at 4:34
  • $\begingroup$ is there a way (with a different table with 2 variables {x,y}, that i can isolate the first variable of each term to just have a list of {x1, x2,...} $\endgroup$
    – missalyssa
    Commented Jun 6, 2019 at 4:37
  • $\begingroup$ So if I have DelZeroMale={{2.04545, 0.989309}, {1.70542, 0.636673}, {1.78403, 0.784521}, {1.9913, 0.999606}, {1.96283, 0.992836}, {1.44868, 0.205681}, {1.74599, 0.714837}, {2.20853, 0.79752}} , how can I get {2.04545, 1.70542, 1.78403, ...} @kglr $\endgroup$
    – missalyssa
    Commented Jun 6, 2019 at 4:45
  • $\begingroup$ @missalyssa, try DelZeroMale[[All,1]] (see Part ([[...]]) in the docs) $\endgroup$
    – kglr
    Commented Jun 6, 2019 at 4:54
  • $\begingroup$ thank you so much!!!!!!! is there a way i can monetarily compensate you? (I feel like that's not allowed on the website but I am seriously so grateful) @kglr $\endgroup$
    – missalyssa
    Commented Jun 6, 2019 at 4:56
2
$\begingroup$

Try this,

Thread[{GenotypesMaleUp, SurvivorsMale}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.