Find the average of rows with duplicated column value - r

If the GeneSymbol is duplicated (i.e., there are previous rows containing the string in the GeneSymbol column, calculate the average of the other columns of that row. Then, I want to assign the meth.kirp.cpg$GeneSymbol column as the new row names of meth.kirp.symbol.
meth.kirp.symbol <- aggregate(meth.kirp.cpg, by=meth.kirp.cpg$GeneSymbol,data=meth.kirp.cpg,FUN=mean)
meth.kirp.symbol <- na.omit(meth.kirp.symbol)
Traceback:
Error in !meth.kirp.cpg$GeneSymbol : invalid argument type
rownames(meth.kirp.symbol) <- meth.kirp.symbol$GeneSymbol
meth.kirp.symbol$GeneSymbol <- NULL
Sample data:
> dput(meth.kirp.cpg[1:100,200:203])
structure(list(TCGA.Y8.A8RZ.01A = c(0.497271965133314, 0.369704160054987,
0.891551980644717, 0.53916519146516, 0.452596179682145, 0.763243369017172,
0.158949338942062, 0.0114350980370701, 0.857172998292539, 0.934966165863031,
0.0472399882616577, 0.0198027126658891, 0.0537032844435588, 0.564211104629996,
0.927550968549496, 0.797624950816491, 0.0290697007131178, 0.595912681963104,
0.174701858916678, 0.882333378501306, 0.857440598542643, 0.937145001009176,
0.159643935623585, 0.0516599385847632, 0.0440610541422886, 0.986742471430344,
0.0164534273018356, 0.905466185196924, 0.831233179669209, 0.945308723924202,
0.889966942114764, 0.354918054240825, 0.013300356676493, 0.830128502759263,
0.823700653779667, 0.10271041258008, 0.0287034526533831, 0.0206566535596095,
0.600278705481019, 0.875119985046439, 0.0371692028405492, 0.0222508063515825,
0.93666315025643, 0.928345505993255, 0.901317044941454, 0.765949109446722,
0.0581920996836425, 0.0430643414149486, 0.90591121556885, 0.951186809441601,
0.980658657952396, 0.0808689550165884, 0.572734025228151, 0.0463712698649506,
0.192938671458161, 0.905133179842298, 0.154186184934303, 0.585848485208317,
0.898651062830721, 0.936272438882973, 0.448635246131194, 0.283554776533025,
0.0309419633482652, 0.861391852247259, 0.0658397100529213, 0.0675173265786392,
0.96281794820265, 0.0313479382790672, 0.0866228017859603, 0.929772217122431,
0.200029728957143, 0.706267849864433, 0.94823325183122, 0.0543243613691732,
0.809705102714619, 0.910219965210065, 0.953735039953166, 0.868080342290672,
0.332725938100749, 0.84324363592612, 0.198505346878334, 0.992801413007608,
0.0503582852070818, 0.475444599242399, 0.988297216865074, 0.926321491575251,
0.0243299898333789, 0.10772567979535, 0.892537448190976, 0.98896599725299,
0.305816605549349, 0.696841353119351, 0.807770532814146, 0.115817690804427,
0.0130874570078787, 0.837153421174282, 0.917049247300387, 0.0122380520755151,
0.912364270697772, 0.951585664581661), TCGA.Y8.A8S0.01A = c(0.264547845506278,
0.155993443463906, 0.90708922263186, 0.756216481105085, 0.740439258566013,
0.791640201668772, 0.455406433078148, 0.0140503539973426, 0.898152971615672,
0.942017289363471, 0.049036339456109, 0.0165762503059443, 0.0593335909473265,
0.459771444740498, 0.929336066827294, 0.948532354182067, 0.0181370789479238,
0.309340792232534, 0.444549689057808, 0.968706245954783, 0.911532818633905,
0.922085999840623, 0.439367515136192, 0.0341088658899809, 0.259555790896829,
0.987081295221313, 0.013467632667194, 0.935890204938304, 0.749182228512838,
0.955266815776283, 0.854718619922343, 0.192270767250957, 0.0103294109383117,
0.814778997430484, 0.884929086289906, 0.364141121626961, 0.0261130123662795,
0.0201970054665062, 0.613121306641491, 0.867830249077504, 0.0313157213491265,
0.0247935393251212, 0.911488850004792, 0.895214160236747, 0.52514961950261,
0.88376413256428, 0.0384672039105036, 0.0294663841757698, 0.957910054231064,
0.955637967662581, 0.980805007180895, 0.056939960969146, 0.737932777954196,
0.0318060005100734, 0.0397987294622703, 0.914995576026559, 0.238482151213353,
0.767237616032529, 0.939069872404913, 0.938081858296652, 0.440484138576205,
0.114954872159159, 0.0244136454763111, 0.846540100826359, 0.200658220716674,
0.0687237453669147, 0.974841732977847, 0.0278561439566069, 0.114556259287869,
0.944131549328849, 0.493585389693977, 0.480768780057962, 0.932741163713172,
0.216131694873378, 0.814313163672161, 0.928672085649515, 0.962443725743837,
0.74077045094838, 0.133424847325993, 0.862916554456606, 0.145580720195214,
0.992046334661351, 0.0436393256442202, 0.712662114242391, 0.990103320899525,
0.880978917772909, 0.0225238271112234, 0.116230435240584, 0.841150918912896,
0.987985943353706, 0.127354758970553, 0.898121601977617, 0.906792865660564,
0.0737140541126039, 0.009384930132621, 0.793174978739833, 0.912006490158477,
0.0139855016500958, 0.899386699555785, 0.954405724569427), TCGA.Y8.A8S1.01A = c(0.581694254362101,
0.18542567310602, 0.867542022665212, 0.581696896530406, 0.78744743737146,
0.389767299224826, 0.216960001070295, 0.0124187105565375, 0.856565918074359,
0.936457155497046, 0.0442067173962602, 0.0140296565558842, 0.249846574394466,
0.476357170192695, 0.919768286971888, 0.947576649507426, 0.0180436058702339,
0.832021246626068, 0.417883168882454, 0.97668892894152, 0.858942374669228,
0.908701674774902, 0.360605175695457, 0.0300050878088438, 0.0152722989237764,
0.986911029436886, 0.017968868244694, 0.916403999667678, 0.665473802275997,
0.894770076029211, 0.815937481683747, 0.505075619070648, 0.0100265844940471,
0.807220745685876, 0.808764855317654, 0.316721084000246, 0.0221128261277136,
0.0159144104679436, 0.841207551595894, 0.832097056965122, 0.0307025272327261,
0.0185995888430839, 0.916475132262134, 0.866934314703349, 0.877454940064029,
0.833363153320509, 0.0381805807655402, 0.0273586863112515, 0.941134508841013,
0.912364696768614, 0.979496335094356, 0.0978730283287029, 0.525086161575951,
0.0261062766734918, 0.0320956400558761, 0.853299258800261, 0.131541990462738,
0.52940082480104, 0.85502275403225, 0.894518042164208, 0.535297530625847,
0.4749856970718, 0.0169015303648868, 0.853076664003846, 0.147470852267928,
0.0467328218099492, 0.978302229003696, 0.0283296096497759, 0.0728218303634117,
0.87648102880048, 0.334033090095117, 0.680802308868236, 0.927680442837916,
0.0707104696817582, 0.770195537274174, 0.868009087459515, 0.951475963819618,
0.797689168093036, 0.683015763740223, 0.803432908458056, 0.191347383851541,
0.991395963746777, 0.0604147893723364, 0.874483310648752, 0.98062171660084,
0.83805259736689, 0.0247465538486677, 0.170932965706481, 0.842567160630419,
0.983614792589478, 0.800795162965799, 0.860170927275085, 0.890545098059859,
0.298079674760789, 0.0084611909392357, 0.73227051610062, 0.831245875309251,
0.0115215601617515, 0.784943936721062, 0.835800768909104), GeneSymbol = c("RBL2",
NA, "VDAC3", "ACTN1", "ATP2A1", "SFRP1", NA, "NIPA2", "MAN1B1",
"LRRC16A", "CNBP", "DDX55", "FAM81A", "KCNQ1", NA, "NPHP4", "MRPS25",
NA, NA, "MAEL", "PROX1", "ELOVL1", "LILRA6", "LOC283050", "NR5A2",
"CDK10", NA, "TMEM182", NA, "DNAJA2", "ATOH7", "LRFN1", "MRPL12",
"COL6A3", NA, "C8orf31", "RTTN", "CD2BP2", "SLMAP", NA, "NOV",
"MXD4", "SND1", "MUSTN1", "TAS1R3", "ITGAD", "SMARCC2", "C1orf114",
NA, "C1orf65", "DNAH17", "DAB1", NA, "SLBP", "CHCHD4", NA, "TNNT2",
"CASZ1", "CASZ1", "C3orf16", NA, "WFIKKN2", "CCDC45", NA, "MEOX2",
"CKLF", "TRANK1", "ZFP36", "SLC2A9", "MXRA7", "LOXL4", NA, "P2RX6P",
"SFRS7", NA, "EHMT1", "AGPAT3", "CDSN", NA, NA, "AGA", "LDHD",
"C14orf181", "LOC729176", "SH2B3", "MTMR7", "MT1F", "RSPO3",
"ANKRD11", "TDRD6", "WWP2", "OR1F2P", "SERPINB12", "DOK7", "SRCAP",
"AMDHD2", "DRG2", "TCTE3", "EFNB1", "FAM180B")), row.names = c("cg00000029",
"cg00000165", "cg00000236", "cg00000289", "cg00000292", "cg00000321",
"cg00000363", "cg00000622", "cg00000658", "cg00000721", "cg00000734",
"cg00000769", "cg00000905", "cg00000924", "cg00000948", "cg00000957",
"cg00001245", "cg00001249", "cg00001261", "cg00001349", "cg00001364",
"cg00001446", "cg00001510", "cg00001582", "cg00001583", "cg00001687",
"cg00001747", "cg00001791", "cg00001809", "cg00001854", "cg00001874",
"cg00002033", "cg00002116", "cg00002145", "cg00002190", "cg00002224",
"cg00002236", "cg00002406", "cg00002426", "cg00002449", "cg00002464",
"cg00002490", "cg00002531", "cg00002591", "cg00002593", "cg00002597",
"cg00002660", "cg00002719", "cg00002769", "cg00002808", "cg00002809",
"cg00002810", "cg00002837", "cg00003091", "cg00003173", "cg00003181",
"cg00003287", "cg00003345", "cg00003513", "cg00003529", "cg00003578",
"cg00003625", "cg00003784", "cg00003969", "cg00003994", "cg00004055",
"cg00004067", "cg00004072", "cg00004082", "cg00004089", "cg00004105",
"cg00004121", "cg00004192", "cg00004207", "cg00004209", "cg00004429",
"cg00004533", "cg00004562", "cg00004608", "cg00004773", "cg00004818",
"cg00004883", "cg00004939", "cg00004963", "cg00004979", "cg00004996",
"cg00005010", "cg00005040", "cg00005072", "cg00005083", "cg00005112",
"cg00005166", "cg00005215", "cg00005297", "cg00005306", "cg00005390",
"cg00005437", "cg00005543", "cg00005617", "cg00005619"), class = "data.frame")

As you have some NA's in GeneSymbol, you cannot use them as rownames unless you remove the NA's also.
This code identifies and calculates the mean of the duplicated and NA's rows,
then remove them from the data.frame and assign GeneSymbol as rownames
meth.kirp.duplicated.na <- data.frame(
mean = apply(subset(meth.kirp.cpg,
duplicated(GeneSymbol) | is.na(GeneSymbol),
select = -GeneSymbol), MARGIN = 1, mean),
is.na = with(meth.kirp.cpg, is.na(GeneSymbol)[
duplicated(GeneSymbol) | is.na(GeneSymbol)]))
meth.kirp.cpg <- subset(meth.kirp.cpg, !duplicated(GeneSymbol) & !is.na(GeneSymbol))
rownames(meth.kirp.cpg) <- meth.kirp.cpg$GeneSymbol

If I understand you correctly, you can loop over the rows and calculate an average only when GeneSymbol is a duplicate.
# create empty column for averages
meth.kirp.cpg$average = rep(NA, nrow(meth.kirp.cpg))
# fill column with row average for cases when `GeneSymbol` is a duplicate
for (r in 1:nrow(meth.kirp.cpg)) {
if (sum(na.omit(meth.kirp.cpg$GeneSymbol[r] == meth.kirp.cpg$GeneSymbol)) > 1){
meth.kirp.cpg$average[r] = mean(meth.kirp.cpg[r,1],
meth.kirp.cpg[r,2],
meth.kirp.cpg[r,3])
}
}

Related

lower triangular heat-map in r

I'm trying to plot a pearson correlation heat map in R on a certain dataset.
The rows and columns of the heat map shall be the same, thus I'm trying to plot a lower triangular plot for it.
The code I'm trying to run is:
cormat_UCS_pearson <- round(cor(t(UCS_pearson)),5)
Where
UCS_perason originally has 58387 columns and two rows, but due to constraints, I'll show
UCS_pearson[,c(1:500)]
structure(c(-0.160788424826038, -0.0257422401750742, -0.0518775542691747,
-0.165841754235558, 0.0621416947620554, 0.222940671263803, 0.0182177186967158,
-0.269665933111091, 0.0108734083848302, -0.0680795555145049,
-0.0314603016241517, 0.100409630242065, 0.491174247937916, 0.153922391186737,
0.0768587331222585, -0.143707163610835, 0.0312164212874025, 0.399184814292453,
-0.153967984972866, 0.204591797534103, -0.0588748849845526, 0.0221869847261395,
-0.12301177706225, 0.0826808454400297, -0.126961149111363, -0.174469497173807,
0.256151155743578, 0.240852646359448, 0.10638094887544, -0.0815900402383247,
0.250473442293516, -0.0238179204071666, -0.144651564807006, -0.280937576894735,
-0.111684092128957, -0.0197076858668464, -0.193220376106192,
-0.0426606909811688, -0.126004286407775, 0.0947536170087334,
0.057738977299137, 0.103571460702936, -0.0157257710015432, 0.149407092075215,
0.127302014752183, -0.206738230688861, -0.060775963589793, -0.189757106698901,
-0.0371024550402435, 0.291246274232428, -0.194659994239295, -0.0689694149696159,
0.160163113758826, 0.17502435406333, -0.341828765694863, 0.0885796257422236,
0.13248737580755, -0.0851616477975954, -0.0225921176857983, -0.00496786994749575,
-0.17139210128259, -0.0754857264355948, -0.326059268523373, -0.197034490794277,
0.187118821445185, -0.3258318107255, -0.0147060076874178, 0.20744856580739,
0.0259449619062298, 0.0133471912808717, -0.089235642663198, -0.104758508695755,
-0.219995628159254, -0.163556018826001, 0.217837787973358, -0.0383668156955706,
0.0446037028532433, 0.0546081091603452, 0.0198990872830052, -0.299886754594252,
0.0690624544291303, -0.151075386942631, -0.0245980828870225,
0.325134214974123, -0.178998579719923, -0.197501542084414, -0.125821792361664,
-0.0831374400037483, -0.0543175598721145, -0.107434351704301,
0.127833423926045, -0.243709143035783, 0.087296540658909, -0.303868722218803,
0.0549884854381427, 0.00283222132557367, -0.360218483376441,
-0.129891049916006, -0.0459448401386707, -0.144868402432394,
-0.0535188683995115, -0.303725269328798, -0.0483750689864511,
-0.207767080382625, 0.0559883421655016, 0.0858848566417679, NA,
NA, NA, NA, -0.116958996376998, 0.217790881211909, 0.0101501061185678,
-0.202050192341405, -0.0881431858631242, -0.194286462214668,
-0.19180463728637, -0.0217840096309176, 0.131094012852616, 0.145435974509276,
0.382016642961684, 0.143664069160626, -0.0703444124193061, 0.270682340825076,
-0.123773734884045, -0.174898297084319, -0.108567975049227, 0.387983258609705,
0.015828181483406, 0.27251194494083, -0.167524773792288, -0.307520405026975,
-0.338574553003239, 0.232510614134642, -0.304841647448181, -0.0877809113428862,
0.0351379398344911, 0.354532976072275, -0.0103688020125061, 0.0670146594763316,
0.431473799708244, 0.213550373925138, -0.254128008083358, 0.238998869027372,
0.245751872540891, -0.201280379473751, 0.266977857736016, -0.0777428082918172,
-0.0686789231261643, 0.190746571654957, 0.255804100930973, 0.188071238929165,
-0.15567163862281, -0.0398148182192045, 0.0462693932429652, -0.00507416965589838,
0.00363537787013793, -0.0188385425590899, 0.0275070608784838,
-0.0534385432423223, -0.235533303097878, 0.000109987362191777,
0.153735230223155, 0.209660579263017, 0.364093077082748, -0.200223246642941,
-0.279468292091011, -0.327788622359998, -0.161785570342061, 0.0221858209145764,
-0.089650270941241, 0.044839622245306, 0.0167494127674376, 0.17763975775981,
-0.211907993676722, 0.476249412131041, -0.127568417870314, 0.111871434618033,
0.0102134076903728, -0.165771097571374, -0.0262893880607643,
-0.24267144356801, 0.0186639441848443, 0.0889160526448091, -0.0275168070171429,
0.105462484914279, -0.104650618921904, 0.485111478944573, -0.0547230640788596,
0.418102872004007, -0.057518923097887, -0.272661215158949, -0.117124831113974,
0.103465628421468, 0.0130711099362795, 0.193421167301985, 0.185748166363864,
0.116518045189166, -0.0535005003380154, 0.146576772396211, -0.0400786368245271,
-0.355485812798769, 0.451651830648632, -0.366605461937997, 0.172424549663343,
-0.140341757305126, 0.0767729688333064, -0.250163351333159, 0.164629010363882,
0.0934583124974739, -0.0257982745866111, 0.143182112676179, -0.0038174243480748,
-0.130737192889484, 0.314900386584229, 0.214116977066315, -0.00490172883881734,
0.308646252172375, -0.373169880595436, 0.360984980326363, -0.00677448042462275,
-0.277436852875204, 0.129349565175812, -0.325470301363098, -0.234973619509544,
-0.164824854977916, -0.0292766889951448, -0.0907647963237643,
-0.319864057611299, 0.0270188473125247, 0.0981459337969273, -0.103491183966377,
0.20984231852361, 0.317321366699691, 0.498494858783593, -0.055812813462925,
0.0811661656281664, -0.280852499373267, -0.171357384217252, -0.0282465534706698,
-0.0387480765018486, -0.129146457915067, -0.470374989360243,
-0.180601632505367, -0.142395528689498, -0.230812618979536, -0.328663331622077,
0.667148931331779, -0.310787006809799, 0.607484764648746, -0.0695639978289592,
0.571428846305687, 0.121589240587617, -0.149946440834327, -0.00049796651995692,
-0.0273667377723118, -0.216744952108681, 0.0720981060950985,
-0.0201231966695146, -0.121282535513109, -0.270602854434521,
0.182350144023858, 0.103005527927574, 0.155195552830089, -0.144345670507073,
-0.168741467053413, 0.148040310295331, 0.196092346617121, NA,
NA, -0.159639365076587, 0.00770350895130156, -0.18495611211399,
0.0666486303528997, -0.0766142699859562, -0.188493474455737,
-0.0435048945218461, -0.223117732044948, -0.0238548540996054,
-0.317445711246788, NA, NA, 0.101286619156465, 0.0950642157902226,
-0.189292595533748, 0.473693004640604, 0.0997608933151469, 0.154916175788068,
-0.0218696636548777, 0.305267207338952, 0.127162496463241, 0.290876940067172,
0.147676819728199, 0.326243074259712, 0.235646247829676, -0.0417812081449229,
0.0429954391404932, -0.291524447226673, -0.0526985369068797,
0.605044141128949, -0.381892266884492, 0.0181871141905498, 0.334334514019781,
0.281403732730617, 0.431864700200925, -0.198503801251651, 0.205059732297505,
-0.131730304224948, -0.060453849529942, -0.0647619911734703,
-0.166359804231634, 0.282486170805339, 0.0100090947328073, -0.37346431271674,
0.421939167218388, -0.504999374742108, -0.0361458397090175, 0.199806590200299,
-0.0923939579395243, 0.300258558209524, 0.307083208123854, -0.372662607142777,
-0.0572583319729891, 0.644732889957074, -0.0904118240718854,
-0.143029858612403, -0.187615998952944, 0.121964949216529, 0.0531386426015056,
0.0624749217328398, 0.206863803305199, -0.262259708980188, 0.0726333418651898,
-0.103658323178436, -0.296071442543119, 0.226374016486998, -0.13440366483565,
0.105501678602159, -0.130030639213654, -0.0110364477837153, NA,
NA, NA, NA, 0.26968371426098, -0.0155890673729734, -0.184284451840467,
-0.0633697628527222, -0.0756406653509469, 0.227411948775754,
NA, NA, -0.125345469385346, -0.0224828981838005, 0.161597493963613,
0.0371197944548526, 0.0148541820967762, -0.189921774311887, -0.397832457796958,
-0.0582032827727681, -0.0764673867131659, -0.0497957441923001,
NA, NA, 0.0449605522472631, 0.0140435671785606, 0.115644287199413,
-0.163612728982696, -0.0369305763029631, 0.152739947872823, -0.181575371181168,
0.154621954754853, NA, NA, -0.314553803719056, 0.344799633261712,
0.0192799528247013, -0.098685769455291, -0.124360554540428, 0.157860234941791,
-0.260396218951657, 0.239485632172963, -0.208741410333448, 0.250827260972775,
-0.142971536264546, 0.207405918032745, NA, NA, NA, NA, -0.0439580344807332,
-0.00181528986796664, -0.0139516499838043, -0.0328095707998725,
-0.0789083514987792, 0.0858281285285902, 0.196262693708447, -0.36649818106507,
0.190538516279416, -0.24916090647245, -0.0728720117481969, -0.0191284575760859,
-0.243389660492848, 0.235641344386585, -0.139766107251914, 0.062247028731737,
-0.246899059846911, 0.178223227792211, -0.190726027555047, -0.0407223282975083,
-0.108655590226593, 0.141082171706391, -0.183351948608341, 0.236140466617194,
0.0336232516784701, 0.159891906857505, -0.244268390987204, 0.229391964824989,
-0.14224137016854, -0.0370043853074932, 0.198093698676019, -0.0745427825448673,
-0.18751615569672, 0.0252952801902908, 0.0148541820967762, -0.189921774311887,
-0.141718980419485, 0.06303858589334, -0.0798637131409112, 0.0206753397045604,
0.0658995925160964, -0.182462081862579, -0.293310524503675, -0.103785090955044,
-0.205789421986016, 0.0737216228863557, -0.18743150613592, 0.0244709344941872,
0.0523090211391174, -0.327774911814208, -0.383791289381148, 0.0224717952896955,
-0.0489466663793394, 0.100849338204541, -0.205632282008697, 0.112731143201648,
NA, NA, -0.0791422176742333, -0.183122879592945, -0.256251541372125,
0.32075114702689, -0.109056115482951, -0.437581856952708, 0.168565776593927,
0.0112315186467975, 0.0205230712251415, -0.152633262615199, NA,
NA, -0.00559346627671493, -0.105939600710423, -0.243200334585682,
-0.0229886745335356, -0.313000186357086, -0.108806585468647,
0.0629844853565044, -0.124978427715945, -0.0998156929088808,
0.28918613444771, -0.229029771129634, 0.17860401699821, 0.192976395550239,
0.0674795315940469, 0.22208076381171, -0.0653077742729489, -0.00441092879437654,
-0.152151871343017, -0.0542585474086585, -0.182156022157871,
0.0243360827586908, -0.159456853362232, -0.315451438915062, 0.00479586764109896,
-0.0658226744519441, -0.054022622684617, -0.14684354898579, -0.0896047917744014,
0.195921804059387, -0.226971922068303, -0.254313406940928, 0.0745354964465048,
0.128381070000955, -0.157056282544603, -0.138751496766607, -0.0562634415442843,
-0.121197670553226, -0.086160697551453, -0.00237992724559371,
-0.115638431740053, NA, NA, -0.0443131642566608, -0.062570457797265,
0.0523959206070392, -0.26451277545694, 0.324554215403563, -0.354636832149615,
0.0900046149894463, -0.21360124829462, 0.328849018719503, -0.563194911556135,
0.0385188334418423, -0.208681554453189, NA, NA, -0.116449694964364,
0.173898476234437, -0.0122353221226405, -0.242859992554905, 0.210779556914438,
-0.136979289161418, 0.112849182471408, -0.0110878937045105, 0.131675159121585,
0.0322369268631404, 0.0722503560841253, -0.105559617713625, 0.145702587734005,
-0.114055843186341, 0.00897168069912057, -0.152779535607564,
0.185416115132091, 0.139648936171848, -0.339435712322975, 0.188493277626503,
-0.219576557100002, 0.0467816679929099, -0.131853773373089, 0.355835047322506,
-0.116170318459756, -0.0062172053864046, -0.00175143214065898,
-0.20938447143972, NA, NA, -0.0645228798411095, -0.053029560023961,
NA, NA, -0.0579625705349727, -0.0879095942957547, -0.0455126985613822,
0.137286630347203, 0.0544159282310674, -0.111029350609663, -0.305157448976381,
0.00287650667329221, -0.0963772261791161, 0.0141550428169644,
-0.118323505439401, 0.0263086012994963, NA, NA, 0.0946996437488379,
-0.0281882901839543, -0.264830491470819, -0.00560255714547876,
NA, NA, 0.0287172038730819, -0.12287491123785, 0.170618969726522,
-0.326371890456747, NA, NA, NA, NA, 0.0074222793941661, -0.178073160886772,
-0.0375507862866806, -0.182780598851118, 0.174405365634955, -0.0244120019683591,
-0.122779951693592, -0.115042812668123, -0.137871428426028, -0.211317089796517,
-0.258126039429376, -0.193566134112804, 0.00147105642397745,
-0.106264366711376, -0.14006867589864, 0.182331899630885, -0.0218154837408014,
0.356667547454766, -0.0412310716225777, 0.00258551517278575,
-0.0339760949801102, -0.0573451484471943, -0.179844910648036,
0.0601934923986177, -0.0954311733961448, -0.257716546080691,
-0.164487954057847, 0.224289601070542, -0.00450016672450693,
0.161798490365034, -0.111255908346463, 0.00906404808218765, 0.00707737733818487,
-0.225878282983652, NA, NA, -0.205008285258871, 0.0543934055830302,
0.012953293999785, -0.199688812112181, -0.105178786172577, 0.0560530628822707,
0.00672275694888985, -0.231344038330046, -0.0807995561538029,
0.0412518012555594, -0.0386808218946201, -0.113881835400778,
0.111253966201852, -0.266822480171457, 0.0600113076474125, 0.126601954785962,
0.185063704213823, 0.166017397633998, NA, NA, 0.0105619900125018,
-0.18651120773984, 0.0763268563546143, -0.166665309941193, -0.178580845628754,
-0.233312517579627, -0.0481684063571434, -0.077797048088731,
-0.203280994156471, -0.142581544437585, 0.0255836118745615, -0.0276336831868125,
-0.0295129513017942, 0.0674858668793503, 0.135260909059116, -0.0927405173056505,
0.0744990456655177, -0.144738862753733, -0.237192573939147, 0.160141253589785,
0.142147193792261, -0.187992976443227, -0.216446688136037, -0.16105196661471,
-0.0508237785151704, 0.118627591076543, -0.182898710862875, 0.0707376228068899,
-0.193890924258218, 0.0900954283356207, 0.00401622925185781,
-0.195921324986153, -0.0694101254841401, 0.0775580321503677,
0.108041719522084, 0.0396115053067626, -0.0458284022403393, -0.218871555395771,
0.121440522444865, -0.0572042815635894, -0.22218652218659, 0.0248185058615541,
0.20938839175807, 0.132481057338594, -0.180258610941658, -0.0284142478612041,
-0.21671672952526, 0.194763389382272, 0.0364715948504319, -0.0657975195408112,
-0.0563040880456959, -0.109544685418116, NA, NA, 0.0648057072675422,
-0.157786229573645, -0.00638799728608172, -0.128516028136478,
0.154035375347516, -0.339760203241564, NA, NA, -0.0864268879423147,
0.0131312434942388, NA, NA, -0.205461907805209, -0.130332837170351,
-0.206680676605858, 0.136703988067015, -0.174060373675473, 0.0659448601839198,
-0.0580533126015975, -0.0314593831638318, -0.0920101781411946,
0.25675637702712, -0.27470347980719, 0.295884532407143, 0.151243691290212,
0.348292828320822, -0.0164280622109516, 0.0294134305588641, -0.355313617294638,
-0.0496116046792636, NA, NA, 0.208051615507144, 0.0612230994890477,
-0.296772891159623, 0.106373198893925, -0.0564000131604138, -0.13755092784139,
-0.0946301230487614, -0.217984541666007, -0.0113011118872734,
-0.353759404722727, NA, NA, -0.125290458742648, 0.0582470395976115,
-0.114798167159317, 0.101545514768859, 0.081099183231184, -0.0827437844416916,
-0.103933326795975, 0.0368614189812161, -0.261860493414426, -0.0839879795872783,
-0.138957366652903, -0.137790816073706, -0.153452701090709, -0.445014708107295,
0.0096604780196279, 0.134783916221383, 0.0452900996550472, -0.210708736380164,
0.0621242385590066, -0.0514563799465529, -0.00744713312770768,
0.0250887647061372, -0.116959036351569, -0.085224863529069, -0.38853419499807,
-0.189952634118266, -0.218665695216765, 0.467745176730558, -0.336315754204112,
0.249063676234904, -0.104035042076053, -0.136859566609601, 0.0525495025377563,
-0.454589141329014, -0.0519257847232248, 0.0205225076770941,
-0.178737694570114, -0.155275617904206, -0.00237992724559371,
-0.115638431740053, -0.110518678178894, -0.108372682262173, -0.287709060609944,
0.0371322942937481, 0.066671589858597, -0.391606873099472, 0.126226324658725,
-0.399388231127899, -0.203849571318033, -0.100361249758939, NA,
NA, -0.187166335014545, -0.124685973058729, -0.191261034341373,
0.125557120478446, NA, NA, -0.172192663023502, 0.0210935670934318,
0.0437454640495771, 0.0649474707755941, -0.0307560655211706,
-0.155943348564083, -0.100459894129437, -0.0837349103788484,
NA, NA, -0.0467230775481449, 0.0445367556198534, -0.0258221029555385,
-0.337769379137755, -0.0949717047071838, -0.0653334039042102,
-0.0916244514588163, 0.208385897193025, -0.0139516499838043,
-0.0328095707998725, 0.108756365899433, -0.205946694745602, 0.0444850847582909,
-0.0456047105712402, -0.123080606885036, 0.166004972978278, -0.0540745862900131,
-0.104383649403864, NA, NA, NA, NA, -0.256514651048856, 0.0389502818708297,
-0.155885002949447, -0.145172040814028, -0.0197648643935328,
-0.154228761470774, -0.245465986869158, 0.196050394893124, -0.0629062361879831,
-0.0418851053863066, -0.0883849505943926, 0.167116542912757,
NA, NA, -0.0945325286387913, -0.244297051453914, 0.0994391613316947,
-0.0414589626231581, -0.0021774093388973, 0.0789953240584772,
-0.28851469166179, 0.212678450880014, 0.178853309299823, 0.0160852171949784,
NA, NA, -0.0724021587657935, -0.0726525233071279, 0.0641256540271004,
-0.247109926514703, 0.261007190593326, 0.162365145316339, 0.183695385237096,
-0.160854132104893, 0.0254757957933874, 0.159302424608104, 0.0536504218846581,
0.0947326442990328, -0.0739825582591165, -0.023444526981956,
NA, NA, -0.246445416033503, 0.0421799991254654, 0.171399843165558,
0.121857838781291, 0.131291806491966, -0.0310256969763662, 0.084932656034447,
0.319694044603215, -0.0889318830147494, 0.244658060764321, -0.0962644796304246,
-0.0406925583175, 0.0719899653174018, 0.186970645556985, -0.269454328187128,
0.115075337197967, NA, NA, 0.124683035292236, 0.0203697993225934,
-0.188138124518597, 0.0454961850788923, -0.0506301523232337,
0.283829223238744, NA, NA, 0.012953293999785, -0.199688812112181,
-0.0414576280113129, 0.195648813114567, -0.178532798762864, 0.0495794181231349,
-0.284278159207787, 0.119933984376387, -0.0736119199628618, -0.0519048539144688,
-0.193631407386575, -0.289684365032212, 0.0521560438562125, -0.122037909970877,
-0.136878270640725, 0.149803202303949, 0.0153790015443654, 0.0202694351487697,
NA, NA, NA, NA, NA, NA, -0.0756117605914394, 0.148175208233554,
-0.271295578246216, 0.409493126095501, -0.01568142586576, -0.0648911279001933,
NA, NA, 0.0671711556674623, 0.0618219987103883, 0.133024970982326,
-0.193030566840229, -0.0158360602199258, -0.0866160392870411,
-0.0675782565096752, -0.0751017710958831, -0.220393224448939,
-0.00966063181064768, -0.0996194859966963, -0.0991640377156096,
0.0726333418651898, -0.103658323178436, -0.27364637703548, 0.273019847922917,
-0.0781696117636672, 0.129417247633593, 0.0297980677565262, -0.134352011645225,
-0.118604292468149, -0.190775713471729, -0.16647638154017, -0.0762085246815682,
-0.0891311686769857, -0.163661512890215, 0.31722215300791, -0.275034100117617,
-0.129169755185721, -0.00241222587250762, -0.107647650941447,
0.127604415704785, -0.166092508902277, -0.195686403184036, 0.0318623953980768,
0.141089701919201, NA, NA, -0.0961135302259641, -0.0798572664410973,
NA, NA, -0.0461883921074545, 0.0834756138899552, -0.08487553609808,
0.00963537949551373, -0.165936066953134, 0.0111744666718458,
-0.0908197261353577, -0.156010494847943, -0.260674035822964,
-0.114751621595064, NA, NA, NA, NA, -0.0136054096164949, -0.0185447185244471,
-0.122981079778463, -0.0111990675185473, -0.182298509501045,
-0.388317916380626, -0.153758412306888, 0.261778719392714, -0.217254978152196,
0.191612183539808, NA, NA, -0.136777432491356, -0.114496580430642,
-0.02969812077836, -0.268652077750056, -0.0508640036811775, -0.000711744011523578,
0.317425038435027, 0.134985042790569, NA, NA), .Dim = c(2L, 500L
), .Dimnames = list(c("tumor_Mes", "tumor_Epi"), c("5_8S_rRNA",
"5S_rRNA", "7SK", "A1BG", "A1BG-AS1", "A1CF", "A2M", "A2M-AS1",
"A2ML1", "A2ML1-AS1", "A2ML1-AS2", "A2MP1", "A3GALT2", "A4GALT",
"A4GNT", "AA06", "AAAS", "AACS", "AACSP1", "AADAC", "AADACL2",
"AADACL2-AS1", "AADACL3", "AADACL4", "AADACP1", "AADAT", "AAED1",
"AAGAB", "AAK1", "AAMDC", "AAMP", "AANAT", "AAR2", "AARD", "AARS",
"AARS2", "AARSD1", "AARSP1", "AASDH", "AASDHPPT", "AASS", "AATBC",
"AATF", "AATK", "AATK-AS1", "AB015752.3", "AB019438.66", "AB019440.50",
"AB019441.29", "ABALON", "ABAT", "ABBA01017803.1", "ABC12-47043100G14.2",
"ABC12-47964100C23.1", "ABC12-49244600F4.4", "ABC14-1080714F14.1",
"ABC7-42391500H16.2", "ABC7-42418200C9.1", "ABC7-43041300I9.1",
"ABC7-481722F1.1", "ABCA1", "ABCA10", "ABCA11P", "ABCA12", "ABCA13",
"ABCA17P", "ABCA2", "ABCA3", "ABCA4", "ABCA5", "ABCA6", "ABCA7",
"ABCA8", "ABCA9", "ABCA9-AS1", "ABCB1", "ABCB10", "ABCB10P1",
"ABCB10P3", "ABCB10P4", "ABCB11", "ABCB4", "ABCB5", "ABCB6",
"ABCB7", "ABCB8", "ABCB9", "ABCC1", "ABCC10", "ABCC11", "ABCC12",
"ABCC13", "ABCC2", "ABCC3", "ABCC4", "ABCC5", "ABCC5-AS1", "ABCC6",
"ABCC6P1", "ABCC6P2", "ABCC8", "ABCC9", "ABCD1", "ABCD1P2", "ABCD1P3",
"ABCD1P4", "ABCD1P5", "ABCD2", "ABCD3", "ABCD4", "ABCE1", "ABCF1",
"ABCF2", "ABCF2P1", "ABCF2P2", "ABCF3", "ABCG1", "ABCG2", "ABCG4",
"ABCG5", "ABCG8", "ABHD1", "ABHD10", "ABHD11", "ABHD11-AS1",
"ABHD12", "ABHD12B", "ABHD13", "ABHD14A", "ABHD14A-ACY1", "ABHD14B",
"ABHD15", "ABHD15-AS1", "ABHD16A", "ABHD16B", "ABHD17A", "ABHD17AP1",
"ABHD17AP3", "ABHD17AP4", "ABHD17AP6", "ABHD17AP9", "ABHD17B",
"ABHD17C", "ABHD2", "ABHD3", "ABHD4", "ABHD5", "ABHD6", "ABHD8",
"ABI1", "ABI2", "ABI3", "ABI3BP", "ABL1", "ABL2", "ABLIM1", "ABLIM2",
"ABLIM3", "ABO", "ABR", "ABRA", "ABRACL", "ABT1", "ABT1P1", "ABTB1",
"ABTB2", "AC000003.1", "AC000029.1", "AC000032.2", "AC000036.4",
"AC000041.10", "AC000041.8", "AC000067.1", "AC000068.10", "AC000068.5",
"AC000068.9", "AC000077.2", "AC000078.5", "AC000081.2", "AC000089.3",
"AC000095.11", "AC000095.9", "AC000099.1", "AC000110.1", "AC000111.3",
"AC000111.4", "AC000111.5", "AC000111.6", "AC000120.7", "AC000123.2",
"AC000123.3", "AC000123.4", "AC000124.1", "AC000354.1", "AC000362.1",
"AC000367.1", "AC000370.2", "AC000374.1", "AC000403.1", "AC000403.4",
"AC001226.7", "AC002044.1", "AC002044.3", "AC002044.4", "AC002056.3",
"AC002056.5", "AC002059.10", "AC002064.4", "AC002064.5", "AC002064.7",
"AC002066.1", "AC002069.5", "AC002069.6", "AC002070.1", "AC002072.1",
"AC002075.3", "AC002075.4", "AC002076.10", "AC002115.5", "AC002115.9",
"AC002116.7", "AC002116.8", "AC002117.1", "AC002127.2", "AC002127.4",
"AC002128.5", "AC002306.1", "AC002310.10", "AC002310.12", "AC002310.13",
"AC002310.14", "AC002310.17", "AC002310.7", "AC002314.4", "AC002331.1",
"AC002365.5", "AC002366.1", "AC002366.3", "AC002368.4", "AC002383.2",
"AC002386.1", "AC002389.1", "AC002395.1", "AC002398.11", "AC002398.12",
"AC002398.13", "AC002398.9", "AC002400.1", "AC002401.1", "AC002407.1",
"AC002429.1", "AC002429.4", "AC002429.5", "AC002451.3", "AC002454.1",
"AC002456.2", "AC002463.3", "AC002464.1", "AC002465.2", "AC002467.7",
"AC002472.11", "AC002480.2", "AC002480.3", "AC002480.4", "AC002480.5",
"AC002486.2", "AC002486.3", "AC002511.2", "AC002511.3", "AC002519.6",
"AC002519.8", "AC002523.1", "AC002530.1", "AC002539.1", "AC002539.2",
"AC002542.2", "AC002543.2", "AC002550.5", "AC002550.6", "AC002551.1",
"AC002553.4", "AC002558.1", "AC002978.1", "AC002979.1", "AC002981.1",
"AC002984.2", "AC002985.3", "AC003001.1", "AC003002.4", "AC003002.6",
"AC003003.5", "AC003005.2", "AC003005.4", "AC003006.1", "AC003006.7",
"AC003009.1", "AC003045.1", "AC003075.4", "AC003080.4", "AC003084.2",
"AC003088.1", "AC003090.1", "AC003092.1", "AC003092.2", "AC003101.1",
"AC003104.1", "AC003658.1", "AC003664.1", "AC003666.1", "AC003681.1",
"AC003682.16", "AC003682.17", "AC003688.1", "AC003956.1", "AC003958.2",
"AC003958.6", "AC003968.1", "AC003973.1", "AC003973.3", "AC003973.4",
"AC003973.5", "AC003984.1", "AC003985.1", "AC003986.5", "AC003986.6",
"AC003986.7", "AC003988.1", "AC003989.3", "AC003989.4", "AC003991.3",
"AC004000.1", "AC004000.2", "AC004004.2", "AC004006.2", "AC004009.1",
"AC004009.2", "AC004009.3", "AC004012.1", "AC004014.3", "AC004014.4",
"AC004016.1", "AC004019.10", "AC004019.13", "AC004022.7", "AC004022.8",
"AC004041.2", "AC004051.2", "AC004052.1", "AC004053.1", "AC004053.2",
"AC004054.1", "AC004057.1", "AC004062.2", "AC004063.1", "AC004066.2",
"AC004066.3", "AC004067.5", "AC004069.1", "AC004069.2", "AC004070.1",
"AC004074.4", "AC004076.5", "AC004076.7", "AC004076.9", "AC004079.1",
"AC004108.1", "AC004112.4", "AC004112.5", "AC004112.7", "AC004125.3",
"AC004129.7", "AC004129.9", "AC004156.3", "AC004158.1", "AC004158.3",
"AC004159.1", "AC004160.4", "AC004166.6", "AC004221.2", "AC004231.2",
"AC004237.1", "AC004257.1", "AC004381.6", "AC004381.7", "AC004383.3",
"AC004386.3", "AC004386.4", "AC004447.2", "AC004448.2", "AC004448.5",
"AC004449.6", "AC004453.1", "AC004453.8", "AC004458.1", "AC004460.1",
"AC004461.4", "AC004470.1", "AC004471.10", "AC004471.9", "AC004477.1",
"AC004485.3", "AC004490.1", "AC004492.1", "AC004510.3", "AC004520.1",
"AC004535.2", "AC004538.3", "AC004540.4", "AC004540.5", "AC004541.1",
"AC004543.1", "AC004543.2", "AC004549.6", "AC004552.1", "AC004593.3",
"AC004595.1", "AC004603.4", "AC004623.2", "AC004623.3", "AC004637.1",
"AC004655.1", "AC004656.1", "AC004673.1", "AC004687.1", "AC004691.1",
"AC004691.5", "AC004692.4", "AC004692.5", "AC004699.1", "AC004702.2",
"AC004744.3", "AC004745.1", "AC004754.3", "AC004769.1", "AC004775.5",
"AC004791.2", "AC004812.1", "AC004813.1", "AC004816.1", "AC004819.1",
"AC004824.1", "AC004824.2", "AC004832.1", "AC004837.1", "AC004837.3",
"AC004837.4", "AC004837.5", "AC004840.8", "AC004846.1", "AC004850.1",
"AC004854.4", "AC004854.5", "AC004862.6", "AC004866.1", "AC004866.3",
"AC004869.2", "AC004869.3", "AC004870.3", "AC004870.4", "AC004870.5",
"AC004875.1", "AC004878.2", "AC004878.8", "AC004893.10", "AC004893.11",
"AC004895.1", "AC004895.4", "AC004899.3", "AC004901.1", "AC004906.3",
"AC004911.2", "AC004915.1", "AC004920.2", "AC004920.3", "AC004924.1",
"AC004932.1", "AC004938.5", "AC004941.3", "AC004941.5", "AC004943.1",
"AC004945.1", "AC004946.1", "AC004947.2", "AC004951.5", "AC004951.6",
"AC004953.1", "AC004967.7", "AC004969.1", "AC004980.1", "AC004980.10",
"AC004980.11", "AC004980.7", "AC004980.8", "AC004980.9", "AC004984.1",
"AC004985.12", "AC004987.10", "AC004987.9", "AC004988.1", "AC005000.1"
)))
This gives me
cormat_UCS_pearson as
structure(c(1, NA, NA, 1), .Dim = c(2L, 2L), .Dimnames = list(
c("tumor_Mes", "tumor_Epi"), c("tumor_Mes", "tumor_Epi")))
Since the values are either 1 or NAs, I cannot move ahead to plot a graph for the same.
Any suggestion to help circumvent this shall be helpful.
The initial steps of my codes produced certain NAs and I had to rectify them in order to get the correct plot.

linearly ranking values from 0:10 in r

I have the following dataset:
structure(list(G = c(NA, NA, -1.01182174807081, -1.01182174807081,
-1.01182174807081, -1.03501949560312, -1.03501949560312, -1.03501949560312,
-1.01189555194367, -1.01189555194367, -1.01189555194367, -1.03208191284692,
-1.03208191284692, -1.03208191284692, -1.00007825695672, -1.00007825695672,
-1.00007825695672, -1.03027247563088, -1.03027247563088, -1.03027247563088,
-0.999632960176179, -0.999632960176179, -0.999632960176179, -0.998570208055593,
-0.998570208055593, -0.998570208055593, -0.975978344319463, -0.975978344319463,
-0.975978344319463, -0.984342844790316, -0.984342844790316, -0.984342844790316,
-0.998450245287518, -0.998450245287518, -0.998450245287518, -1.11255680134788,
-1.11255680134788, -1.11255680134788, -1.14437105346841, -1.14437105346841,
-1.14437105346841, -1.24738311047776, -1.24738311047776, -1.24738311047776,
-1.28564738896258, -1.28564738896258, -1.28564738896258, -1.30225611704836,
-1.30225611704836, -1.30225611704836, -1.17181860494129, -1.17181860494129,
-1.17181860494129, -1.15687952410288, -1.15687952410288, -1.15687952410288,
-1.12078874426169, -1.12078874426169, -1.12078874426169, -1.12194837414298,
-1.12194837414298, -1.12194837414298, -1.1119085686834, -1.1119085686834,
-1.1119085686834, -1.11460209275208, -1.11460209275208, -1.11460209275208,
-1.14030482631462, -1.14030482631462, -1.14030482631462, -1.25693845068723,
-1.25693845068723, -1.25693845068723, -1.29636270710907, -1.29636270710907,
-1.29636270710907, -1.28630939351124, -1.28630939351124, -1.28630939351124,
-1.34123496736839, -1.34123496736839, -1.34123496736839, -1.30208113084414,
-1.30208113084414, -1.30208113084414, -1.27472858798502, -1.27472858798502,
-1.27472858798502, -1.2601313178257, -1.2601313178257, -1.2601313178257,
-1.25435070950356, -1.25435070950356, -1.25435070950356, -1.25446776571291,
-1.25446776571291, -1.25446776571291, -1.31782396761758, -1.31782396761758,
-1.31782396761758, -1.32404892123336, -1.32404892123336, -1.32404892123336,
-1.35533362583485, -1.35533362583485, -1.35533362583485, -1.32224476611552,
-1.32224476611552, -1.32224476611552, -1.37165859726789, -1.37165859726789,
-1.37165859726789, -1.32061051911721, -1.32061051911721, -1.32061051911721,
-1.26156328360682, -1.26156328360682, -1.26156328360682, -1.26156328360682,
-1.26156328360682, NA, NA)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -123L))
What I want is to rank every value 0 to 10, where 0 should equal the highest value (-0.9759783) and 10 should be the lowest value (-1.37166). Everything in between should be ranked linearly so that, for example, -1.25693845068723 should yield 7.1 and so on.
Thanks in advance.

Linear Regression Analysis of population data with R

I have a homework assignment where I need to take a CSV file based around population data around the United States and do some data analysis on the data inside. I need to find the data that exists for my state and for starters run a Linear Regression Analysis to predict the size of the population.
I've been studying R for a few weeks now, went through a LinkedIn Learning training, as well as 2 different trainings on pluralsight about R. I have also tried searching for how to do a Linear Regression Analysis in R and I find plenty of examples for how to do it when the data is perfectly laid out in a table in just the right way to Analyze.
The CSV file is laid out so that each state is defined on a single line/row so I used the filter function to grab just the data for my State and put it into a variable.
Within that dataset the population data is defined across several columns with the most important data being the Population Estimates for each year from 2010 to 2018.
library(tidyverse)
population.data <- read_csv("nst-est2018-alldata.csv")
mn.state.data <- filter(population.data, NAME == "Minnesota")
I'm looking for some help to get headed in the right direction my thought is that I will need to create to containers of data 1 having each year from 2010 to 2018 and one that contains the population data for each of those years. And then use the xyplot function with those two containers? If you have some experience in this area please help me think this through I'm not looking for anybody to do the assignment for me just want some help trying to think it through.
Edit: Here is the results of the
dput(head(population.data))
command:
structure(list(SUMLEV = c("010", "020", "020", "020", "020",
"040"), REGION = c("0", "1", "2", "3", "4", "3"), DIVISION = c("0",
"0", "0", "0", "0", "6"), STATE = c("00", "00", "00", "00", "00",
"01"), NAME = c("United States", "Northeast Region", "Midwest Region",
"South Region", "West Region", "Alabama"), CENSUS2010POP = c(308745538L,
55317240L, 66927001L, 114555744L, 71945553L, 4779736L), ESTIMATESBASE2010
= c(308758105L,
55318430L, 66929743L, 114563045L, 71946887L, 4780138L), POPESTIMATE2010 =
c(309326085L,
55380645L, 66974749L, 114867066L, 72103625L, 4785448L), POPESTIMATE2011 =
c(311580009L,
55600532L, 67152631L, 116039399L, 72787447L, 4798834L), POPESTIMATE2012 =
c(313874218L,
55776729L, 67336937L, 117271075L, 73489477L, 4815564L), POPESTIMATE2013 =
c(316057727L,
55907823L, 67564135L, 118393244L, 74192525L, 4830460L), POPESTIMATE2014 =
c(318386421L,
56015864L, 67752238L, 119657737L, 74960582L, 4842481L), POPESTIMATE2015 =
c(320742673L,
56047587L, 67869139L, 121037542L, 75788405L, 4853160L), POPESTIMATE2016 =
c(323071342L,
56058789L, 67996917L, 122401186L, 76614450L, 4864745L), POPESTIMATE2017 =
c(325147121L,
56072676L, 68156035L, 123598424L, 77319986L, 4875120L), POPESTIMATE2018 =
c(327167434L,
56111079L, 68308744L, 124753948L, 77993663L, 4887871L), NPOPCHG_2010 =
c(567980L,
62215L, 45006L, 304021L, 156738L, 5310L), NPOPCHG_2011 = c(2253924L,
219887L, 177882L, 1172333L, 683822L, 13386L), NPOPCHG_2012 = c(2294209L,
176197L, 184306L, 1231676L, 702030L, 16730L), NPOPCHG_2013 = c(2183509L,
131094L, 227198L, 1122169L, 703048L, 14896L), NPOPCHG_2014 = c(2328694L,
108041L, 188103L, 1264493L, 768057L, 12021L), NPOPCHG_2015 = c(2356252L,
31723L, 116901L, 1379805L, 827823L, 10679L), NPOPCHG_2016 = c(2328669L,
11202L, 127778L, 1363644L, 826045L, 11585L), NPOPCHG_2017 = c(2075779L,
13887L, 159118L, 1197238L, 705536L, 10375L), NPOPCHG_2018 = c(2020313L,
38403L, 152709L, 1155524L, 673677L, 12751L), BIRTHS2010 = c(987836L,
163454L, 212614L, 368752L, 243016L, 14227L), BIRTHS2011 = c(3973485L,
646265L, 834909L, 1509597L, 982714L, 59689L), BIRTHS2012 = c(3936976L,
637904L, 830701L, 1504936L, 963435L, 59070L), BIRTHS2013 = c(3940576L,
635741L, 830869L, 1504799L, 969167L, 57936L), BIRTHS2014 = c(3963195L,
632433L, 836505L, 1525280L, 968977L, 58907L), BIRTHS2015 = c(3992376L,
634515L, 837968L, 1545722L, 974171L, 59637L), BIRTHS2016 = c(3962654L,
628039L, 831667L, 1541342L, 961606L, 59388L), BIRTHS2017 = c(3901982L,
616552L, 816177L, 1519944L, 949309L, 58259L), BIRTHS2018 = c(3855500L,
609336L, 804431L, 1499838L, 941895L, 57216L), DEATHS2010 = c(598691L,
110848L, 140785L, 228706L, 118352L, 11073L), DEATHS2011 = c(2512442L,
470816L, 586840L, 962751L, 492035L, 48818L), DEATHS2012 = c(2501531L,
460985L, 584817L, 960575L, 495154L, 48364L), DEATHS2013 = c(2608019L,
480032L, 605188L, 1011093L, 511706L, 50847L), DEATHS2014 = c(2582448L,
470196L, 597078L, 1006057L, 509117L, 49692L), DEATHS2015 = c(2699826L,
488881L, 626494L, 1052360L, 532091L, 51820L), DEATHS2016 = c(2703215L,
480331L, 619471L, 1058173L, 545240L, 51662L), DEATHS2017 = c(2779436L,
501022L, 620556L, 1092949L, 564909L, 53033L), DEATHS2018 = c(2814013L,
506909L, 621030L, 1109152L, 576922L, 53425L), NATURALINC2010 = c(389145L,
52606L, 71829L, 140046L, 124664L, 3154L), NATURALINC2011 = c(1461043L,
175449L, 248069L, 546846L, 490679L, 10871L), NATURALINC2012 = c(1435445L,
176919L, 245884L, 544361L, 468281L, 10706L), NATURALINC2013 = c(1332557L,
155709L, 225681L, 493706L, 457461L, 7089L), NATURALINC2014 = c(1380747L,
162237L, 239427L, 519223L, 459860L, 9215L), NATURALINC2015 = c(1292550L,
145634L, 211474L, 493362L, 442080L, 7817L), NATURALINC2016 = c(1259439L,
147708L, 212196L, 483169L, 416366L, 7726L), NATURALINC2017 = c(1122546L,
115530L, 195621L, 426995L, 384400L, 5226L), NATURALINC2018 = c(1041487L,
102427L, 183401L, 390686L, 364973L, 3791L), INTERNATIONALMIG2010 =
c(178835L,
45723L, 25158L, 68742L, 39212L, 928L), INTERNATIONALMIG2011 = c(792881L,
206686L, 116948L, 285343L, 183904L, 4716L), INTERNATIONALMIG2012 =
c(858764L,
207584L, 120995L, 344198L, 185987L, 5874L), INTERNATIONALMIG2013 =
c(850952L,
194103L, 126681L, 329897L, 200271L, 5111L), INTERNATIONALMIG2014 =
c(947947L,
222685L, 134310L, 365281L, 225671L, 3753L), INTERNATIONALMIG2015 =
c(1063702L,
227275L, 142759L, 429088L, 264580L, 4685L), INTERNATIONALMIG2016 =
c(1069230L,
236718L, 144859L, 436795L, 250858L, 5950L), INTERNATIONALMIG2017 =
c(953233L,
215872L, 126013L, 404582L, 206766L, 3190L), INTERNATIONALMIG2018 =
c(978826L,
229700L, 127583L, 418418L, 203125L, 3344L), DOMESTICMIG2010 = c(0L,
-32918L, -50873L, 90679L, -6888L, 1238L), DOMESTICMIG2011 = c(0L,
-159789L, -186896L, 335757L, 10928L, -2239L), DOMESTICMIG2012 = c(0L,
-205314L, -181285L, 336615L, 49984L, 59L), DOMESTICMIG2013 = c(0L,
-216273L, -123814L, 293443L, 46644L, 2641L), DOMESTICMIG2014 = c(0L,
-274391L, -182730L, 373439L, 83682L, -755L), DOMESTICMIG2015 = c(0L,
-339996L, -234823L, 452879L, 121940L, -1553L), DOMESTICMIG2016 = c(0L,
-372953L, -228200L, 442633L, 158520L, -1977L), DOMESTICMIG2017 = c(0L,
-316879L, -161387L, 364465L, 113801L, 2065L), DOMESTICMIG2018 = c(0L,
-292928L, -157048L, 345132L, 104844L, 5718L), NETMIG2010 = c(178835L,
12805L, -25715L, 159421L, 32324L, 2166L), NETMIG2011 = c(792881L,
46897L, -69948L, 621100L, 194832L, 2477L), NETMIG2012 = c(858764L,
2270L, -60290L, 680813L, 235971L, 5933L), NETMIG2013 = c(850952L,
-22170L, 2867L, 623340L, 246915L, 7752L), NETMIG2014 = c(947947L,
-51706L, -48420L, 738720L, 309353L, 2998L), NETMIG2015 = c(1063702L,
-112721L, -92064L, 881967L, 386520L, 3132L), NETMIG2016 = c(1069230L,
-136235L, -83341L, 879428L, 409378L, 3973L), NETMIG2017 = c(953233L,
-101007L, -35374L, 769047L, 320567L, 5255L), NETMIG2018 = c(978826L,
-63228L, -29465L, 763550L, 307969L, 9062L), RESIDUAL2010 = c(0L,
-3196L, -1108L, 4554L, -250L, -10L), RESIDUAL2011 = c(0L, -2459L,
-239L, 4387L, -1689L, 38L), RESIDUAL2012 = c(0L, -2992L, -1288L,
6502L, -2222L, 91L), RESIDUAL2013 = c(0L, -2445L, -1350L, 5123L,
-1328L, 55L), RESIDUAL2014 = c(0L, -2490L, -2904L, 6550L, -1156L,
-192L), RESIDUAL2015 = c(0L, -1190L, -2509L, 4476L, -777L, -270L
), RESIDUAL2016 = c(0L, -271L, -1077L, 1047L, 301L, -114L), RESIDUAL2017 =
c(0L,
-636L, -1129L, 1196L, 569L, -106L), RESIDUAL2018 = c(0L, -796L,
-1227L, 1288L, 735L, -102L), RBIRTH2011 = c(12.79898857, 11.646389369,
12.449493906, 13.0753983, 13.564866164, 12.455601786), RBIRTH2012 =
c(12.589173852,
11.454833676, 12.353389372, 12.900715293, 13.172754439, 12.287820829
), RBIRTH2013 = c(12.511116578, 11.384582534, 12.318197145, 12.770698648,
13.1250523, 12.012410502), RBIRTH2014 = c(12.493440163, 11.301146646,
12.363692308, 12.814734, 12.993051496, 12.179749675), RBIRTH2015 =
c(12.493175596,
11.324209532, 12.357461907, 12.843808208, 12.92441189, 12.301816868
), RBIRTH2016 = c(12.309933949, 11.20434042, 12.242454436, 12.663079639,
12.619264908, 12.222387438), RBIRTH2017 = c(12.039095529, 10.996948983,
11.989119413, 12.357287884, 12.333939366, 11.962999487), RBIRTH2018 =
c(11.820984126,
10.863177115, 11.789576855, 12.078306222, 12.128940451, 11.720998206
), RDEATH2011 = c(8.0928244199, 8.4846099623, 8.7504877826, 8.3388830191,
6.7917918366, 10.187095914), RDEATH2012 = c(7.9990857588, 8.2779015368,
8.6968381072, 8.2343067033, 6.7700904074, 10.060744313), RDEATH2013 =
c(8.2803198685,
8.5962112289, 8.9723230665, 8.5807898649, 6.9298356343, 10.542582104
), RDEATH2014 = c(8.1408206164, 8.4020820365, 8.8249187702, 8.4524499397,
6.8267702932, 10.274434632), RDEATH2015 = c(8.4484528254, 8.7250748685,
9.2388679994, 8.7443343664, 7.0592978512, 10.689339673), RDEATH2016 =
c(8.3975028099,
8.5692003816, 9.1188486402, 8.6935469035, 7.1552465339, 10.632332792
), RDEATH2017 = c(8.5756150392, 8.9363320099, 9.1155717285, 8.8857783149,
7.3396052849, 10.889883997), RDEATH2018 = c(8.6277792774, 9.0371195009,
9.1016891619, 8.9320830002, 7.4291216994, 10.944391939), RNATURALINC2011 =
c(4.7061641498,
3.161779407, 3.6990061239, 4.7365152812, 6.7730743272, 2.2685058724
), RNATURALINC2012 = c(4.5900880929, 3.1769321388, 3.656551265,
4.66640859, 6.402664032, 2.2270765159), RNATURALINC2013 = c(4.2307967093,
2.7883713049, 3.3458740787, 4.1899087829, 6.1952166656, 1.4698283977
), RNATURALINC2014 = c(4.3526195469, 2.89906461, 3.5387735378,
4.3622840605, 6.1662812026, 1.9053150433), RNATURALINC2015 =
c(4.0447227708,
2.5991346635, 3.1185939072, 4.0994738414, 5.8651140389, 1.6124771946
), RNATURALINC2016 = c(3.912431139, 2.6351400388, 3.123605796,
3.969532736, 5.4640183742, 1.5900546466), RNATURALINC2017 =
c(3.4634804902,
2.0606169731, 2.8735476848, 3.4715095687, 4.9943340813, 1.0731154898
), RNATURALINC2018 = c(3.1932048488, 1.8260576141, 2.687887693,
3.1462232219, 4.6998187519, 0.7766062675), RINTERNATIONALMIG2011 =
c(2.5539481982,
3.7247036946, 1.7438348531, 2.4715029092, 2.5385138982, 0.9841112772
), RINTERNATIONALMIG2012 = c(2.7460490726, 3.7275831375, 1.7993217139,
2.9505576333, 2.5429438207, 1.2219173785), RINTERNATIONALMIG2013 =
c(2.7017267715,
3.4759149144, 1.8781318506, 2.7997195452, 2.7121923767, 1.0597112344
), RINTERNATIONALMIG2014 = c(2.988275652, 3.9792291689, 1.9851256285,
3.0689308523, 3.0260314993, 0.7759790947), RINTERNATIONALMIG2015 =
c(3.3285982753,
4.0561842059, 2.1052580818, 3.5654043717, 3.5102060089, 0.9664136698
), RINTERNATIONALMIG2016 = c(3.3215493142, 4.2230961065, 2.1323795548,
3.5885415898, 3.2920380658, 1.2245437674), RINTERNATIONALMIG2017 =
c(2.9410856198,
3.8503376372, 1.8510505744, 3.2892897676, 2.6864164429, 0.6550398799
), RINTERNATIONALMIG2018 = c(3.0010858795, 4.0950670621, 1.8698304564,
3.3695510667, 2.6156748143, 0.685035969), RDOMESTICMIG2011 = c(0,
-2.879569389, -2.786843372, 2.9081645678, 0.1508443529, -0.467223314
), RDOMESTICMIG2012 = c(0, -3.686820778, -2.69589683, 2.8855541222,
0.6834160664, 0.0122732593), RDOMESTICMIG2013 = c(0, -3.872925953,
-1.835626629, 2.4903472978, 0.6316815776, 0.5475831286), RDOMESTICMIG2014
= c(0,
-4.903180146, -2.700781819, 3.1374707924, 1.1220952977, -0.156105573
), RDOMESTICMIG2015 = c(0, -6.067919504, -3.462920156, 3.7630900106,
1.6177886489, -0.320350145), RDOMESTICMIG2016 = c(0, -6.653555548,
-3.359190761, 3.6365043774, 2.0802759896, -0.40687782), RDOMESTICMIG2017 =
c(0,
-5.651919379, -2.370672066, 2.963134779, 1.4785645494, 0.4240305179
), RDOMESTICMIG2018 = c(0, -5.222289092, -2.301663494, 2.7793734944,
1.350093835, 1.1713623417), RNETMIG2011 = c(2.5539481982, 0.845134306,
-1.043008519, 5.379667477, 2.6893582511, 0.516887963), RNETMIG2012 =
c(2.7460490726,
0.0407623599, -0.896575116, 5.8361117555, 3.2263598871, 1.2341906378
), RNETMIG2013 = c(2.7017267715, -0.397011039, 0.0425052219,
5.2900668429, 3.3438739543, 1.6072943629), RNETMIG2014 = c(2.988275652,
-0.923950977, -0.71565619, 6.2064016447, 4.148126797, 0.6198735214
), RNETMIG2015 = c(3.3285982753, -2.011735298, -1.357662074,
7.3284943823, 5.1279946578, 0.6460635248), RNETMIG2016 = c(3.3215493142,
-2.430459441, -1.226811206, 7.2250459672, 5.3723140554, 0.8176659475
), RNETMIG2017 = c(2.9410856198, -1.801581742, -0.519621492,
6.2524245465, 4.1649809923, 1.0790703978), RNETMIG2018 = c(3.0010858795,
-1.12722203, -0.431833037, 6.1489245611, 3.9657686492, 1.8563983107
)), .Names = c("SUMLEV", "REGION", "DIVISION", "STATE", "NAME",
"CENSUS2010POP", "ESTIMATESBASE2010", "POPESTIMATE2010",
"POPESTIMATE2011",
"POPESTIMATE2012", "POPESTIMATE2013", "POPESTIMATE2014",
"POPESTIMATE2015",
"POPESTIMATE2016", "POPESTIMATE2017", "POPESTIMATE2018", "NPOPCHG_2010",
"NPOPCHG_2011", "NPOPCHG_2012", "NPOPCHG_2013", "NPOPCHG_2014",
"NPOPCHG_2015", "NPOPCHG_2016", "NPOPCHG_2017", "NPOPCHG_2018",
"BIRTHS2010", "BIRTHS2011", "BIRTHS2012", "BIRTHS2013", "BIRTHS2014",
"BIRTHS2015", "BIRTHS2016", "BIRTHS2017", "BIRTHS2018", "DEATHS2010",
"DEATHS2011", "DEATHS2012", "DEATHS2013", "DEATHS2014", "DEATHS2015",
"DEATHS2016", "DEATHS2017", "DEATHS2018", "NATURALINC2010",
"NATURALINC2011",
"NATURALINC2012", "NATURALINC2013", "NATURALINC2014", "NATURALINC2015",
"NATURALINC2016", "NATURALINC2017", "NATURALINC2018",
"INTERNATIONALMIG2010",
"INTERNATIONALMIG2011", "INTERNATIONALMIG2012", "INTERNATIONALMIG2013",
"INTERNATIONALMIG2014", "INTERNATIONALMIG2015", "INTERNATIONALMIG2016",
"INTERNATIONALMIG2017", "INTERNATIONALMIG2018", "DOMESTICMIG2010",
"DOMESTICMIG2011", "DOMESTICMIG2012", "DOMESTICMIG2013",
"DOMESTICMIG2014",
"DOMESTICMIG2015", "DOMESTICMIG2016", "DOMESTICMIG2017",
"DOMESTICMIG2018",
"NETMIG2010", "NETMIG2011", "NETMIG2012", "NETMIG2013", "NETMIG2014",
"NETMIG2015", "NETMIG2016", "NETMIG2017", "NETMIG2018", "RESIDUAL2010",
"RESIDUAL2011", "RESIDUAL2012", "RESIDUAL2013", "RESIDUAL2014",
"RESIDUAL2015", "RESIDUAL2016", "RESIDUAL2017", "RESIDUAL2018",
"RBIRTH2011", "RBIRTH2012", "RBIRTH2013", "RBIRTH2014", "RBIRTH2015",
"RBIRTH2016", "RBIRTH2017", "RBIRTH2018", "RDEATH2011", "RDEATH2012",
"RDEATH2013", "RDEATH2014", "RDEATH2015", "RDEATH2016", "RDEATH2017",
"RDEATH2018", "RNATURALINC2011", "RNATURALINC2012", "RNATURALINC2013",
"RNATURALINC2014", "RNATURALINC2015", "RNATURALINC2016",
"RNATURALINC2017",
"RNATURALINC2018", "RINTERNATIONALMIG2011", "RINTERNATIONALMIG2012",
"RINTERNATIONALMIG2013", "RINTERNATIONALMIG2014", "RINTERNATIONALMIG2015",
"RINTERNATIONALMIG2016", "RINTERNATIONALMIG2017", "RINTERNATIONALMIG2018",
"RDOMESTICMIG2011", "RDOMESTICMIG2012", "RDOMESTICMIG2013",
"RDOMESTICMIG2014",
"RDOMESTICMIG2015", "RDOMESTICMIG2016", "RDOMESTICMIG2017",
"RDOMESTICMIG2018",
"RNETMIG2011", "RNETMIG2012", "RNETMIG2013", "RNETMIG2014", "RNETMIG2015",
"RNETMIG2016", "RNETMIG2017", "RNETMIG2018"), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
In order to help you out, an example data using dput(head(population.data)) would be helpful. Based on your comments, your data is in what is called 'wide' format, meaning each observation is contained in a column, rather than a row (pupulation 2010, population 2011 etc.).
As i hinted in my comment, a sub-goal within statistical modelling is always to clean and reshape data to a proper format, that will work for running models. In this case the problem is that your format is in an incorrect shape. The most common is likely melting to long format via the reshape2 or data.table package as explained in this link. I personally prefer the data.table package, as it seems to have better large scale performance. Their usage however is identical.
Lets say you have a column 'NAME' for states and 9 columns for population estimates (2010 population estimates, 2011 population estimates and so on), we could then convert these columns into a long format, using melt from either of the two suggested packages (They are identical in use)
require(data.table)
value_columns <- paste(2010:2018, "Population Estimates")
population.data_long <- melt(population.data, id.vars = "NAME",
measure.vars = value_columns, #Columns containing values we (that are grouped by their column names)
variable.name = 'Year (Population Estimate)', #Name of the column which tells us [(Year) Population Estimate]
value.name = 'Population Estimate') #Name of the column with values
population.data_long$year <- as.integer(substr(population.data_long$`Year (Population Estimate)`, 1, 4)) #Create a year column in a bit of a hacky way
Note i have ignored any additional columns, and these should be included in your melt statement. From here on a linear regression should follow any standard example that you have found.

Plotting Curves from Data Frame Columns

i am facing a problem in plot ols estimations in a scatterplot:
I have this data frame: With 9 columns and 99 rows:
structure(list(Y = c(-0.145442175, 0.291096141, 0.489923112,
-2.038363166, 1.180430664, 0.188114666, 0.850922634, 1.172142766,
-3.980837975, 0.285762444, 2.497040646, 0.658010994, -0.925171981,
0.37076995, -1.108211119, -0.409242669, -1.234583525, -0.385841816,
0.016744771, -0.584406288, 1.17224811, -0.746804388, -0.625028046,
0.257871468, -2.735845346, 2.619304857, -0.406825232, 0.323665151,
2.218951363, -0.821029648, -0.872854889, -2.663306158, -0.121976044,
0.881566376, -1.972706678, -3.855576256, 2.927421113, 1.314753531,
0.234296206, 0.828464757, -0.909318569, 0.616134903, -0.567630403,
0.624571064, -0.414112923, 0.642200314, -0.309421266, 0.195312598,
-0.519988256, 0, 0.081070175, 0.032446432, -0.534025032, -0.426783307,
-0.38495511, -0.207900219, -1.953789746, -0.616924355, -0.783222881,
-1.935420969, 0.638445535, 1.080925923, -1.598076681, 0.25063631,
-0.697183766, 0.188971653, -0.415267389, -4.154506044, 1.163226552,
0.036569698, -0.547147074, 1.11937374, 0.383311682, -0.875037781,
-0.372684863, 0.306816004, -1.250561544, -1.042237738, -1.757788446,
0.021079982, 1.844023775, 1.674645753, -0.428546132, -0.527705597,
0.542202572, -0.621479123, -0.050415867, -0.122332943, 0.468553764,
0.216998274, 3.088480781, 0.434099931, 2.114916704, -2.407018936,
-0.127060127, 0.546756422, 0.263207486, 0.63453915, 0.76832746
), X = c(0.009476137, -0.0236354, 0.0094081, 0.11715252, 0.032324021,
0.0461193, 0.050794971, 0.032372819, 0.202121874, 0.390821859,
-0.124492596, -0.127305193, -0.22233597, -0.081113713, 0.09952616,
0.22494711, 0.226621495, 0.411607624, 0.089200478, -0.013454832,
-0.013547165, -0.232366214, 0.03140992, -0.026798837, -0.084556341,
-0.091993172, -0.303730207, -0.236679148, -0.284235285, -0.355253166,
-0.179645537, -0.01381843, -0.022950244, -0.050065976, -0.032018504,
-0.087168055, -0.081865767, -0.253991077, -0.242882759, -0.150225053,
-0.16596575, -0.156887247, -0.071795146, -0.100408802, -0.067307731,
0.024006869, -0.019250912, -0.02399429, 0.038421097, 0.062320065,
0.07187025, 0.024019462, 0.038421097, 0.033539309, 0.014351457,
-0.009575137, 0.014343968, 0.028561284, 0.0404213, 0.026065697,
-0.004700435, -0.072739794, -0.042217496, -0.05889531, -0.130522139,
-0.136291869, -0.120099035, -0.091418565, -0.122040844, -0.124609029,
-0.096255449, -0.190338762, -0.11611752, -0.055598423, -0.065293448,
-0.038746326, -0.029090518, -0.067627348, -0.082097445, -0.215845836,
-0.389993696, -0.264371785, -0.126530291, -0.111840985, -0.094952196,
-0.136700196, -0.190968195, -0.156564122, -0.181077278, -0.15381292,
-0.122020692, -0.107867301, -0.068642333, -0.034348677, -0.073289926,
-0.063314884, -0.092537576, -0.165375956, -0.15042398), Null = c(-0.036795117836493,
0.0120555676565338, -0.0366906491623935, -0.22323992930528, -0.0728300398338213,
-0.0955073599141197, -0.103350601084975, -0.0729090354522075,
-0.400153521158964, -0.887015257107641, 0.1362666683468, 0.13919994231771,
0.221388292373518, 0.087380368104602, -0.189831042487278, -0.452154909992189,
-0.456044210600938, -0.948567833126862, -0.170785020294756, -0.00253939338337472,
-0.00240533038312774, 0.228145471304061, -0.0713518661553421,
0.0165138860659871, 0.0915102566139487, 0.100284493544177, 0.265652059802101,
0.230938443729295, 0.257246215885006, 0.281209408151878, 0.188533028671265,
-0.00201164134414489, 0.0110851592192505, 0.0481858583559124,
0.0237904823161768, 0.094614581053392, 0.0882862377341187, 0.241468070168396,
0.234837060900023, 0.162029971029324, 0.176601607696189, 0.168307425791361,
0.0759851164110966, 0.109970788582389, 0.0703849242291975, -0.059492586621119,
0.00581616568295407, 0.0125631925046972, -0.0827672867080164,
-0.123023227393077, -0.139691063870559, -0.0595125909296922,
-0.0827672867080164, -0.074799966578053, -0.044324863847201,
-0.00820062690976645, -0.0443132308515717, -0.0667648997869916,
-0.0860567642206439, -0.0627706942069095, -0.0153914247452083,
0.0771546773236518, 0.0377224646820258, 0.0596889425617937, 0.1425196179012,
0.148379247725525, 0.13162698340227, 0.0996137276510431, 0.133686233062275,
0.136388667637584, 0.105222539655097, 0.197385328960716, 0.127361748973716,
0.0554268640818151, 0.0678473149754353, 0.0330232883757411, 0.0197208677278167,
0.0707862239701058, 0.0885648870712001, 0.216820906265572, 0.286245951224793,
0.247258814186372, 0.138394666330137, 0.122716205945161, 0.103719679674083,
0.148789344619283, 0.197893429730301, 0.168006688568371, 0.189742414352596,
0.165430712615822, 0.133664933948451, 0.11833998959919, 0.0720581343490991,
0.0270069004188009, 0.077834296346802, 0.0653403280475977, 0.100918894574441,
0.176071877748707, 0.162219750035618), OLS_1 = c(-2.97674658085357,
-2.95792547866683, -2.97674412477729, -2.7937460366665, -2.96913739819288,
-2.95639989365184, -2.95069150171007, -2.96910314906723, -2.3856485268894,
-0.647452287114872, -2.68293610049662, -2.670570393744, -2.10297963546522,
-2.84137496711892, -2.84927190111917, -2.23638642750757, -2.22477621905134,
-0.385841816000001, -2.87715002139054, -2.96747293407547, -2.96740133507642,
-2.02609643038743, -2.9697648045679, -2.95427875550959, -2.8310157181346,
-2.80733412921436, -1.38551048535346, -1.99204069101103, -1.57679230211392,
-0.821029648, -2.39395151432173, -2.96718943992586, -2.95867282134313,
-2.9175506236826, -2.94755679517459, -2.82290206987746, -2.83914454134393,
-1.84931168689084, -1.94200482386918, -2.56030139156351, -2.4747687889082,
-2.52507434784403, -2.86749990988846, -2.77838660436577, -2.87908253396987,
-2.97385415360498, -2.96244666805069, -2.95752797222193, -2.96426392038595,
-2.93361303993881, -2.91621877029975, -2.97384869333029, -2.96426392038595,
-2.96826157356433, -2.97653443074828, -2.97023260580068, -2.97653534550966,
-2.9715473503959, -2.96240424133875, -2.97289412424858, -2.9730125951007,
-2.86497897723402, -2.93188917574701, -2.89904800305061, -2.6561144854951,
-2.62935195635151, -2.70174255054932, -2.80922741244202, -2.69350740105694,
-2.68242924921473, -2.79295820376613, -2.32657978700299, -2.718248099245,
-2.90625073580661, -2.88407071600265, -2.93759776247538, -2.95143559806685,
-2.87827902655775, -2.83845377816351, -2.15100018436527, -0.392139380784325,
-1.7590965971582, -2.67400272569948, -2.73540774982849, -2.79741598960129,
-2.62741730304073, -2.322499279269, -2.52681590220219, -2.38514457172383,
-2.541507865502, -2.6935934995898, -2.75082409521646, -2.87570553083222,
-2.94427256930162, -2.86349763526591, -2.88884317216564, -2.80553055841713,
-2.47811758528604, -2.55927025907886), OLS_2 = c(-2.83865555876367,
-2.82203271957637, -2.83865550287755, -2.66277932892391, -2.83073328950317,
-2.8182826854432, -2.81275284604234, -2.83069942358793, -2.27571536741022,
-0.632851535784811, -2.56646067709365, -2.55491098827374, -2.02364579120999,
-2.71420058960775, -2.71564453925406, -2.13442002502496, -2.12343285482248,
-0.385841816, -2.74223576659719, -2.83068449367348, -2.83062014186059,
-1.95158880862936, -2.83135434505306, -2.81870405841395, -2.70456098525177,
-2.68251016192609, -1.35080974869909, -1.91966655284606, -1.53026524143009,
-0.821029648, -2.29619548286091, -2.83042962848176, -2.82271365766308,
-2.78489427206998, -2.81254809712918, -2.69700817487578, -2.71212546804251,
-1.78585373408616, -1.87276085874404, -2.45184700668681, -2.37183555552258,
-2.41889982491589, -2.73848954857785, -2.65553364194069, -2.74924637290594,
-2.8354502300085, -2.82614423798244, -2.82167034953476, -2.82594242161564,
-2.7962902949221, -2.77959589724382, -2.83544467118397, -2.82594242161564,
-2.82986834510621, -2.83829410413293, -2.83315419155684, -2.83829521382395,
-2.83312719078141, -2.82412509152621, -2.83447802392599, -2.83561001727694,
-2.73614728712302, -2.79813447119318, -2.76776591170989, -2.54140667394362,
-2.5163996858597, -2.58402223424852, -2.68427373122372, -2.57633280462435,
-2.56598731123967, -2.66911582708562, -2.23311605677819, -2.59943103595799,
-2.7744383205277, -2.75387620457868, -2.80339428073398, -2.81610308322424,
-2.74850042856033, -2.71148276169435, -2.06864445166113, -0.418358709691658,
-1.7012556906544, -2.558117011201, -2.61544592452239, -2.67326984561107,
-2.5145916492569, -2.22929491666958, -2.42052887445801, -2.28795076147412,
-2.43427089501948, -2.57641320261571, -2.62982944259216, -2.74611100908034,
-2.80953310903525, -2.73477077084888, -2.75830410348864, -2.68083005992821,
-2.37496906485549, -2.4508827380889), OLS_3 = c(-2.58083646581942,
-2.5683178338716, -2.58084089114316, -2.41826149362172, -2.57232965672457,
-2.56041470241702, -2.55521822468909, -2.57229650627193, -2.0704676472292,
-0.605591599496051, -2.34899840070827, -2.33897223601076, -1.87552769159633,
-2.47676312148376, -2.46615920192222, -1.94404642215785, -1.9342224786085,
-0.385841816000001, -2.49034777076914, -2.57529735049815, -2.57524652934739,
-1.81248137667339, -2.57293885513887, -2.56558300171966, -2.46846711008925,
-2.44946096338359, -1.28602268062379, -1.78454238349805, -1.4433981562183,
-0.821029648, -2.11368273887782, -2.57509593622485, -2.56887479307252,
-2.53722183306237, -2.56048377359198, -2.46196139684977, -2.47497795642607,
-1.66737628649693, -1.7434807939705, -2.24936019247138, -2.17965685727221,
-2.22066956504207, -2.49762425675709, -2.42616435450559, -2.50683929408026,
-2.57704694280319, -2.57166448720316, -2.56802106429762, -2.56769302344379,
-2.53990559282486, -2.52451787208599, -2.57704119998386, -2.56769302344379,
-2.57148502596854, -2.58019625622877, -2.57722566059429, -2.58019772985789,
-2.57469359055957, -2.56595475982599, -2.57605200249485, -2.57907626550515,
-2.49561557851369, -2.54841138215235, -2.52265924802504, -2.32724456926626,
-2.30551521644622, -2.36423571438323, -2.45098235381054, -2.35756515622,
-2.3485875529132, -2.43789928063234, -2.05861713726078, -2.37759686441414,
-2.52834152993493, -2.51080007744427, -2.55283331443161, -2.56343418632904,
-2.50620082129485, -2.47442497328161, -1.91488441727801, -0.467310795744689,
-1.59326539683083, -2.34175573481226, -2.39147445613669, -2.44148615865099,
-2.30394357612981, -2.05528024243402, -2.22208856552246, -2.10648769733616,
-2.23405702128991, -2.35763491117015, -2.40392966200837, -2.50415507637054,
-2.55797145858227, -2.49443477420494, -2.51458468009137, -2.44801138045477,
-2.18238842077399, -2.24852076027753), OLS_4 = c(-2.4289478285331,
-2.41681903415288, -2.42895104301202, -2.27867081965274, -2.4213161496905,
-2.41038194422522, -2.40559515788832, -2.42128586809391, -1.95522949388955,
-0.590647453749078, -2.21077815389366, -2.20138321248198, -1.76758669368012,
-2.33060054299992, -2.32313500877883, -1.83755181381677, -1.82840597739465,
-0.385841816, -2.34557046847711, -2.42346978407977, -2.42342111188123,
-1.70861264386732, -2.42187239429871, -2.41422413566286, -2.32281181955877,
-2.30497392699143, -1.21632553238408, -1.68248005204524, -1.36346128591018,
-0.781669317752002, -1.99042352676657, -2.42327691796255, -2.41734804581689,
-2.38744248609079, -2.40939495374384, -2.31670510436427, -2.32892438647688,
-1.57289978140148, -1.64407512538075, -2.11744278294415, -2.05217911016675,
-2.09057710272701, -2.35019495754122, -2.28311871426765, -2.35885543710246,
-2.42560672084754, -2.42000135641999, -2.4165372393818, -2.41707097497419,
-2.39145946177805, -2.3772271125231, -2.42560153071694, -2.41707097497419,
-2.420544236609, -2.42841594588832, -2.4253216199613, -2.42841722040367,
-2.42347169955882, -2.41547562547196, -2.42470587973943, -2.4271143253132,
-2.34830761179908, -2.39799094116799, -2.37373288731684, -2.19039487337143,
-2.17003793409615, -2.22505776553193, -2.30640152341961, -2.21880622042115,
-2.21039315621698, -2.294126428977, -1.93888869626962, -2.23758086989921,
-2.37908034073483, -2.36257901260101, -2.4021644964107, -2.41218787827608,
-2.35825527028976, -2.3284051877118, -1.80440438182757, -0.451087514089169,
-1.50359480720157, -2.20399138892979, -2.25058992243427, -2.29749148286179,
-2.16856567860513, -1.93576601076367, -2.09190575790345, -1.98368936201681,
-2.10311255036163, -2.21887159162467, -2.26226743315126, -2.35633238493592,
-2.407018936, -2.34719820268328, -2.36613768370737, -2.30361375259329,
-2.05473632620086, -2.11665669129059), OLS_5 = c(-2.2911912568638,
-2.28123967681215, -2.29119683586224, -2.14805590207021, -2.28325670505768,
-2.27261386268403, -2.268006850245, -2.28322682471889, -1.84560662105751,
-0.576090713535621, -2.0945064647732, -2.0859234999636, -1.68828464788266,
-2.20368547406672, -2.18986194988925, -1.73587625378362, -1.72735189094969,
-0.385841816, -2.21101101562234, -2.28700200417098, -2.28696051646281,
-1.63411554699496, -2.28380625780731, -2.27896044246845, -2.19661244829441,
-2.18039652225164, -1.18146437845759, -1.6101070827248, -1.31682391434599,
-0.781364138557704, -1.89278224977018, -2.28683751979873, -2.28170279433502,
-2.25507742887343, -2.27469315563211, -2.19106352335337, -2.20216376634672,
-1.50940418054145, -1.57481865165838, -2.00915316980509, -1.94938461398854,
-1.98455653642811, -2.22145418758665, -2.1605019074557, -2.22929361026136,
-2.28754415075922, -2.28401553991566, -2.28099274980288, -2.2790962708342,
-2.25448944582185, -2.24095826297856, -2.28753886744317, -2.2790962708342,
-2.28249611688223, -2.29051254450738, -2.28856644852124, -2.29051401027405,
-2.28539476406181, -2.27754391464367, -2.28663199585719, -2.29003809100396,
-2.21974449731936, -2.26453458741267, -2.24273365564754, -2.0758820670505,
-2.05727208640147, -2.1075473897372, -2.18169509790509, -2.10183883759691,
-2.0941547862828, -2.17052540371127, -1.84552009498619, -2.11897925887711,
-2.2475539961602, -2.23266092019845, -2.26826235385205, -2.27716458812284,
-2.22875067319638, -2.20169236013157, -1.72209385129724, -0.476893951190187,
-1.44569200778405, -2.08830648613957, -2.13084935049209, -2.17358829667077,
-2.05592583172644, -1.84265559786228, -1.98577321824112, -1.88660772323127,
-1.99603456442263, -2.10189853669134, -2.14149931364702, -2.22701080101746,
-2.27258448425562, -2.21873931960315, -2.23587705524471, -2.17915915787995,
-1.95172754860073, -2.00843362344438), OLS_6 = c(-2.14615029819501,
-2.1274826763545, -2.14613692884822, -2.038363166, -2.14482079785526,
-2.13839956793073, -2.1352633011825, -2.14480554064275, -1.77137087834078,
-0.604458131512312, -1.92044345866761, -1.91142894340333, -1.5035051350835,
-2.03720410348948, -2.07364942604987, -1.67230210256299, -1.66457879312031,
-0.427523081653794, -2.09111249534671, -2.1358169999572, -2.13575175544593,
-1.44873737433719, -2.14509683128765, -2.12442374236989, -2.02946586195686,
-2.01185030632841, -0.994510606111227, -1.42450007218492, -1.12983335353955,
-0.596198212559954, -1.7115906309286, -2.13555900800151, -2.12811588444992,
-2.09509015766854, -2.11889016916752, -2.02341958358771, -2.03553614239934,
-1.32305159796573, -1.38891263096519, -1.83141440901763, -1.76969899713653,
-1.80596583024281, -2.05682837956465, -1.99043348930533, -2.06558998487816,
-2.14664801486533, -2.13135448546891, -2.1271468279034, -2.14250449627423,
-2.12545741758249, -2.11509475538252, -2.1466464083569, -2.14250449627423,
-2.14442504670383, -2.14684049810003, -2.13838680613343, -2.1468398441846,
-2.14583791450693, -2.14156460788614, -2.14633891192499, -2.14114136796206,
-2.05492693125432, -2.10632999229998, -2.08080895764288, -1.90090288083161,
-1.88144765246016, -1.93417313784094, -2.01325520240903, -1.9281579797124,
-1.92007377040746, -2.00120005643771, -1.66327168223962, -1.94624457366434,
-2.08634430885867, -2.06937728900294, -2.11086434271986, -2.12206882778948,
-2.06498074945642, -2.03501978622706, -1.5377512452434, -0.29431817292714,
-1.25902518147068, -1.91393009686737, -1.95881793980313, -2.00449939786682,
-1.88004274517372, -1.66034827254381, -1.80722288608151, -1.70526848086161,
-1.81783189921089, -1.92822084254891, -1.97013652098612, -2.0630309651189,
-2.1162243283256, -2.0538104595074, -2.07300962091288, -2.0105124912345,
-1.7721107506457, -1.83066883021211)), .Names = c("Y", "X", "Null",
"OLS_1", "OLS_2", "OLS_3", "OLS_4", "OLS_5", "OLS_6"), row.names = c(NA,
99L), class = "data.frame")
My scatter plot will consist of the first column (Y) and the second column (X).
The third column i will not use.
From the fourth column are the curves that are fitted values of OLS regressions.
How do I include them using the plot function?
i am doing this, but its not working
plot(data[,2],data[,1])
for(i in 4:9){
lines(data[,i])
}
What am i doing wrong?
Basically you want
data <- data[order(data$X), ] ## reordering so that `X` is increasing
plot(data$X, data$Y)
for (i in 4:9) {
lines(data$X, data[,i], col = i) ## remember to set `x-coordinates`
}
legend("topright", legend = names(data)[4:9], col = 4:9, lty = 1) ## add legend

R Find Full width at half maximum for a gausian density distribution

I have a data set (come from reality) like
a<-c(12.4314579038074, 30.1197692762127, 31.8986680511062, 21.5000657793742,
24.2201952026304, 21.4083286311931, 30.543892400514, 11.3243039196637,
18.6629847817322, 68.5846251690826, 8.15853135278713, 20.0269675183568,
23.761746451965, 15.7934365856289, 20.2308964167179, 16.1739058219803,
16.80324393405, 17.8825865979249, 11.4033338599819, 24.6766819397457,
21.6401012626284, 34.9473576269376, 21.2387163543256, 38.8393540982342,
11.1324409747932, 27.9691456747847, 35.0247764515163, 25.2955953655814,
20.1144847120957, 21.601935342838, NA, 37.0382391253826, 23.0768070922688,
29.7978557208652, 25.5629412341385, 52.3688195218551, 24.3278804498841,
24.5473987167943, 18.7003825260279, 7.59034179685435, 30.3494564815945,
11.9464422720518, 31.1286124512956, 35.6013073091488, 59.7732211526442,
18.1103630173406, 23.6991128199505, 35.0041638638631, 32.3290441334575,
9.96009633874818, 31.9439199749795, 17.2338813393175, 19.4703069779573,
40.0710364677356, 21.9784578364056, 14.8391748404154, 36.699595515976,
8.23000952339805, 29.3936574804397, 16.608043366678, 31.8893140469488,
25.0034860781714, 5.85410045445957, 33.6738722502197, 19.8719119513059,
16.5220779562036, 18.5998514048289, 26.2005902882878, NA, 24.6566247442218,
27.0333844562812, 14.886428829687, 17.5724702275547, 26.2137775245073,
19.0507021982012, 10.9566296835514, 26.6958883379168, 7.96499401119146,
26.1859738026908, 17.660793443073, 24.2581780545893, 13.2116252996823,
20.8404415084083, 13.9759556218075, 8.08290201929875, 19.577431906635,
30.8617872452287, 17.659162045328, 19.6553312413463, 54.5228181855605,
8.61384429381566, 8.57902103633537, 14.3833198356842, 44.6520928899702,
50.1684992597442, 19.1839092769506, 14.1859756348872, 22.319616459382,
7.04281719040295, 19.9734034824111, 26.5179176521408, 13.1611965717225,
16.9098287156019, 28.9883554716117, 26.0468146958332, 29.6763235030978,
48.7345046631538, 38.4339027762459, 31.2090734875574, 15.9385304470886,
12.8921108018056, 10.9673039456914, 10.3743768429606, 25.9387376803067,
NA, 11.5544889726556, 18.7480106738499, 13.2374072159457, 16.0463683223854,
13.6394902895386, 19.6499476784153, 19.6653905961478, 22.6713289483346,
30.0530150121339, 39.2413167843811, 29.7476825791523, 67.017937817938,
6.75394239192403, 13.8315465658099, 15.6479984367677, 11.6595078158563,
16.6153046740276, 29.1944136335659, 20.0699193532974, 23.0964604145297,
16.4642724437565, 31.4384175748718, 24.9125640407848, 25.0969240666473,
32.7585005489893, 28.2005135471151, 11.6928832972854, 29.0925157165188,
27.1449795674534, 19.7174609825609, 11.3155221077222, 13.8725373098617,
10.4058292934838, 20.5471528311623, 24.593775927458, 24.5992797334339,
25.7621705532288, 19.429523059737, 23.7267657702523, 26.8378886664471,
33.0405101400995, 33.8244308994044, 23.923384237542, 10.1422998835261,
8.36171095318636, 31.7070531272099, 29.7732770732215, 24.8822351146394,
5.02000303147286, 12.8561338422933, 19.9693656971446, 19.599345558469,
22.1630854796563, 22.3226724168097, 32.0046288304837, 9.97036087568324,
17.9532401992864, 27.5200598557606, 18.2493582809349, 19.516614679827,
8.73100033494884, 9.92568752683278, 36.111580524921, 26.5447538548956,
31.5801048764258, 30.7784315713327, 43.9917658205537, 5.88518831155849,
38.6914615372257, 22.4450167569794, 38.471255777786, 17.8759146100263,
42.1237669506763, 40.8120103320423, 50.9620878359755, 24.8723162387534,
28.281137488787, 21.1047200631107, NA, 35.6445176565107, NA,
22.4329601563967, 17.1865147962927, 34.6207419910748, 27.488098898296,
40.647159426457, 49.0566470559664, 25.2404304347901, 28.9937264113381,
14.0652751682648, 16.8982448551594, NA, NA, 38.7092724982844,
51.3923484671426, 56.2948963516975, 17.6784549803966, 21.346370069203,
40.5568626421931, 11.5473392102776, 29.8901196029765, 55.8045368249135,
32.5629692658593, 15.7151398771352, 50.69539004787, 28.6630956503548,
NA, 33.745363485143, 30.1793575796192, 31.5239871763176, 23.413715020835,
28.4068815777865, 26.628933941261, 28.8040299272661, 38.7590176170059,
28.5895707604946, 27.3163626291958, 22.4432050319593, 22.8717709770244,
15.5769117905467, 16.6205562869212, 19.6461009184912, 28.112145862862,
22.4817869475301, 11.9911595195158, 27.7864754526246, 32.110827889238,
38.6601905078103, 26.5431928219843, 37.5022713181254, 20.1507313327997,
26.1701491671608, 13.5713776019221, 24.9836498596017, 21.2698715590683,
25.0155871471049, 33.7177860466273, NA, 13.9496573767241, 16.1150625739034,
16.6382037385219, 38.0327684962353, 15.4336346869134, 28.2741877552971,
18.3988010783219, 46.8872039734549, 39.6400155384279, 42.2346150067755,
23.8766379243586, 20.6388991126635, 13.4323233360809, 25.7328268912762,
18.5198704804179, 35.1253893334279, 50.4960266232654, 22.8606920846386,
16.1816315814691, 24.404001970632, 12.7156971608144, 16.1868830629463,
30.2499403084286, 49.7785508137954, 33.2123299816736, NA, 12.9230946451066,
7.08427169664578, 10.0671158815277, 19.7294071616146, 30.8425354787526,
38.3145455434934, 16.7030543796463, 12.1822921506718, 24.8419226234385,
NA, 19.6863906566313, 24.8415166763613, 27.2222764218966, 25.4530639943619,
24.3584061455177, 21.6932253013582, 26.6862568289173, 10.4439641151796,
8.16828313448626, 24.7764905211242, 24.0153889448978, 42.27494669877,
23.1024890766068, 12.5421984383058, 28.126105527251, 11.7477790609559,
37.8210140575854, 16.2510203840877, 29.5179896530944, 19.767113140873,
21.180255311345, 50.1326402088336, 46.9411426142246, 22.1825770399621,
38.3217563655723, 32.8198922751461, 18.1215432904772, 36.7957509446084,
31.0953183824079, 41.2683134903454, 27.3369679280893, 18.6814450240623,
40.9365261829113, 31.3995794910782, 45.3773497997797, 29.7809299163648,
25.6494347188067, 12.2371700316698, 24.028235743912, 20.2190137194663,
63.5048123597575, 19.4212679708406, 28.2540327945574, 15.6824059299007,
26.4502584835429, 25.6747019832926, 21.3448542479901, 21.5398949527062,
15.0453039478043, 15.435237823288, 21.9433429596872, 22.4942864667832,
19.2699097293276, 13.7352833513297, 17.2542472110831, 47.1631828020397,
43.0112020075035, 16.3372108879913, 24.2918076279655, 26.4439880171655,
23.1117247311131, 36.6759437723188, 43.6176498793953, 32.0130676806535,
30.6326404095052, 10.8268556221906, 52.7653604760821, 8.91595447346234,
13.193539457832, 7.68418008204124, 15.449010979906, 30.9584089126334,
51.9422244686175, 15.8458479496976, 14.1047956442756, 17.5191070473658,
31.7011704471313, 14.8239075593942, 26.6479556968534, 12.7304068904724,
21.6484498326962, 18.5454691264783, 19.7417604612319, 17.4178392306296,
18.6961734797299, 16.6762708630409, 25.5769497729958, 20.4324858725377,
48.0108296588978, 22.3873783217253, 61.8180303957998, 60.9275917236957,
33.6030207132321, NA, 35.5927559357877, 20.7557420025042, 45.0952627270979,
33.7073022209601, 23.7276388907278, 44.0279966951556, 18.4465734471124,
35.376096916925, 11.049064991332, 6.38266176887074, 27.770464922835,
14.3280667570411, 18.2895352437716, 11.8697485564632, 11.9115403522214,
23.8995147554712, 22.9524551093465, 41.5537350356802, 8.32663490566077,
41.2800566378259, 37.616909008102, 13.9220837749745, 53.4996016880608,
38.0527622385737, 36.2584535594006, 31.3674093196625, 24.2902569424465,
21.440394745746, 32.2127828476281, 22.1521432796998, 16.4186950681111,
10.4937514476589, 32.4071007810483, 24.498045100507, 25.4241096355652,
9.73946952507465, 21.4041253422142, 28.8926165924432, 34.512959841434,
30.0571573052611, 22.4907629383951, 20.2211187443641, 16.8118098933704,
23.5285775050765, 39.4440966466874, 33.2825067066343, 36.8830992125003,
21.1282934201697, 18.6272972241037, 15.3140799736706, 40.0011498958142,
10.0182747888065, 15.3706553616215, 41.9509134815123, 22.303622817723,
19.2424468127472, 35.0099989943938, 16.6900077828908, 23.4847012508485,
22.9601479739565, 13.7682136158064, 20.0454049113627, 27.7179470144016,
43.7485548044574, 27.7379261226753, 32.1756980668739, 32.8029836110017,
30.2392324390705, 31.3156918552083, 32.1847331854615, 20.5297104164335,
50.9569341153107, 42.6081618367459, 18.636321910844, 12.4308178035891,
26.6917378844734, 5.76426461481125, 25.0767930273219, 24.2457959380206,
11.3931924451717, 19.077483646119, 12.0287714622052, 13.8729173763677,
15.940072198383, 31.9320584106662, 16.1008550559317, 35.8212131776284,
15.2435052118809, 3.44730091866671, 13.2863037128651, 33.2528958365812,
23.0426972188497, 31.9040632994659, 21.2588079706295, 9.56009250089547,
37.0841912585872, 21.7862379679352, 12.5945799997629, 11.9204901690358,
34.2003866802345, 22.1076801376058, 14.7504409350283, 12.2988895790339,
37.4743876245349, 4.40070781544351, 27.47718305659, 45.3352312111182,
44.7238582623121, 30.1074154853725, 25.3584692242304, 18.2894817200095,
39.6668104206319, 15.1780135384362, 8.90023187782675, 12.695608490357,
7.97231909106364, 18.0254627826149, 37.1330399717644, 40.3814619400626,
15.7530424414729, 26.4871843271195, 11.3849905569825, 14.4310436716623,
15.7889776729542, 15.3189979064802, 8.14775366334019, 21.3763917473048,
19.4271587027591, 8.17415804490136, 8.56927307423665, 9.9955524608618,
15.5450134422331, 10.823091946932, 8.44824243438286, 4.43490646514755,
5.47934855653405, 7.23626623411468, 25.3530745380911, 24.3179916472365,
18.7488727821045, 32.190181880216, 20.3023247566628, 16.5179670640049,
13.5756284381254, 16.6579681190254, 31.1737441837392, 26.4445566581656,
19.0657083835412, 9.02756346026971, 13.8198542042488, 19.5572751031157,
15.9815268564019, 21.2096031612745, 23.1965642826673, 22.9413587497691,
54.0401136217987, 14.3385183237915, 9.56798831205209, 16.8699681496442,
15.9839479181869, 13.6433809778083, 11.6657052013993, 33.293408496818,
22.5090700291058, 19.3612583830867, 14.4092661794021, 17.9685233644732,
5.41812657103551, 5.85301279046166, 16.4916538514991, 32.8886078034163,
42.5319945344839, 6.96221532796392, 10.8250789766828, 14.0362434679265,
13.4236572258544, 8.18430437430949, 8.49810493010364, 19.9805220462551,
7.99530774694417, 7.7257996525705, 29.0351171682388, 4.33760495695362,
17.6928347163945, 10.1142902669032, 6.06249165375458, 4.74850565714552,
17.9833699614403, 67.2065822391264, 17.3347810074396, 16.5017818986004,
23.7514924365845, 37.1851342775933, 21.5618045488646, 30.6788445864795,
17.1035593022782, 8.42714630237048, 13.4006384220441, 22.1238974112126,
4.48001569435593, 23.9658029257865, 6.23907173530781, 26.877146564602,
15.3003261751959, 12.0485155125301, 4.32690092924821, 7.01214075444578,
16.1791317461962, 13.0728785273578, 7.63109083309118, 16.9972980214674,
8.30295245274037, 8.7770203067377, 5.67480760942735, 21.3961492360836,
13.9550988566784, 11.0242554066141, 19.4382013687556, 8.62975825045164,
11.4164507143039, 8.34586383704729, 3.72091720855698, 8.97296101792361,
29.8903858240922, 2.32504604168462, 25.8164695705562, 22.061057520145,
3.4803762605344, 48.3170810944539, 80.6701146444289, 15.0833362411301,
10.8924796349525, 17.4918647333209, 12.6115824242011, 34.3062414327012,
8.287617251304, 15.4831104293005, 15.1485432894085, 4.5184565189416,
3.59999333029852, 3.66865483560892, 29.9677778375668, 34.4509226015574,
32.5918276015502, 10.6060279795247, 19.7913453571932, 28.266459587366,
19.6122992848655, 9.57523706552828, 9.04738999444933, 5.25824593606435,
6.55473931337678, 18.7449471987719, 9.27943740426736, 9.54703445889029,
3.43647048217306, 17.6920729261708, 25.3789409935332, 43.0995071399241,
15.7776713016551, 5.96178566715426, 7.04629857379702, 40.3659823950032,
20.3090509981183, 14.0833358445997, 16.9522805698219, 40.8824485009689,
21.6424431028975, 11.0653580862889, 9.52636056796406, 13.2093186951614,
11.180272835061, 28.7154955728657, NA, 8.29026375001596, 30.2969947814111,
29.9276371600909, 8.84477707628671, 34.8718762912212, 33.7483835972703,
34.2724400573937, 10.0767436084755, 15.4873945381221, 26.7642017413928,
51.0184704255941, 13.3969350777478, 26.0049124989409, 24.4542678955175,
15.3254947646799, 27.6832229022455, 30.8718044931518, 19.7152850968778,
39.1363812987409, 3.27215259879083, 15.0217151381093, 5.81934884447124,
30.0083825574588, 12.8728048546551, 39.6060296728825, 25.1813163765464,
44.1868459510693, 56.2542657142314, 12.8977291749907, 45.114989387575,
48.6359576292684, 13.6879551288472, 20.8800721437086, 21.1718129052816,
18.1109547325148, 30.6495392873229, 16.6778394456472, 28.4355940709725,
40.2732033692905, 16.0324459813519, 21.6715649249579, 21.5745121789595,
41.0491368236404, 23.1897670150996, 38.6763733544082, 28.2952020362427,
14.9775146624242, 17.0529816156432, 21.3182907083993, 58.5980139524611,
34.1182365536438, 66.2307408341237, 10.0250215641074, 19.2484140780393,
36.1794806395077, 13.3664708666649, 43.0162594869992, 14.6768584506211,
14.3681241887621, 21.6991390370549, 19.3686839558787, 18.0066235564319,
26.4208759599778, 8.02575642257494, 6.45796803589213, 11.3672996291157,
14.4629853700209, 22.159295359166, 9.48235040640243, 28.0483346879341,
18.7791600825367, 19.7502447289479, 6.97410234941009, 15.552802250357,
13.3419372146528, 27.5115005559368, 6.97909930700005, NA, 7.05260541598179,
35.7722821782854, 36.7903676155688, 49.4540597647083, 25.2948226594315,
10.1520912497611, 13.4494123507724, 4.619799633406, 22.0861395692476,
14.2039171171824, 26.9952012939039, 9.36273697960081, 36.3471521574781,
17.1331241745133, 36.2783284115396, 23.2266827910025, 32.5915815527522,
31.2871980610003, 16.0233005517923, 23.600172770202, 18.2722026855851,
25.6024146453473, 20.9881450301547, 14.2228275030676, 9.41424245694267,
10.816472087346, 9.04870233666866, 28.2892191586388, 35.0753624317,
20.804631336334, 16.4586859700612, 18.4239500923344, 6.3386546363293,
6.49433203538962, 9.82250938112426, 21.4723821170409, 17.8374467840815,
35.0187346487592, 16.6827994374155, 10.1793943910258, 20.5493611125065,
15.7669268485395, 11.1870666093615, 9.10959979062923, 18.6380321376242,
10.0704206578543, 12.5407783691327, 34.8148633389888, 28.084370623971,
4.13200285250811, 30.1892030192568, 55.4882769575542, 35.7133359116889,
25.7829535423758, 24.3427532329746, 26.1373088326654, 12.8559165605457,
13.4759287411954, 45.973341582547, 16.3120873890776, 11.9948065461913,
7.92837707316941, 32.2209508527388, 17.166801717345, 22.4859349413392,
30.5941859604216, 10.9778157606133, 70.2748062001235, 21.5991697951828,
25.7831959948602, 1.43209618416462, 56.1235033644788, 24.4226310541958,
20.9224949050978, 36.3840952118939, 35.7276159685088, 37.6827740210086,
23.5299198435553, 13.6851209030389, 25.5335190230571, 45.4755511169848,
14.6080811491954, 14.2316318552737, 13.339561577062, 45.9187643234812,
24.9990910216492, 8.29483649953895, 23.5418927144432, 37.7936234851124,
12.70652449092, 28.7414210264296, 13.77474354302, 40.7185271359513,
13.2888748806108, 18.1136413518116, 48.3746826507517, NA, 12.1384015733918,
19.9658506537594, 13.1441032684027, 26.6795046532402, 11.9603093870165,
4.66530121380388, 19.473270220492, 27.5276898686734, 18.937349603982,
18.8155543455793, 13.4728520043676, 12.7940590426415, 16.6697994573555,
21.3583533715887, 42.5731745705282, 11.3851614825814, 16.7458126574673,
15.6740255937648, 16.6703517164138, 62.8179873937814, 21.6206878297099,
46.9610219140348, 53.40123532387, 40.092219470411, 37.8805373833002,
28.6457545722248, 20.6694999165836, 17.8624286041768, 28.5861053418492,
17.9939250048543, 37.3414460735396, 16.09898942567, 51.9310125086572,
19.7924905322066, 14.0565954639482, 46.864231594175, 20.7054727206452,
51.6787725408675, 37.6405519392879, 23.8641295161859, 14.714628026623,
10.3999093904835, 28.3638116333964, 29.5945043539217, 15.3139943100935
)
Than when I plot a curve density with ggplot
density_plot<-ggplot(data =a, aes(x=truc))+
geom_density(binwidth=5, alpha=.5, position="identity")
I get this graph
I have 2 questions :
it's look like a gausian ... whitch tool can I use for play with that?
I would like (if it's possible) to determine the Full width at half maximum (FWHM) to determine a model space (come from simulations) interesting to explore.
I have find normalmixEM from mixtools package the made that (I'm not sure to understand how it work).
fit = normalmixEM(a)
Erreur dans if (any(s.hyp == 0)) s.hyp[which(s.hyp == 0)] = runif(sum(s.hyp == :
valeur manquante là où TRUE / FALSE est requis
What the good way to calcul de FWHM ?
Thank's
E
That plot doesn't look like a normal distribution at all to me. The distribution looks right-skewed. Anyway, that's not relevant:
d <- density(na.omit(a), n=1e4)
plot(d)
xmax <- d$x[d$y==max(d$y)]
x1 <- d$x[d$x < xmax][which.min(abs(d$y[d$x < xmax]-max(d$y)/2))]
x2 <- d$x[d$x > xmax][which.min(abs(d$y[d$x > xmax]-max(d$y)/2))]
points(c(x1, x2), c(d$y[d$x==x1], d$y[d$x==x2]), col="red")
FWHM <- x2-x1
#[1] 25.71115

Resources