Ich habe folgende Datenrahmen mit Informationen für 163 Affen:mehrere Matrixwerte auf einzelne Spalte von Datenrahmen zuweisen
> head(vervetdf)
ucla_id country species Gender pi
1 A8516_M_2 Barbados Chlorocebus sabaeus M NA
2 AG23_F_10 Tanzania Chlorocebus pygerythrus pygerythrus F NA
3 AG5417_F_10 Tanzania Chlorocebus pygerythrus pygerythrus F NA
4 AGM126_F_1 Central African Republic Chlorocebus tantalus F NA
5 AGM127_F_1 Central African Republic Chlorocebus tantalus F NA
6 AGM129_F_1 Central African Republic Chlorocebus tantalus F NA
> str(vervetdf)
'data.frame': 163 obs. of 5 variables:
$ ucla_id: Factor w/ 163 levels "A8516_M_2","AG23_F_10",..: 1 2 3 4 5 6 7 8 9 10 ...
$ country: Factor w/ 12 levels "Barbados","Botswana",..: 1 11 11 3 3 3 3 3 3 3 ...
$ species: Factor w/ 5 levels "Chlorocebus aethiops aethiops",..: 4 3 3 5 5 5 5 5 5 5 ...
$ Gender : Factor w/ 2 levels "F","M": 2 1 1 1 1 1 1 2 1 2 ...
$ pi : logi NA NA NA NA NA NA ...
Ich brauche die pi-Werte für jeden Affen für die Analyse hinzuzufügen und Plotten, so habe ich die neue Spalte pi. Pi ist für alle Affen derselben Spezies gleich (ich habe 5 Arten), aber wird in Fenstern berechnet, so gibt es 1300 Pi-Werte für jeden Affen. Ich habe eine Matrix mit den PI-Werte für jede Spezies:
> head(corrected_pi)
pi1 pi2 pi3 pi4 pi5
w1.ce 0.001918322 0.002408772 0.002306475 0.002086117 0.002501300
w2.ce 0.002125624 0.002779025 0.002620691 0.002599817 0.002847614
w3.ce 0.001512895 0.001886345 0.001867847 0.001658217 0.001875594
w4.ce 0.002340536 0.002637327 0.002736944 0.002252872 0.002848985
w5.ce 0.001329015 0.001553925 0.001654385 0.001654023 0.001806535
w6.ce 0.001326739 0.001595000 0.001487649 0.001417510 0.001581388
> dim(corrected_pi)
[1] 1300 5
So ist es eine Möglichkeit, eine gerade Säule des Datenrahmens in alle PI-Werte auf die entsprechenden Arten zuordnen kann?