Re: [R] characters, mathematical expressions and computed values
Thanks for the example. On Thu, Oct 11, 2012 at 7:24 PM, William Dunlap [via R] ml-node+s789695n4645934...@n4.nabble.com wrote: I think that bquote, with its .() operator, suffices for [almost?] any single title; don't bother fiddling with expression(), substitute(), or parse(). (You can make those work in many situations, but if you stick with just bquote then you can spend your time on the title itself.) E.g., hist(new, main=bquote(Heart Attack ( * bar(X)==.(mean(new)) * ))) or, if you want to limit the number of digits after the decimal point, hist(new, main=bquote(Heart Attack ( * bar(X)==.(round(mean(new),1)) * ))) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: [hidden email]http://user/SendEmail.jtp?type=nodenode=4645934i=0[mailto:[hidden email] http://user/SendEmail.jtp?type=nodenode=4645934i=1] On Behalf Of 1Rnwb Sent: Thursday, October 11, 2012 2:32 PM To: [hidden email]http://user/SendEmail.jtp?type=nodenode=4645934i=2 Subject: [R] characters, mathematical expressions and computed values Hello, I have to add Age (bar(x)=14.3) as a title on a chart. I am unable to get this to working. I have tried bquote, substitute and expression, but they are only doing a part of the job. new- c(14.3, 18.5, 18.1, 17.7, 18, 15.9, 19.6, 17.3, 17.8, 17.5, 15.4, 16.3, 15, 17.1, 17.1, 16.4, 15.2, 16.7, 16.7, 16.9, 14.5, 16.6, 15.8, 15.2, 16.2, 15.6, 15, 17.1, 16.7, 15.6, 15, 15.8, 16.8, 17, 15.2, 15.8, 15.7, 14.7, 17.3, 14.9, 16.8, 14.6, 19.3, 15.3, 14.7, 13.3, 16.5, 16, 14.2, 16.1, 15.2, 13.4, 17.7, 15.5, 14.5, 15.7, 13.6, 14.1, 20, 17.2, 16.5, 14.3, 13.7, 14.7, 15.4, 13.6, 17, 17.3, 15.4, 15.5, 16.6, 15.8, 15.7, 14.7, 14.2, 14.2, 14, 14.2, 19.1, 17.2, 18.3, 13.9, 16, 15.9, 14.9, 14.6, 15.9, 12.2, 14.1, 12, 12.8, 17.1, 17, 15, 15.8, 15.9, 16.1, 18, 14.7, 18.9 ) hist(new, xlab='30-day Death Rate',xlim=c(7,22),main=expression(Heart Attack( * bar(X) * )= * mean(new))) I would appreciate any pointers on getting this correct. Thanks -- View this message in context: http://r.789695.n4.nabble.com/characters-mathematical- expressions-and-computed-values-tp4645916.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4645934i=3mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4645934i=4mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/characters-mathematical-expressions-and-computed-values-tp4645916p4645934.html To unsubscribe from characters, mathematical expressions and computed values, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4645916code=c2JwdXJvaGl0QGdtYWlsLmNvbXw0NjQ1OTE2fDU4ODg0MTYwOQ== . NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/characters-mathematical-expressions-and-computed-values-tp4645916p4646003.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] characters, mathematical expressions and computed values
Hello, I have to add Age (bar(x)=14.3) as a title on a chart. I am unable to get this to working. I have tried bquote, substitute and expression, but they are only doing a part of the job. new- c(14.3, 18.5, 18.1, 17.7, 18, 15.9, 19.6, 17.3, 17.8, 17.5, 15.4, 16.3, 15, 17.1, 17.1, 16.4, 15.2, 16.7, 16.7, 16.9, 14.5, 16.6, 15.8, 15.2, 16.2, 15.6, 15, 17.1, 16.7, 15.6, 15, 15.8, 16.8, 17, 15.2, 15.8, 15.7, 14.7, 17.3, 14.9, 16.8, 14.6, 19.3, 15.3, 14.7, 13.3, 16.5, 16, 14.2, 16.1, 15.2, 13.4, 17.7, 15.5, 14.5, 15.7, 13.6, 14.1, 20, 17.2, 16.5, 14.3, 13.7, 14.7, 15.4, 13.6, 17, 17.3, 15.4, 15.5, 16.6, 15.8, 15.7, 14.7, 14.2, 14.2, 14, 14.2, 19.1, 17.2, 18.3, 13.9, 16, 15.9, 14.9, 14.6, 15.9, 12.2, 14.1, 12, 12.8, 17.1, 17, 15, 15.8, 15.9, 16.1, 18, 14.7, 18.9 ) hist(new, xlab='30-day Death Rate',xlim=c(7,22),main=expression(Heart Attack( * bar(X) * )= * mean(new))) I would appreciate any pointers on getting this correct. Thanks -- View this message in context: http://r.789695.n4.nabble.com/characters-mathematical-expressions-and-computed-values-tp4645916.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] labeling rows in heatmap.2
how can i put the row labels on the left hand of the heatmap in heatmap.2? abnr-structure(c(1, 0.678622097406395, 0.670294749652918, -0.0016314464654279, -0.000519068106572792, 0.199581999119988, -0.0106623494189115, 0.0840111691399559, -0.0461494399639137, 0.249279171677728, NA, 1, 0.757114062773504, 0.0352642759270137, -0.0255518450373996, 0.0943268190664674, -0.0536269679247722, 0.126773293034976, 0.201980408094959, 0.350765436868705, NA, NA, 1, -0.0036285048239171, -0.0130341823193391, 0.0687025839829192, 0.0178114338783461, 0.152626558218618, 0.275694188182626, 0.516142788252573, NA, NA, NA, 1, 0.164352390738372, 0.0458032354120583, -0.105461242066774, 0.128550333248478, -0.0388185507340826, -0.0114545823453345, NA, NA, NA, NA, 1, 0.0771316851136, -0.00659533531241862, 0.0901665606000509, -0.0220524408127054, 0.0488218042091934, NA, NA, NA, NA, NA, 1, 0.208114979820194, 0.438398355562088, -0.0635609915410962, 0.0769889130808, NA, NA, NA, NA, NA, NA, 1, 0.350782329458641, 0.102284906838582, 0.00467073053941224, NA, NA, NA, NA, NA, NA, NA, 1, 0.170117904443778, 0.166988169283325, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0.324711157100758, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1), .Dim = c(10L, 10L), .Dimnames = list(c(TNFB, MCP3, IL6, IGFBP6, sCD40L, PTH, IGFBP2, OPG, IL1Ra, TNFA), c(TNFB, MCP3, IL6, IGFBP6, sCD40L, PTH, IGFBP2, OPG, IL1Ra, TNFA))) heatmap.2(abnr, breaks=c(0,0.05,0.1,0.25,0.35), col=brewer.pal(4,Blues), Rowv=FALSE, Colv=FALSE,symm=TRUE, key=TRUE,symkey=FALSE, density.info=none, trace=none, cexRow=0.75, keysize=0.8, scale = none, dendrogram=none,main='AbN') I would appreciate any response on this. Thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/labeling-rows-in-heatmap-2-tp4490314p4490314.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] row names of a heatmap on left hand side
bump -- View this message in context: http://r.789695.n4.nabble.com/row-names-of-a-heatmap-on-left-hand-side-tp4426353p4447786.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] row names of a heatmap on left hand side
Hello R Gurus, I have a matrix for which I am doing a heatmap using heatmap.2. I want to put the rownames on the lefthand side instead of the right side of the heatmap. how can i put the rownames on left hand side: I have already tried axis but could not make it work ccc-structure(c(1, 0.283300333755851, 0.237863231117007, 0.0148696794159253, -0.0780756406815149, -0.106161465097659, -0.0756387578559718, -0.0331407390639047, -0.0707492640028071, -0.0613323523367336, 0.160614869977481, 0.163220169151304, -0.00799405273310068, 0.0702415660531524, -0.00269044770795431, 0.022118567043969, 0.0620175783757948, 0.071884246401891, -0.0469804302975448, 0.0261500962333625, 0.126816435101853, 0.135887180731395, 0.0110308674727327, 0.0805731314652419, -0.147245436227401, NA, 1, 0.756696630102848, -0.0253573545151531, -0.0436449174849985, -0.0681193805838121, -0.125651668003682, -0.132100479190945, -0.0672954083207475, -0.230426861035276, -0.000418410746782722, 0.0769862111911649, -0.0335582429785183, -0.0842411971843023, -0.122530783393992, -0.0649446178327085, -0.077787483725924, -0.0351869234224504, -0.083404295266297, -0.0381865040141299, 0.106839122670871, 0.110275858855431, 0.0863464084194804, 0.153158957903198, -0.0240563780789799, NA, NA, 1, -0.0581824191662743, -0.0577752089674947, -0.0732098989298006, -0.128791472234673, -0.0988078828924034, -0.0679818896618525, -0.17312177564727, 0.012457362675565, 0.0592327855817399, -0.0666240794205135, -0.0715883024096398, -0.0922611542475004, -0.0690818250876944, -0.0580129934906561, -0.0172677939384777, -0.107766765710368, 0.00520294080324943, 0.0784863927912482, 0.102062918116874, 0.0571392089924128, 0.122231446563675, -0.037588761722365, NA, NA, NA, 1, 0.525472699159769, 0.514041356697963, 0.561064373161352, 0.431210983834436, 0.452619063041757, 0.147444937649346, 0.0499871095691751, 0.101711708044079, 0.313069848945963, 0.173478908711319, 0.234099595958429, 0.442444172603688, 0.271047417517104, 0.271574694324702, 0.335146377247985, 0.261796658619168, 0.20615917507402, 0.179710108054483, 0.00693091170071528, 0.0572351824096096, 0.0421931015525606, NA, NA, NA, NA, 1, 0.500262732680092, 0.575331145231366, 0.535966575237105, 0.588011751256699, 0.209316134244339, 0.178306362315634, 0.144372963193607, 0.449164822440907, 0.311585643277039, 0.373916415586687, 0.42342063290168, 0.257074092743689, 0.235277302551095, 0.349938957503695, 0.330125591891904, 0.343804820698451, 0.273320029845419, -0.00571265033987237, 0.0226529101519386, 0.0133821821423264, NA, NA, NA, NA, NA, 1, 0.783943436792447, 0.738881212745611, 0.74753358245511, 0.154011088987657, -0.0345413593712036, 0.0774290165561568, 0.270530619110383, 0.197653878154696, 0.175622464937608, 0.494122861400667, 0.205654982662595, 0.262435922111394, 0.336248481780927, 0.2457208720417, 0.225645535832965, 0.166011304030232, -0.000628760762335414, -0.0498164098632905, 0.0504668500594617, NA, NA, NA, NA, NA, NA, 1, 0.694267683304991, 0.665025879567406, 0.202215608856743, 0.0242420445336668, 0.115486719828318, 0.327074561287353, 0.232316609009873, 0.252557073368415, 0.528071198751934, 0.271456859045674, 0.308461563380474, 0.430695444971444, 0.343610015300747, 0.270906939265836, 0.233818502929012, 0.0267752322720164, 0.0263022347486687, 0.0451312848263739, NA, NA, NA, NA, NA, NA, NA, 1, 0.776593952305343, 0.264441281328401, 0.18148880771864, 0.123206249983537, 0.298515458147549, 0.325676094897333, 0.269563532182944, 0.500437079037779, 0.315922872681825, 0.320594404612037, 0.342087722381524, 0.234383707828859, 0.333287400951434, 0.218902122287433, 0.0369772789625516, 0.0129942406701288, 0.0489108090105715, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0.162583487686877, 0.195970937901678, 0.120763943840432, 0.436732203917893, 0.466737746485222, 0.37904462705, 0.512555709916608, 0.242432982203289, 0.253876944460396, 0.309350372966892, 0.251258196675636, 0.230011894342281, 0.127848664881258, -0.0115057022105185, -0.00311190058097034, 0.0549673967736474, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0.245845410111639, 0.244681678373053, 0.345224517493842, 0.231228340394969, 0.375331818652881, 0.279222931694161, 0.449497588453708, 0.381759655904665, 0.125594966938876, 0.123732822791146, 0.242643089641339, 0.213713940442987, -0.0464978734739873, -0.0530884098109049, 0.00741507616587697, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0.257637258425107, 0.266404784079116, 0.418770493609101, 0.380954319800656, 0.225911833064407, 0.239940125963318, 0.166185116079108, 0.0545692769866459, 0.104587370234936, 0.157906865871569, 0.153607122076791, -0.0654111656429167, -0.00340208731802426, -0.0629540855938132, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 0.302626240633324, 0.314160256475753, 0.36659577440935, 0.283381437378777, 0.356824428698387, 0.458399544248849, 0.0513918399545163, 0.175229426288891, 0.219315198173476, 0.379344376229316, 0.0380837761734483, 0.052844098764557,
[R] height of plots
Hello R gurus, I have to create 12 plots, I have been using the following script, which leaves a large white space between two plot. I would appreciate if someone can suggest an alternative to reduce the white space. par(mar=c(3,3,.5,.5)) split.screen(c(6,2))# split display into two screens for (i in 1:12) { if (i11) { screen(i) plot(1:10,xaxt='n', xlab='', ylab='') box() }else{ screen(i) plot(1:10, xlab='', ylab='', cex=0.75) box() } } Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/height-of-plots-tp4339152p4339152.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with code
this is how the ouput from the code should be structure(list(HTN = 1:10, HTN_FDR = structure(c(4L, 2L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 2L), .Label = c(Ctrl_noc, T1D_noc, T1D_oc, T1d_w), class = factor), Dyslipidemia = structure(c(3L, 2L, 1L, 2L, 4L, 1L, 1L, 2L, 4L, 2L), .Label = c(Ctrl_noc, T1D_noc, T1D_oc, T1D_w), class = factor), CAD = structure(c(3L, 2L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 2L), .Label = c(Ctrl_noc, T1D_noc, T1D_oc), class = factor), CAD_FDR = structure(c(3L, 2L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 2L), .Label = c(Ctrl_noc, T1D_noc, T1D_oc), class = factor), Prior_MI = structure(c(3L, 2L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 2L), .Label = c(Ctrl_noc, T1D_noc, T1D_oc), class = factor), t1d_ptype = structure(c(3L, 3L, 2L, 3L, 1L, 1L, 2L, 3L, 3L, 3L), .Label = c(Ctrl, Ctrl_FDR, T1D), class = factor)), .Names = c(HTN, HTN_FDR, Dyslipidemia, CAD, CAD_FDR, Prior_MI, t1d_ptype), class = data.frame, row.names = c(NA, -10L)) -- View this message in context: http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4228759.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with code
here is the dump and the code once again, sorry for creating so much noise. c1-structure(list(HTN = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), HTN_FDR = structure(c(2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), Dyslipidemia = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), CAD = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), CAD_FDR = structure(c(2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), Prior_MI = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(, Y), class = factor), t1d_ptype = structure(c(3L, 3L, 2L, 3L, 1L, 1L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 3L, 3L, 2L, 2L, 1L, 1L, 3L), .Label = c(Ctrl, Ctrl_FDR, T1D), class = factor)), .Names = c(HTN, HTN_FDR, Dyslipidemia, CAD, CAD_FDR, Prior_MI, t1d_ptype ), row.names = c(NA, 25L), class = data.frame) c2-c1 any_comp-NULL for( i in 1:dim(c1)[1]) { num_comp-0 for (j in 1:dim(c1)[2]) if (c1[i,j]==2) num_comp=num_comp+1 #Y=2 for (j in 1:dim(c1)[2]) if(num_comp0) { if (data$t1d_ptype[i] == T1D c1[i ,j] == 2) c2[i,j]-T1D_w if (data$t1d_ptype[i] == T1D c1[i, j] == 1) c2[i,j]-T1D_oc if(substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 2) c2[i,j]-Ctrl_w if (substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 1) c2[i,j]-Ctrl_oc } else { if(data$t1d_ptype[i] == T1D) c2[i,j]-T1D_noc if(substr(data$t1d_ptype[i],1,4) == Ctrl) c2[i,j]-Ctrl_noc } } -- View this message in context: http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4222965.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with code
Thanks Bill, the output of dput was very similar to your example, I was not sure so did not put it on the post. however i uploaded the foo.txt file which contains the part of the data. sharad -- View this message in context: http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4222947.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with code
I do not know how to use dput, i am attaching the txt file for the data http://r.789695.n4.nabble.com/file/n4222616/foo.txt foo.txt c1-read.dlim('foo.txt') c2-c1 any_comp-NULL for( i in 1:dim(c1)[1]) { num_comp-0 for (j in 1:dim(c1)[2]) if (c1[i,j]==2) num_comp=num_comp+1 #Y=2 for (j in 1:dim(c1)[2]) if(num_comp0) { if (data$t1d_ptype[i] == T1D c1[i ,j] == 2) c2[i,j]-T1D_w if (data$t1d_ptype[i] == T1D c1[i, j] == 1) c2[i,j]-T1D_oc if(substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 2) c2[i,j]-Ctrl_w if (substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 1) c2[i,j]-Ctrl_oc } else { if(data$t1d_ptype[i] == T1D) c2[i,j]-T1D_noc if(substr(data$t1d_ptype[i],1,4) == Ctrl) c2[i,j]-Ctrl_noc } } this gives me whether the particular t1d_ptype has a specific complication as well as there is another complication as well. I will appreciate help very much. thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4222616.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with code
hello gurus, i have a data frame like this HTN HTN_FDR Dyslipidemia CAD t1d_ptype[1:25] 1Y YY T1D 2 T1D 3 Ctrl_FDR 4 T1D 5Y Ctrl 6 Ctrl 7 Ctrl_FDR 8 T1D 9YY T1D 10 T1D 11 Ctrl_FDR 12 YY T1D 13 Y YY T1D 14 T1D 15 Ctrl 16 Ctrl 17 Ctrl_FDR 18 T1D 19 T1D 20 Y T1D 21 Ctrl_FDR 22 Ctrl_FDR 23 Ctrl 24 Ctrl 25 T1D i am converting it to define the groups more uniformly using this code: for( i in 1:dim(c1)[1]) { num_comp-0 for (j in 1:dim(c1)[2]) if (c1[i,j]==2) num_comp=num_comp+1 #Y=2 for (j in 1:dim(c1)[2]) if(num_comp0) { if (data$t1d_ptype[i] == T1D c1[i ,j] == 2) c2[i,j]-T1D_w if (data$t1d_ptype[i] == T1D c1[i, j] == 1) c2[i,j]-T1D_oc if(substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 2) c2[i,j]-Ctrl_w if (substr(data$t1d_ptype[i],1,4) == Ctrl c1[i,j] == 1) c2[i,j]-Ctrl_oc } else { if(data$t1d_ptype[i] == T1D) c2[i,j]-T1D_noc if(substr(data$t1d_ptype[i],1,4) == Ctrl) c2[i,j]-Ctrl_noc } } it is giving me error In `[-.factor`(`*tmp*`, iseq, value = structure(c(NA, ... : invalid factor level, NAs generated Also it there a simple way to do this. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4218989.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with formula for clogit
I would like to know if clogit function can be used as below clogit(group~., data=dataframe) When I try to use in above format it takes a long time, I would appreciate some pointers to get multiple combinations tested. set.seed(100) d=data.frame(x=rnorm(20)+5, x1=rnorm(20)+5, x2=rnorm(20)+5, x3=rnorm(20)+5, x4=rnorm(20)+5, x5=rnorm(20)+5, x6=rnorm(20)+5, x7=rnorm(20)+5, x8=rnorm(20)+5, group=rep(c(1,2),10), Age=rnorm(20)+35,strata=c(rep(1,10), rep(2,10))) nam=names(d)[1:9] results - c(Protein, OR, p-val) pc3=combinations(n=length(nam),r=2) for (len in 1:dim(pc3)[2]) { prs=pc3[len,] mols=nam[prs] d2=d[,c(mols,'group','Age','strata')] log.reg-clogit(group~.,data=d2) a = summary(log.reg)$conf.int z= summary(log.reg)$coefficients[1,4] #ncol in coefficients is 3 * number of parameters pval = 2*pnorm(-abs(z)) res2 = c(paste('IL8+',molecule,sep=''), paste (round(a[1,1],2), ( , round(a[1,3],2), - , round(a[1,4],2), ) , sep=), pval) results = rbind (results ,res2 ) } Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-formula-for-clogit-tp3998967p3998967.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
the part of the question dawned on me now is, should I try to do the parallel processing of the full code or only the iteration part? if it is full code then I am at the complete mercy of the R help community or I giveup on this and let the computation run the serial way, which is continuing from past sat. Sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3948118.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with paste
Hi Joshua, Thanks for the suggestion. Sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-paste-tp3942818p3943753.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with parallel processing code
Hello R gurus, I have the code below for which i need help and pointers to make it run in parallel on a dual core win7 computer with R 2.13.x, using foreach, iterators,doMC. library(scatterplot3d) # Loads 3D library. library(fields) library(MASS) library(ROCR) library(verification) library(caret) library(gregmisc) ##simulated data d=replicate(9, rnorm(40)+10) colnames(d)-c(LEPTIN,SAA,PTH,sEGFR,IGFBP6,MMP2,OPG,IGFBP3,PDGFAABB) mols=c(LEPTIN,SAA,PTH,sEGFR,IGFBP6,MMP2,OPG,IGFBP3,PDGFAABB) Name of the results output file1=AUCvalues_3plex.csv temp1=c('protein comb', 'AUC') pdf('ROC Charts-3plex.pdf') #generate combinations pc3 = combinations(n=length(mols),r=3) #runing the combinations for (len in 1:dim(pc3)[1]) { prs = pc3[len,] ## new data mat samples - mols[prs] mat -data [,c(samples,'Self_T1D')] mat-mat[complete.cases(mat),] # LDA # rows- c(1:nrow(mat)) scores - c() labels -c() for (itr in 1:1000) { train - sample(rows, length(rows)-1) label =0 ; if (mat$Self_T1D[-train] == N) label = 1 #need the value for this line, should it be 'N' or 'Y' z - lda(Self_T1D ~ ., mat, subset = train) score = predict(z, mat[-train, ])$pos[1] scores - c(scores, score) labels- c(labels, label) } ## ROC # pred - prediction(scores, labels) perf - performance(pred,tpr, fpr) plot(perf,colorize = F) # plot a ROC curve for a single prediction run # with CI by bootstrapping and fitted curve #roc.plot(labels,scores, xlab = False positive rate, #ylab = True positive rate, main = NULL, CI = T, n.boot = 100, plot = both, binormal = TRUE) auc - as.numeric(performance(pred, measure = auc, x.measure = cutoff)@y.values) auc = round(auc,3) text(.9,0,paste( AUC=, auc, sep= ), cex=1) names1 = paste (samples, collapse=+) text(.8,.05,names1, cex=0.75) temp = c(names1, auc) temp1 = rbind(temp1 , temp) print(paste(3,' ','done len=',len, ,names1,' ',date(),sep='')) } dev.off() write.csv(temp1 , file=file1) Thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3944303.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
sorry for noise the simulated data should be like this d=data.frame(replicate(9, rnorm(40)+10),rep(c('y','n'),20)) colnames(d)-c(LEPTIN,SAA,PTH,sEGFR,IGFBP6,MMP2,OPG,IGFBP3,PDGFAABB,group) -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3944922.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package for time series
if you are a beginer then try this http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm there are lots of books and their exercises available on the authors website. also search in google books http://books.google.com/books?id=0fRcUmyhUIQCprintsec=frontcoversource=gbs_ge_summary_rcad=0#v=onepageqf=false. regards sharad -- View this message in context: http://r.789695.n4.nabble.com/package-for-time-series-tp3944825p3944878.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
my modification gives me error rows- c(1:nrow(mat)) scores - c() labels -c() itr-1000 chnksz-ceiling(itr/getDoParWorkers()) smpopt=list(chunkSize=chnksz) foreach(icount(itr),.combine=cbind,.options.smp=smpopts)%dopar% + { + train - sample(rows, length(rows)-1) + label =0 ; if (mat$Self_T1D[-train] == N) label = 1 #need the value for this line, should it be 'N' or 'Y' + z - lda(mat[train,4] ~ mat[train,1:3]) + score = predict(z, mat[-train, ])$pos[1] + scores - c(scores, score) + labels- c(labels, label) + } Error in { : task 1 failed - could not find function lda -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3945243.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
yes the library(MASS) was loaded. -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3945972.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
If i understand correctly you mean to write the line as below: foreach(icount(itr),.combine=combine,.options.smp=smpopts,.packages='MASS')%dopar% -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3945954.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with paste
Hello gurus, I have some variables, and i am creating combinations for analysis in the end i need these variables to be displayed like LEPTIN+SAA+PTH. currently i am using loop to perform this. I would appreciate any pointers to do it without the loop. mols=c(LEPTIN,SAA,PTH,sEGFR) samples=mols[1:3] samples [1] LEPTIN SAAPTH names1=samples[1] for (j in 2:length(samples)){ names1 = paste (names1, samples[j], sep=+)} names1 [1] LEPTIN+SAA+PTH thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-paste-tp3942818p3942818.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dotPlot with diagonal
is this what you are looking for library(lattice) (Seq - matrix(c(1, 1, 6, 1, 2, 2, 5, 4, 3, 3, 4, 3, 4, 4, 3, 2, 5, 5, 2, 5, 6, 6, 1, 6), ncol = 6)) plot(Seq[1,], Seq[2,], main = Sequenz 1 und Sequenz 2, asp = 1) abline(a=0,b=1,col='red',lwd=2) -- View this message in context: http://r.789695.n4.nabble.com/dotPlot-with-diagonal-tp3940265p3942828.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] calculating ratios from all combinations
Thanks Micheal, that's what I wanted, I did not quite catch which variable is unused. Another part is I have my variable values in log scale so it generates '0's' instead of '1', how do i get rid of those cols. Thanks for you patience Sharad -- View this message in context: http://r.789695.n4.nabble.com/calculating-ratios-from-all-combinations-tp3912560p3915321.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] calculating ratios from all combinations
thanks for the help and pointer. I am modifying it like this x=which(n[,1]==n[,2]) n=n[-x,] to get rid of combinations which will generate '0' or ratio of 1. Thanks once again. sharad -- View this message in context: http://r.789695.n4.nabble.com/calculating-ratios-from-all-combinations-tp3912560p3915645.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] calculating ratios from all combinations
so here is the code I need help to fix the line for 'st' when it reaches maximum, that's where i am getting stuck. thanks Sharad set.seed(100) d=data.frame(x=rnorm(20)+5, x1=rnorm(20)+5, x2=rnorm(20)+5, x3=rnorm(20)+5, x4=rnorm(20)+5, x5=rnorm(20)+5, x6=rnorm(20)+5, x7=rnorm(20)+5, x8=rnorm(20)+5) r2=c() cinit=0 for (col in 1:9) { cinit=cinit+1 st=cinit+1 end=dim(d)[2] r=d[,cinit]-d[,st:end] r2=cbind(r2,r) } -- View this message in context: http://r.789695.n4.nabble.com/calculating-ratios-from-all-combinations-tp3912560p3912767.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation matrix
Thank you all for your suggestions. Sharad -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-tp3891085p3894329.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] correlation matrix
Hello Gurus I have two correlation matrices 'xa' and 'xb' set.seed(100) d=cbind(x=rnorm(20)+1, x1=rnorm(20)+1, x2=rnorm(20)+1) d1=cbind(x=rnorm(20)+2, x1=rnorm(20)+2, x2=rnorm(20)+2) xa=cor(d,use='complete') xb=cor(d1,use='complete') I want to combine these two to get a third matrix which should have half values from 'xa' and half values from 'xb' x x1 x2 x 1.000 -0.15157123 -0.23085308 x1 0.3466155 1. -0.01061675 x2 0.1234507 0.01775527 1. I would like to generate a heatmap for correlation values in disease and non disease phenotype I would appreciate if someone can point me in correct direction. Thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-tp3891085p3891085.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation matrix
okay so fixed what i need to do this way finit=0 for(ri in 1:dim(xa)[1]) { finit=finit+1 xc[ri,1:finit]-xa[ri,1:finit] xc[1:finit,ri]-xb[1:finit,ri] } but getting error in heatmap.2 mycol - colorpanel(n=40,low=red,mid=white,high=blue) heatmap.2(xc, breaks=pairs.breaks, col=mycol, Rowv=FALSE, symm=TRUE, key=TRUE, symkey=FALSE, density.info=none, trace=none, cexRow=0.5, + scale = none, dendrogram=none) Error in heatmap.2(xc, breaks = pairs.breaks, col = mycol, Rowv = FALSE, : `x' must be a numeric matrix any pointers are appreciated -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-tp3891085p3891584.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] splitting sample names
Thanks to all of you for the suggestions and corrections. Sharad -- View this message in context: http://r.789695.n4.nabble.com/splitting-sample-names-tp3753712p3755297.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] splitting sample names
I have a data frame like this xx-data.frame(cbind(Sample=c('Ctrl_6h','1+0_6h','1+200_6h','1+5k_6h','Ctrl_5K_6h','ConA_6h'), IFIT1=c(24,25,24.7,24.5,24.2,24.8))) grep('[[:digit:]]h',xx$Sample) yy-xx$Sample strsplit(yy,_) I have to extract the time information separated by '_' in the sample names, i tried grep and strsplit, it looks that i am not providing some information correctly. I would appreciate if someone can point me to the correct way. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/splitting-sample-names-tp3753712p3753712.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] msProcess, creating msSet file(s)
I have 120 MS chromatograms containing two columns'Time' and 'Peak height'. how do in create a msSet file which is required by all the functions of 'msProcess' to process these files. I would appreciate help very much. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/msProcess-creating-msSet-file-s-tp3727959p3727959.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching by gender and age
getting errors when running this file http://r.789695.n4.nabble.com/file/n3605311/il1ra_status.txt il1ra_status.txt Age.co-c(dat2b$Dr_Age) Sex.co-as.factor(dat2b$Sex) casecont.co-as.factor(dat2b$Self_T1D) stat.co-as.factor(dat2b$status) m - matchControls(stat.co~Sex.co+Age.co,contlabel=IL1Ra_H) Error in retval[k] - controls[which.is.min(d[cases[k], controls])] : replacement has length zero In addition: Warning message: In min(x, na.rm = TRUE) : no non-missing arguments to min; returning Inf I would appreciate help to solve this. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3605311.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching by gender and age
the examples work great but it gives me this error on this file http://r.789695.n4.nabble.com/file/n3603737/il1ra_L.csv il1ra_L.csv Age.co-c(dat2b$Dr_Age) Sex.co-as.factor(dat2b$Sex) casecont.co-as.factor(dat2b$Self_T1D) stat.co-as.factor(dat2b$status) m - matchControls(Sex.co~Age.co,contlabel=F) Error in retval[k] - controls[which.is.min(d[cases[k], controls])] : replacement has length zero In addition: Warning message: In min(x, na.rm = TRUE) : no non-missing arguments to min; returning Inf I would appreciate help to solve this. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3603737.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching by gender and age
Thanks, for pointing out the package e1071, the example for matchControls is exactly what I am looking for, however how can I add additional factors to match for. library(e1071) Age.case - 40 + 5 * rnorm(50) Age.cont - 45 + 10 * rnorm(150) Age - c(Age.case, Age.cont) Sex.case - sample(c(M, F), 50, prob = c(.4, .6), replace = TRUE) Sex.cont - sample(c(M, F), 150, prob = c(.6, .4), replace = TRUE) Sex - as.factor(c(Sex.case, Sex.cont)) casecont - as.factor(c(rep(case, 50), rep(cont, 150))) risk.case-sample(c(H, M, L), 50, prob = c(.4,.4, .2), replace = TRUE) risk.cont-sample(c(H, M, L), 150, prob = c(.3,.3, .4), replace = TRUE) risk-as.factor(c(risk.case, risk.cont)) ## now look at the group properties: boxplot(Age ~ casecont) barplot(table(Sex, casecont), beside = TRUE) barplot(table(Sex, risk), beside = TRUE) m - matchControls(casecont ~ Sex + Age+risk) -- View this message in context: http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3571509.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching by gender and age
I hope this modified example will work set.seed(100) disease-paste(rep(c('y','n'),50)) gender-c(paste(rep(c('m','f'),25)), paste(rep(c('f','m'),25))) mcp-rnorm(100, mean=1000,sd=600) age-rnorm(100,mean=32,sd=20) dat-data.frame(disease=disease,sex=gender,Dr_age=age,MCP=mcp) the output should be very closely in age for equal number of disease and gender. disease sex Dr_age MCP 99 y f 25.87435 -534.4172 93 y f 65.60017 1741.8817 47 y m 46.15360 407.0412 19 y m 26.24546 910.1833 24 n f 66.53540 1343.3980 30 n f 47.21835 888.0062 78 n m 42.75345 1605.1334 82 n m 27.05292 1671.9386 -- View this message in context: http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3561009.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] matching by gender and age
Hello R gurus, I have a data set from which i have to extract the gender and age matched rows from controls and disease group disease-paste(rep(c('y','n'),11)) gender-paste(rep(c('m','f'),11)) mcp-rnorm(700,1400) age-rnorm(32,34) dat-data.frame(disease=disease,sex=gender,Dr_age=age[1:22],MCP=mcp[1:22]) I have other categorical variables also to add to the matching. all the posts I came across are matching for a single column from two matrix/dataframe. How can i match for multiple variables when all the data is in one single dataframe -- View this message in context: http://r.789695.n4.nabble.com/matching-by-gender-and-age-tp3552825p3552825.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A better way to do this
here is the data set, yes i am doing spagghetti plots for each Subject for MCP1 with respect to the Age.at.Sample.Collection, with a final of all the controls and all the cases Subject.ID sample Group Age.at.Sample.CollectionMCP1 19 00173-0 3455 control11.767282 212.4438625 104 00173-0 4992 control 4.087611 222.6706897 148 00173-0 5046 control 5.103353 257.5997389 192 00173-0 5205 control 7.249828 191.8050229 223 00173-0 4991 control 6.061601 171.2995728 235 00173-0 5295 control 7.843942 240.2288223 275 00173-0 5366 control 9.817932 64.9237708 319 00173-0 5473 control10.704996 199.4368169 210200173-0 3140 control15.260780 366.1121484 317400173-0 4950 control14.012320 253.4390051 388300173-0 4103 control12.974674 260.3490578 23 01039-0 901388 control 3.058179 273.6916770 491 01039-0 901068 control 1.284052 255.5981436 735 01039-0 900985 control 1.968514 450.2616943 119901039-0 900733 control 5.086926 161.5011670 394801039-0 901422 control 4.041067 365.8560986 24 21038-0 901594 control 8.418891 303.9160091 128 21038-0 900089 control12.440793 250.4846256 381 21038-0 901157 control 6.477754 35.3079462 486 21038-0 901739 control 6.669404 77.1044173 582 21038-0 900313 control10.464065 233.8540385 972 21038-0 900527 control11.438740 194.8173368 125621038-0 900262 control14.472279 175.7577419 156521038-0 901475 control 2.015058 246.2465683 164121038-0 901216 control 4.416153 99.7496760 195721038-0 901618 control 6.669404 141.4459310 229121038-0 900563 control 3.025325 278.6264989 313121038-0 900363 control 5.470225 103.3293132 370421038-0 900872 control 9.434633 153.7875157 398421038-0 900766 control13.437371 269.4589484 2 00041-0 3810case17.368925 203.1979716 310 00041-0 4923case17.648186 168.8229783 444 00041-0 3842case16.375085 102.6136126 108200041-0 4078case16.813141 89.7548225 145900041-0 5005case14.817248 131.0459201 146400041-0 4816case16.082135 131.1120569 147000041-0 3495case15.323750 118.7034216 167700041-0 3991case 9.782340 169.1765831 184500041-0 4824case 8.520191 122.3348897 192800041-0 4599case16.651608 2.3051960 214200041-0 3146case15.164955 191.6823727 218400041-0 3220case15.526351 188.6667153 228300041-0 5239case18.269678 174.9620952 254200041-0 3536case10.910335 301.6238182 288300041-0 4787case13.527720 159.0956166 292100041-0 4058case17.845311 137.7700442 293200041-0 5015case 7.520876 101.6216590 364100041-0 4266case 5.497604 125.6831543 368300041-0 4360case 4.421629 187.2961108 372500041-0 4428case13.451060 157.4203222 376700041-0 4506case 6.507871 141.1115853 388900041-0 4455case12.147843 213.7489685 3 00709-0 5023case 2.004106 412.4962003 398 00709-0 3180case 5.234770 9.6108457 639 00709-0 3205case 4.974674 262.5951990 105800709-0 3788case 4.577686 281.6220685 170000709-0 3450case 4.156057 131.7354794 205000709-0 3183case 5.878165 0.3707844 248300709-0 4434case 2.162902 339.0410965 278900709-0 3849case 4.405201 405.9685980 328100709-0 3619case 5.541409 255.1460421 384200709-0 3943case 3.515400 624.2636701 401100709-0 5304case 3.312799 2.9206063 4 00174-0 4142case16.060232 240.4858235 13 00174-0 4244case 5.615331 NA 22 00174-0 4446case15.523613 223.3748681 57 00174-0 4292case 6.209445 168.6679707 100 00174-0 4314case 6.66 147.6358300 183 00174-0 3689case16.224503 0.5689179 270 00174-0 4208case 3.468856
[R] A better way to do this
Hello gurus, I have a dataframe containing two groups viz., 'control' and 'case', each of these groups contains longitudinal data for 100 subjects. I have to plot all these subjects on a single chart and then put a regression line for each of the group for all the subjects. I have written a function to do the chart grpcharts-function (dat, group,group2,molecule,cutoff){ dat2-dat[grep(group,dat$Group),] ylim=log2(c(min(dat2[,molecule],na.rm=T)+4,max(dat2[,molecule],na.rm=T)+1)) all.sub.id-dat2$Subject.ID if (group=='control'){ col=c('blue') }else{col=c('red')} if(group2=='case'){ col2=c('red') }else{ col2=c('blue')} uniq.sub.id-unique(all.sub.id) errcol-c() for (i in 1: length(uniq.sub.id)) { sub-dat2[grep(uniq.sub.id[i],dat2$Subject.ID),] sub- sub[order(sub$Age.at.Sample.Collection),] sub-sub[sub[,molecule]cutoff,] sub.id-uniq.sub.id[i] if (dim(sub)[1]=1) errcol-c(errcol, sub.id) if (dim(sub)[1]1) { par(new=TRUE) plot(log2(sub[,molecule])~sub$Age.at.Sample.Collection, ylab=paste('Log2_',molecule,sep=''),xlab=Age at Sample,pch=1, ylim=ylim, xlim=c(0,25),main=paste(group,'-',molecule)) mod-loess(log2(sub[,molecule])~Age.at.Sample.Collection, na.action=na.exclude, data=sub) pred-predict(mod) lines(pred~Age.at.Sample.Collection, data=sub,lwd=1, lty=1) } } dat2-dat2[order(dat2$Age.at.Sample.Collection),] mod-loess(log2(dat2[,molecule])~Age.at.Sample.Collection, na.action=na.exclude, data=dat2) pred-predict(mod) lines(pred~Age.at.Sample.Collection, data=dat2,lwd=2, lty=1,col=col) dat2-dat[grep(group2,dat$Group),] dat2-dat2[order(dat2$Age.at.Sample.Collection),] mod-loess(log2(dat2[,molecule])~Age.at.Sample.Collection, na.action=na.exclude, data=dat2) pred-predict(mod) lines(pred~Age.at.Sample.Collection, data=dat2,lwd=2, lty=1,col=col2) legend(c(20,20),c(ylim),c(group,group2), lty=1,lwd=2,col=c(col,col2), bty='n') print('done') } the function subsets the data based on the 'group' and plots the datapoints currently I am using a loop to assign the colors under two conditions. I need some pointers to assign the colors to the regression lines for the two groups without using a loop. thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/A-better-way-to-do-this-tp3536576p3536576.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] log transformation and mean question
I have question about log2 transformation and performing mean on log2 data. I am doing analysis for ELISA data. the OD values and the concentration values for the standards were log2 transformed before performing the lm. the OD values for samples were log2 transformed and coefficients of lm were applied to get the log2 concentration values. I then backtransformed these log2 concentrations and the trouble started. when i take the mean of log2 concentrations the value is different than the backtransformed concentrations. 100+1000/2 [1] 600 2^((log2(100)+log2(1000))/2) [1] 316.2278 What I am doing wrong to get the different values -- View this message in context: http://r.789695.n4.nabble.com/log-transformation-and-mean-question-tp3517825p3517825.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merging multiple columns from two dataframes
Hello, I have data in a dataframe with 139104 rows which is multiple of 96x1449. i have a phenotype file which contains the phenotype information for the 96 samples. the snp name is repeated 1449X96 samples. I haveto merge the two dataframes based on sid and sen. this is how my two dataframes look like dat-data.frame(snpname=rep(letters[1:12],12),sid=rep(1:12,each=12), genotype=rep(c('aa','ab','bb'), 12)) pheno-data.frame(sen=1:12,disease=rep(c('N','Y'),6), wellid=1:12) I have to merge or add the disease column and 3 other columns to the data file. I am unable to use merge in R. I have searched google, i guess i am not hitting the correct terms to get the answer. I would appreciate any input on this issue. thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/merging-multiple-columns-from-two-dataframes-tp3496341p3496341.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Clearing Console; of weeks of codes!
click in console window and type rm(list=ls(all=TRUE)), everything will be gone -- View this message in context: http://r.789695.n4.nabble.com/Clearing-Console-of-weeks-of-codes-tp3447506p3448041.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error for ttest
Hello all, I have arranged my data as per Dennis's suggestion in this post http://www.mail-archive.com/r-help@r-project.org/msg107156.html. the posted code works fine but when I try to apply it to my data, i get u2 - ddply(xxm, .(plateid, cytokine), as.data.frame.function(f)) Error in t.test.formula(conc ~ Self_T1D, data = df, na.rm = T) : grouping factor must have exactly 2 levels. Self_T1D has two levels N and Y I have used the ddply function to do the mean and sd for the same dataframe without any issues. I would appreciate help to solve this. Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/error-for-ttest-tp3448056p3448056.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error for ttest: solved
I knew that the NA's in my data were the root cause of the trouble, but did not find out how to get rid of them. Untill I found your another post mentioning to use 'na.omit' to remove the lines containing 'NA's and the problem got fixed after that. Thanks for the help and all the trouble you have to go thru. -- View this message in context: http://r.789695.n4.nabble.com/error-for-ttest-tp3448056p3449792.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Clearing Console; of weeks of codes!
Thanks, I thought that removing the list would take care of it. the question is I do not see a .Rhistory file in my current working directory, so where it is stored. it is not visible in C:\Program files\R either. Serarching the C;\ and D:\ drives shows some old .Rhistory files but not the recent ones. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Clearing-Console-of-weeks-of-codes-tp3447506p3449832.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding the 4 parameter logisitc regression
Thanks Dieter for the help. This is how I want plot(log(test$conc),fn(test$conc,15,3.5,600,1/2.5),type=l) # looks good points(log(test$conc),log(test$il10)) regards and happy holidays sharad -- View this message in context: http://r.789695.n4.nabble.com/understanding-the-4-parameter-logisitc-regression-tp3091588p3092628.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] understanding the 4 parameter logisitc regression
I have questions regarding test=data.frame(cbind(conc=c(25000, 12500, 6250, 3125, 1513, 781, 391, 195, 97.7, 48.4, 24, 12, 6, 3, 1.5, 0.001), il10=c(330269, 216875, 104613, 51372, 26842, 13256, 7255, 3049, 1849, 743, 480, 255, 241, 128, 103, 50))) nls(log(il10)~A+(B-A)/(1+(conc/xmid )^scal),data=test, + start = list(A=3.5, B=15, + xmid=600,scal=1/2.5)) Nonlinear regression model model: log(il10) ~ A + (B - A)/(1 + (conc/xmid)^scal) data: test A Bxmidscal 14.7051665 3.7964534 607.9822962 0.3987786 residual sum-of-squares: 0.1667462 I did not understand how these values A=3.5, B=15,xmid=600,scal=1/2.5 were obtained by Jim in the posting here http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg25500.html. I would appreciate a little help here to understand the 4-parameter logisitic regression for processing of standard curve for ELISA/MUltiplex Immunoassays. Thanks and happy holidays sharad -- View this message in context: http://r.789695.n4.nabble.com/understanding-the-4-parameter-logisitc-regression-tp3091588p3091588.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot creates a straigth line
Thanks Jim for the explanation. I will modify the code accordingly -- View this message in context: http://r.789695.n4.nabble.com/Plot-creates-a-straigth-line-tp3004090p3005569.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exact pattern match in grep for column headers
my question is exactly as described in this post http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9812.html i am doing the pattern search using a vector 'vars[vi]' where i cannot use '^vars[vi]$' for a exact pattern match -- View this message in context: http://r.789695.n4.nabble.com/grep-tp3004422p3005885.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exact pattern match in grep for column headers
Thanks I agree i did not asked the question correctly, but I solved the issue using the suggestions from this post. http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg23646.html -- View this message in context: http://r.789695.n4.nabble.com/grep-tp3004422p3006236.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding rows to column
sorry i got clik happy df2-df1[, c(3,5,7,9,11,13,15)] df2-df2[grep('ID', df2$Group), ] -- View this message in context: http://r.789695.n4.nabble.com/Adding-rows-to-column-tp3005607p3006302.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exact pattern match in grep for column headers
the current code is like this vidx-grep(paste('^',vars[vi],'$',sep=''),gsub([[:punct:]],,strrl1[[datbeg-1]]),ignore.case=T) where as the old one was vidx-grep(vars[vi],gsub([[:punct:]],,strrl1[[datbeg-1]]),ignore.case=T) -- View this message in context: http://r.789695.n4.nabble.com/grep-tp3004422p3006240.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding rows to column
If I understand correctly you want to create a new dataframe with selected columns which can be achieved this was as well, it will right away create a new dataframe with column headers df2-df1[ ,c(3,7,9,11,13,15)] -- View this message in context: http://r.789695.n4.nabble.com/Adding-rows-to-column-tp3005607p3006284.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subtraction based on two groups in a dataframe
I want the reshaped data to look like this. plate.id HYBwell.id rlt1.control1 well.id rlt1.control1 well.idrlt1.disease1 well.id rlt1.disease2 1 P1 SKOV3hyb A10.190 A2 0.210 B10.217B2 0.190 2P1 SKOV3hyb A3 0.205 A4 0.206 B30.371B4 0.56 Thanks Sharad On Thu, Oct 7, 2010 at 7:09 PM, djmuseR [via R] ml-node+2967676-1432920781-6...@n4.nabble.comml-node%2b2967676-1432920781-6...@n4.nabble.com wrote: Hi: Is this what you were looking for? plate.id well.id Group HYB rlt1 P1 A1 control1SKOV3hyb0.19 P1 A2 disease1SKOV3hyb0.21 P1 A3 control1SKOV3hyb0.205 P1 A4 disease1SKOV3hyb0.206 P1 B1 disease2SKOV3hyb0.217 P1 B2 control2SKOV3hyb0.646 P1 B3 disease2SKOV3hyb0.371 P1 B4 control2SKOV3hyb dfwide - reshape(df, idvar = c('plate.id', 'well.id', 'HYB'), timevar = 'Group', direction = 'wide') dfwide plate.id well.id HYB rlt1.control1 rlt1.disease1 rlt1.disease2 1 P1 A1 SKOV3hyb 0.190NANA 2 P1 A2 SKOV3hybNA 0.210NA 3 P1 A3 SKOV3hyb 0.205NANA 4 P1 A4 SKOV3hybNA 0.206NA 5 P1 B1 SKOV3hybNANA 0.217 6 P1 B2 SKOV3hybNANANA 7 P1 B3 SKOV3hybNANA 0.371 8 P1 B4 SKOV3hybNANANA rlt1.control2 1NA 2NA 3NA 4NA 5NA 6 0.646 7NA 8 0.560 HTH, Dennis On Thu, Oct 7, 2010 at 7:54 AM, 1Rnwb [hidden email]http://user/SendEmail.jtp?type=nodenode=2967676i=0 wrote: Hi The reshape suggestions works great on my previous data, but I am unable to make is work on the new dataset. It actually works but only gives me the output of single row, instead of 96 rows. The dataset has two control groups control 1 and control 2, two disease groups viz disease 1 and disease 2 a total of 384 values plate.idwell.id Group HYB rlt1 P1 A1 control1SKOV3hyb0.19 P1 A2 disease1SKOV3hyb0.21 P1 A3 control1SKOV3hyb0.205 P1 A4 disease1SKOV3hyb0.206 P1 B1 disease2SKOV3hyb0.217 P1 B2 control2SKOV3hyb0.646 P1 B3 disease2SKOV3hyb0.371 P1 B4 control2SKOV3hyb0.56 when I use ydat - reshape(ydat, idvar = c('plate.id','HYB'), timevar ='Group',direction = 'wide') I get plate.idwell.id.control1HYB.control1rlt1.control1 well.id.disease1 HYB.disease1rlt1.disease1 well.id.disease2HYB.disease2 rlt1.disease2 well.id.control2HYB.control2rlt1.control2 P1 A1 SKOV3hyb0.19A2 SKOV3hyb0.21 B1 SKOV3hyb0.217 B2 SKOV3hyb0.646 instead of 96 rows of data, only one row comes, i tried new.row.names but that is not working. I would appreciate the help. Thanks -- View this message in context: http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2966918.htmlhttp://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2966918.html?by-user=t Sent from the R help mailing list archive at Nabble.com. __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2967676i=1mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ [hidden email] http://user/SendEmail.jtp?type=nodenode=2967676i=2mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View message @ http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2967676.html To unsubscribe from subtraction based on two groups in a dataframe, click herehttp://r.789695.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2716104code
[R] Plot creates a straigth line
Hello all, I am using 'plot' to create standard curves for elisa data. when I use 'plot' with type='b' i get the points connected with lines and one straigth line from the lowest datapoint to the highest data point. how can i avoid/remove it from the figure. i am using R2.9.1, below is the example of the data. od-c(10, 8, 6,4,2,1, 10.5,7.8,6.4,3.8,2.1,0.95) cyto_conc=2650 # Highest cytokine concentration user defined cyto_std_conc -c(cyto_conc) for (i in 1:5) { cyto_conc = cyto_conc /3 cyto_std_conc -c(cyto_std_conc ,cyto_conc) } cyto_std_conc-log2(rep(cyto_std_conc,2)) cyto-cbind(cyto_std_conc,od) plot(cyto_std_conc,od, type='b') I have searched help using '?plot' in R as well as google, all the examples which are available online gives me the plot the way it is shown in the example. but when i use the plot for my data it gives me a straight line. thanks sharad -- View this message in context: http://r.789695.n4.nabble.com/Plot-creates-a-straigth-line-tp3004090p3004090.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] grep
Hi I have a script which is designed to gather data from individual columns from a file, which is an output from an instrument. the file has multiple sections and each a section has data under each column (vars), I am using the name of the column as a variable to gather the column ID using vidx-grep(vars[vi],gsub([[:punct:]],,strrl1[[datbeg-1]]),ignore.case=T) the vidx stores the column ID for each 'vars', which in subsequent step is stored in a temp vector for analysis strrl1[[datbeg-1]] is the position in the file where the data begins( the data is given below) This is working fine when i have all the unique names for 'vars' the trouble started when I started working with files having column names starting with exactly same alphabets for eg, Apo AII and Apo AI the vidx returns multiple column ids and in the following example it 'vidx' returns 3 and 5 LocationSample Apo AII Apo B Apo AI Apo CII Apo CIIIApo E Total Events 1(1,A1) PC1 32310 594755069 21856 66539 54589 321 2(1,B1) PC2 33772 275450452.5 20588 68813 45586 268 3(1,C1) PC3 25386 960 38045 12992 57239 28939.5 275 4(1,D1) PC4 23604 475 40056 14433 59969.5 19788 275 5(1,E1) PC5 13469 216 31967 890055937 13534 257 6(1,F1) PC6 11142.5 174.5 30025 946564848 11053 244 7(1,G1) PC7 1021129.5 11405 366150841 2466236 8(1,H1) S1 29339 7721.5 55777 14939 50864 11369 252 9(1,I1) S2 17315.5 248540010 10756.5 45471.5 5133239 10(1,J1)S3 18440 140647276.5 15425 44740 2815.5 264 11(1,K1)S4 19011 756 55982.5 12801 38148 1265273 12(1,L1)S5 6372278 28585 521010605 664 259 13(1,M1)S6 2608223 13819 25593143274 260 14(1,N1)S7 408.5 198 3775834 443 117.5 252 15(1,O1)S8 114.5 135 860 538 135 73.5242 Thanks Sharad -- View this message in context: http://r.789695.n4.nabble.com/grep-tp3004422p3004422.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subtraction based on two groups in a dataframe
Hi The reshape suggestions works great on my previous data, but I am unable to make is work on the new dataset. It actually works but only gives me the output of single row, instead of 96 rows. The dataset has two control groups control 1 and control 2, two disease groups viz disease 1 and disease 2 a total of 384 values plate.idwell.id Group HYB rlt1 P1 A1 control1SKOV3hyb0.19 P1 A2 disease1SKOV3hyb0.21 P1 A3 control1SKOV3hyb0.205 P1 A4 disease1SKOV3hyb0.206 P1 B1 disease2SKOV3hyb0.217 P1 B2 control2SKOV3hyb0.646 P1 B3 disease2SKOV3hyb0.371 P1 B4 control2SKOV3hyb0.56 when I use ydat - reshape(ydat, idvar = c('plate.id','HYB'), timevar ='Group',direction = 'wide') I get plate.idwell.id.control1HYB.control1rlt1.control1 well.id.disease1 HYB.disease1rlt1.disease1 well.id.disease2HYB.disease2 rlt1.disease2 well.id.control2HYB.control2rlt1.control2 P1 A1 SKOV3hyb0.19A2 SKOV3hyb0.21B1 SKOV3hyb0.217 B2 SKOV3hyb0.646 instead of 96 rows of data, only one row comes, i tried new.row.names but that is not working. I would appreciate the help. Thanks -- View this message in context: http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2966918.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loess with missing data points
Hello List, I have a longitudinal samples on multiple individuals, for initial analysis, i am doing some plots to see how the variable changes with the age. In some of the individuals one or two data points are missing, IL1Ra Age.at.Sample.Collection Subject.ID 6.575466 2.004106 00709-0 NA2.162902 00709-0 5.1154213.312799 00709-0 6.1196263.515400 00709-0 5.7056484.156057 00709-0 7.2988874.405201 00709-0 6.1950634.577686 00709-0 6.5748645.541409 00709-0 When I run cap-paste(sub.id,cases2$group[1],sep= ) plot(cases2$IL1Ra~cases2$Age.at.Sample.Collection, ylab=eo_conc,xlab=Age at Sample,pch=1, ylim=c(3,10), xlim=c(0,22),main=cap) points(cases2$MIP1b~cases2$Age.at.Sample.Collection,pch=2,ylim=c(1.5,10),col=red) points(cases2$MCP1~cases2$Age.at.Sample.Collection,,pch=3, ylim=c(1.5,10),col=brown) lines(predict(loess(cases2$IL1Ra~cases2$Age.at.Sample.Collection))~cases2$Age.at.Sample.Collection, lwd=1, lty=1) lines(predict(loess(cases2$MIP1b~cases2$Age.at.Sample.Collection))~cases2$Age.at.Sample.Collection, col=red, lwd=1, lty=1) lines(predict(loess(cases2$MCP1~cases2$Age.at.Sample.Collection))~cases2$Age.at.Sample.Collection,col=brown, lwd=1, lty=1) I get error Error in model.frame.default(formula = predict(loess(cases2$IL1Ra ~ cases2$Age.at.Sample.Collection)) ~ : variable lengths differ (found for 'cases2$Age.at.Sample.Collection') In addition: There were 50 or more warnings (use warnings() to see the first 50) I tried using na.action=na.omit, which is not working at all. I would appreciate some pointers in this regards to get these charts. Thanks -- View this message in context: http://r.789695.n4.nabble.com/loess-with-missing-data-points-tp2956851p2956851.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subtraction based on two groups in a dataframe
Thanks for the help. Sharad On Mon, Sep 27, 2010 at 9:12 PM, Remko Duursma [via R] ml-node+2716469-935075351-6...@n4.nabble.comml-node%2b2716469-935075351-6...@n4.nabble.com wrote: Try something like this: dfr - read.table(textConnection(plate.id well.id Group HYB rlt1 1 P1 A1 Control SKOV3hyb 0.190 2 P1 A2 Control SKOV3hyb 0.210 3 P1 A3 Control SKOV3hyb 0.205 4 P1 A4 Control SKOV3hyb 0.206 5 P1 A5 Control SKOV3hyb 0.184 385 P1 A1ovca SKOV3hyb 0.184 386 P1 A2ovca SKOV3hyb 0.229 387 P1 A3ovca SKOV3hyb 0.214 388 P1 A4ovca SKOV3hyb 0.226 389 P1 A5ovca SKOV3hyb 0.217 )) difs - lapply(split(dfr,dfr$plate.id), function(x)x$rlt1[x$Group == Control] - x$rlt1[x$Group == ovca]) dfr$Diff - Reduce(c,difs) greetings, Remko -- View message @ http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2716469.html To unsubscribe from subtraction based on two groups in a dataframe, click herehttp://r.789695.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2716104code=c2JwdXJvaGl0QGdtYWlsLmNvbXwyNzE2MTA0fDU4ODg0MTYwOQ==. -- View this message in context: http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2719364.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] subtraction based on two groups in a dataframe
Hello I have a data set like below: plate.id well.id Group HYB rlt1 1 P1 A1 Control SKOV3hyb 0.190 2 P1 A2 Control SKOV3hyb 0.210 3 P1 A3 Control SKOV3hyb 0.205 4 P1 A4 Control SKOV3hyb 0.206 5 P1 A5 Control SKOV3hyb 0.184 385 P1 A1ovca SKOV3hyb 0.184 386 P1 A2ovca SKOV3hyb 0.229 387 P1 A3ovca SKOV3hyb 0.214 388 P1 A4ovca SKOV3hyb 0.226 389 P1 A5ovca SKOV3hyb 0.217 390 P1 A6ovca SKOV3hyb 0.207 each plate.id contains 384 readings for Group==Control and the same plate.id will contain 384 readings for Group=='ovca' to give a total of 768 values for P1 and so on for other plate ID's. I have to take the subtract the values of rlt1 colum between the two groups based on Plate ID. currently I am using newdat2$diff-(newdat2[1:5,5]-newdat2[6:10,5])/newdat2[1:5,5]*100 newdat2 plate.id well.id Group HYB rlt1 diff 1 P1 A1 Control SKOV3hyb 0.190 3.157895 2 P1 A2 Control SKOV3hyb 0.210 -9.047619 3 P1 A3 Control SKOV3hyb 0.205 -4.390244 4 P1 A4 Control SKOV3hyb 0.206 -9.708738 5 P1 A5 Control SKOV3hyb 0.184 -17.934783 385 P1 A1ovca SKOV3hyb 0.184 3.157895 386 P1 A2ovca SKOV3hyb 0.229 -9.047619 387 P1 A3ovca SKOV3hyb 0.214 -4.390244 388 P1 A4ovca SKOV3hyb 0.226 -9.708738 389 P1 A5ovca SKOV3hyb 0.217 -17.934783 I have tried apply(newdat2, 1, function(x) tapply(x, plate.id, newdat2$Control-newdat2$ovca))) I am looking for a more simple way to calculate the percent difference between the each value (based on well.id) for the two groups for 100's of plate.ids. I would appreciate help in getting this solved. Thanks -- View this message in context: http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2716104.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extracting pvalues from ttest
okay fixed it by putting c in quote marks. 1Rnwb wrote: Hello, I am using B as a vector to store all the t.tests. since i am a newbie to both R and statistics I am not sure if B is the list. Also I see c used in the do.call formula and do not know what it is being used for. I used aggregate but getting this error Error in aggregate.data.frame(eo, eo$PlateID, function(.sub) t.test(ENA78 ~ : 'by' must be a list. As i mention in my OP that I am using is function from an earlier post. any help is appreciated. Thanks Sharad Jun Shen-3 wrote: I never used by. Is B a list? If not, I am not sure if lapply can take it. Try aggregate(). On Fri, Aug 28, 2009 at 10:53 AM, 1Rnwb sbpuro...@gmail.com wrote: Hello list, I have a similar issue as this post http://tolstoy.newcastle.edu.au/R/e6/help/09/04/11438.html#options2 and I used the suggestion provided by Jorge with modifications to my data do.call(c,lapply(your_list_with_the_t_tests,function(x) x$p.value)) but I am getting the following error after excuting the code B-by(eo,eo$PlateID, function(.sub) t.test(mcp1~Self_T1D,data=.sub, na.rm=T)) #ttest platewise do.call(c,lapply(B, function(x) x$p.value)) Error in do.call(c, lapply(B, function(x) x$p.value)) : 'what' must be a character string or a function here B is equal to your_list_with_the_t_tests. is something i am doing wrong -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25192381.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25349826.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extracting pvalues from ttest
Hello, I am using B as a vector to store all the t.tests. since i am a newbie to both R and statistics I am not sure if B is the list. Also I see c used in the do.call formula and do not know what it is being used for. I used aggregate but getting this error Error in aggregate.data.frame(eo, eo$PlateID, function(.sub) t.test(ENA78 ~ : 'by' must be a list. As i mention in my OP that I am using is function from an earlier post. any help is appreciated. Thanks Sharad Jun Shen-3 wrote: I never used by. Is B a list? If not, I am not sure if lapply can take it. Try aggregate(). On Fri, Aug 28, 2009 at 10:53 AM, 1Rnwb sbpuro...@gmail.com wrote: Hello list, I have a similar issue as this post http://tolstoy.newcastle.edu.au/R/e6/help/09/04/11438.html#options2 and I used the suggestion provided by Jorge with modifications to my data do.call(c,lapply(your_list_with_the_t_tests,function(x) x$p.value)) but I am getting the following error after excuting the code B-by(eo,eo$PlateID, function(.sub) t.test(mcp1~Self_T1D,data=.sub, na.rm=T)) #ttest platewise do.call(c,lapply(B, function(x) x$p.value)) Error in do.call(c, lapply(B, function(x) x$p.value)) : 'what' must be a character string or a function here B is equal to your_list_with_the_t_tests. is something i am doing wrong -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25192381.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25348965.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting pvalues from ttest
Hello list, I have a similar issue as this post http://tolstoy.newcastle.edu.au/R/e6/help/09/04/11438.html#options2 and I used the suggestion provided by Jorge with modifications to my data do.call(c,lapply(your_list_with_the_t_tests,function(x) x$p.value)) but I am getting the following error after excuting the code B-by(eo,eo$PlateID, function(.sub) t.test(mcp1~Self_T1D,data=.sub, na.rm=T)) #ttest platewise do.call(c,lapply(B, function(x) x$p.value)) Error in do.call(c, lapply(B, function(x) x$p.value)) : 'what' must be a character string or a function here B is equal to your_list_with_the_t_tests. is something i am doing wrong -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25192381.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help for t.test using by
any one 1Rnwb wrote: I am trying to do ttest for each plate which has equal number of disease and controls. by searching this forum I found one posting suggesting OP to use by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)). when i modified this for my use I used to get the pvalues for each plate, recently upgraded to R2.9.x and now i am getting following error when i use this by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)) Error in t.test.formula(IL1Ra ~ Group, data = .sub) : grouping factor must have exactly 2 levels I checked my data file and the plate ID has P16-P47 and the disease column is Y/N. I have search all but could not locate the answer. Can anyone suggest me the direction where i am going wrong. for more detail i amm posting a part of my data. SampleID PlateID Sex Disease DurationAge prt1prt2 prt3prt4 1 P16 F N 25.33282811 836.08979 20.04582692 295.74 11731.43 2 P16 F N 32.74912883 243.0652116 53.16487056 383.63 4451.36 3 P16 M N 3.49961999 181.5587298 23.24604762 522.52 325.52 4 P16 M N 5.249771666 261.0978097 19.69024684 833.61 2229.04 5 P16 M N 39.16612385 237.334794 83.97284692 694.03 1204.36 6 P16 F N 33.49929145 540.486536 29.69569346 895.36 72105.75 7 P16 F N 3.915997361 5215.378446 35.44324704 1023.63 101680.69 8 P16 F N 33.49929145 466.5188732 12.93422535 814.26 7169.61 9 P16 F N 38.1661348 706.5117791 19.69024684 331.62 7296.72 10P16 M N 0.916030215 242.3011559 36.40117263 90.135962.08 11P16 F Y 14975.2542.08281552 133.8052501 29.0570764 260.55 1280.29 12P16 M Y 1095.75 40.41593932 247.6495456 19.69024684 161.64 6685.6 13P16 F Y 292225.08300169 231.6043765 9.022844487 902.53 37571.39 14P16 F Y 12053.2537.49924765 158.6370595 24.90606549 1.63471.15 15P16 F Y 14610 76.58209602 278.3837309 41.51010914 152.13 16285.49 16P16 F Y 3287.25 49.58239171 128.4568603 17.91234645 274.99 41823.21 17P17 M N 2.333079994 397.4440508 55.20987654 366.37 90011.27 18P17 F N 4.749435461 222.0839813 73.62489675 271.65 903.89 19P17 F N 1.749468315 676.8904636 47.7037037 721.19 663.15 20P17 M N 33.24946503 413.712486 27.42386831 611.64 4195.86 21P17 F N 15.4162131 346.9913086 30.71604938 302.29 2151.47 22P17 F N 33.3327405 2598.071161 107.8088094 1800.44 102005.12 23P17 M N 9.832656179 3296.535581 54.1563786 2642.73 676.78 24P17 F N 3.749446413 488.2589867 15.29151952 562.88 11619.62 25P17 M N 9.749380705 159.1536586 23.41690259 132.64 931.14 26P17 M Y 12053.2550.91548265 173.7764722 18.90280088 52.25 15962.05 27P17 M Y 3652.5 25.83248096 264.8254141 35.32510288 497.33 15504.95 28P17 F Y 28.41607073 415.3599225 35.0617284 1600.67 14224.39 29P17 F Y 6209.25 60.74882219 213.7280879 44.41152263 111.36 9018.48 30P17 M Y 4748.25 47.33258719 264.0016959 31.24279835 366.81 3809.83 31P17 M Y 16071 54.49906148 112.4128794 34.40329218 114.56 1727.02 32P17 M Y 7670.25 52.33253243 145.5753317 32.2962963 44.92 15264.84 33P17 M Y 876631.74913978 220.2561296 34.40329218 130.31 2377.36 34P17 F Y 8400.75 40.83231669 194.6662059 48.09876543 407.83 19587.61 35P17 M Y 12053.2536.1661567 212.1613578 96.51775947 621.42 3269.9 36P17 M Y 8035.5 57.91540599 115.2852178 24.79012346 282.88 8960.27 37P17 M Y 5478.75 36.33270765 160.4592669 40.72427984 102.32 5006.77 38P17 F Y 9496.5 34.74910692 329.8991551 40.32921811 417.32 248857.58 39P18 F N 14.2496731
Re: [R] Fitting a logistic regression
with my limited understanding, I am not surprised to see this data fitting nicely at the end just by eyeballing at it. the reaction at the early time point is not completed as the time passes which is close to 20 units the reaction generates more metabolite to be measured reliably your t=0 and t=10 are basically the same, if i limit the digits to 2 then the values will be 0.20. you can do the log transform and then try to fit it. Dani Valverde-4 wrote: Hello, I have this data: Time AMP 0 0.200 10 0.1958350 20 0.2914560 40 0.6763628 60 0.8494534 90 0.9874526 120 1.0477692 where AMP is the concentration of this metabolite with time. If you plot the data, you can see that it could be fitted using a logistic regression. For this purpose, I used this code: AMP.nls - nls(AMP~SSlogis(Time,Asym, xmid, scal), data = concentrations,model=T) When plotting the fitted function, it seems that it fits quite well at the end of the time. However, at the beginning it seems that the fit is not so good. How can I achieve a better fit? Forgive me if it is a stupid question, but I am just starting with non linear regression. Thank you, Dani -- [?] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Fitting-a-logistic-regression-tp25041444p25043712.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help for t.test using by
Thanks for the reply, and sorry for not being clear, I have ELISA data for 50 plates, equal number of disease and control samples are located on each plates. I need to do the ttest between each proteins listed as prt1, prt2... prt50 on all the plates 1-50, however for some proteins i have data for 40 plates and that is creating the problem for me when I run by(eo,eo$PlateID, function(.sub) t.test(prt1~Disease,data=.sub)). If i only take the data for 40 plates, this command works, unfortunately I do not want to make multiple copies of the same data over to do things. Similarlyby(eo,eo$sex,function(.sub) t.test(prt1~Disease,data=.sub)) is also not working when I select the data for 40 plates. I used these two formulas earlier sucessfully. I am uploading a part of data as a delim file for sample http://www.nabble.com/file/p25051220/r..txt r..txt . Thanks 1Rnwb wrote: any one 1Rnwb wrote: I am trying to do ttest for each plate which has equal number of disease and controls. by searching this forum I found one posting suggesting OP to use by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)). when i modified this for my use I used to get the pvalues for each plate, recently upgraded to R2.9.x and now i am getting following error when i use this by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)) Error in t.test.formula(IL1Ra ~ Group, data = .sub) : grouping factor must have exactly 2 levels I checked my data file and the plate ID has P16-P47 and the disease column is Y/N. I have search all but could not locate the answer. Can anyone suggest me the direction where i am going wrong. for more detail i amm posting a part of my data. SampleID PlateID Sex Disease DurationAge prt1prt2 prt3prt4 1P16 F N 25.33282811 836.08979 20.04582692 295.74 11731.43 2P16 F N 32.74912883 243.0652116 53.16487056 383.63 4451.36 3P16 M N 3.49961999 181.5587298 23.24604762 522.52 325.52 4P16 M N 5.249771666 261.0978097 19.69024684 833.61 2229.04 5P16 M N 39.16612385 237.334794 83.97284692 694.03 1204.36 6P16 F N 33.49929145 540.486536 29.69569346 895.36 72105.75 7P16 F N 3.915997361 5215.378446 35.44324704 1023.63 101680.69 8P16 F N 33.49929145 466.5188732 12.93422535 814.26 7169.61 9P16 F N 38.1661348 706.5117791 19.69024684 331.62 7296.72 10 P16 M N 0.916030215 242.3011559 36.40117263 90.135962.08 11 P16 F Y 14975.2542.08281552 133.8052501 29.0570764 260.55 1280.29 12 P16 M Y 1095.75 40.41593932 247.6495456 19.69024684 161.64 6685.6 13 P16 F Y 292225.08300169 231.6043765 9.022844487 902.53 37571.39 14 P16 F Y 12053.2537.49924765 158.6370595 24.90606549 1.63471.15 15 P16 F Y 14610 76.58209602 278.3837309 41.51010914 152.13 16285.49 16 P16 F Y 3287.25 49.58239171 128.4568603 17.91234645 274.99 41823.21 17 P17 M N 2.333079994 397.4440508 55.20987654 366.37 90011.27 18 P17 F N 4.749435461 222.0839813 73.62489675 271.65 903.89 19 P17 F N 1.749468315 676.8904636 47.7037037 721.19 663.15 20 P17 M N 33.24946503 413.712486 27.42386831 611.64 4195.86 21 P17 F N 15.4162131 346.9913086 30.71604938 302.29 2151.47 22 P17 F N 33.3327405 2598.071161 107.8088094 1800.44 102005.12 23 P17 M N 9.832656179 3296.535581 54.1563786 2642.73 676.78 24 P17 F N 3.749446413 488.2589867 15.29151952 562.88 11619.62 25 P17 M N 9.749380705 159.1536586 23.41690259 132.64 931.14 26 P17 M Y 12053.2550.91548265 173.7764722 18.90280088 52.25 15962.05 27 P17 M Y 3652.5 25.83248096 264.8254141 35.32510288 497.33 15504.95 28 P17 F Y 28.41607073 415.3599225 35.0617284 1600.67 14224.39 29 P17 F Y 6209.25 60.74882219 213.7280879 44.41152263 111.36 9018.48 30 P17 M Y 4748.25 47.33258719 264.0016959 31.24279835 366.81 3809.83 31 P17 M Y 16071 54.49906148
[R] need help for t.test using by
I am trying to do ttest for each plate which has equal number of disease and controls. by searching this forum I found one posting suggesting OP to use by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)). when i modified this for my use I used to get the pvalues for each plate, recently upgraded to R2.9.x and now i am getting following error when i use this by(eo,PlateID, function(.sub) t.test(IL1Ra~Group,data=.sub)) Error in t.test.formula(IL1Ra ~ Group, data = .sub) : grouping factor must have exactly 2 levels I checked my data file and the plate ID has P16-P47 and the disease column is Y/N. I have search all but could not locate the answer. Can anyone suggest me the direction where i am going wrong. for more detail i amm posting a part of my data. SampleIDPlateID Sex Disease DurationAge prt1prt2 prt3prt4 1 P16 F N 25.33282811 836.08979 20.04582692 295.74 11731.43 2 P16 F N 32.74912883 243.0652116 53.16487056 383.63 4451.36 3 P16 M N 3.49961999 181.5587298 23.24604762 522.52 325.52 4 P16 M N 5.249771666 261.0978097 19.69024684 833.61 2229.04 5 P16 M N 39.16612385 237.334794 83.97284692 694.03 1204.36 6 P16 F N 33.49929145 540.486536 29.69569346 895.36 72105.75 7 P16 F N 3.915997361 5215.378446 35.44324704 1023.63 101680.69 8 P16 F N 33.49929145 466.5188732 12.93422535 814.26 7169.61 9 P16 F N 38.1661348 706.5117791 19.69024684 331.62 7296.72 10 P16 M N 0.916030215 242.3011559 36.40117263 90.135962.08 11 P16 F Y 14975.2542.08281552 133.8052501 29.0570764 260.55 1280.29 12 P16 M Y 1095.75 40.41593932 247.6495456 19.69024684 161.64 6685.6 13 P16 F Y 292225.08300169 231.6043765 9.022844487 902.53 37571.39 14 P16 F Y 12053.2537.49924765 158.6370595 24.90606549 1.63471.15 15 P16 F Y 14610 76.58209602 278.3837309 41.51010914 152.13 16285.49 16 P16 F Y 3287.25 49.58239171 128.4568603 17.91234645 274.99 41823.21 17 P17 M N 2.333079994 397.4440508 55.20987654 366.37 90011.27 18 P17 F N 4.749435461 222.0839813 73.62489675 271.65 903.89 19 P17 F N 1.749468315 676.8904636 47.7037037 721.19 663.15 20 P17 M N 33.24946503 413.712486 27.42386831 611.64 4195.86 21 P17 F N 15.4162131 346.9913086 30.71604938 302.29 2151.47 22 P17 F N 33.3327405 2598.071161 107.8088094 1800.44 102005.12 23 P17 M N 9.832656179 3296.535581 54.1563786 2642.73 676.78 24 P17 F N 3.749446413 488.2589867 15.29151952 562.88 11619.62 25 P17 M N 9.749380705 159.1536586 23.41690259 132.64 931.14 26 P17 M Y 12053.2550.91548265 173.7764722 18.90280088 52.25 15962.05 27 P17 M Y 3652.5 25.83248096 264.8254141 35.32510288 497.33 15504.95 28 P17 F Y 28.41607073 415.3599225 35.0617284 1600.67 14224.39 29 P17 F Y 6209.25 60.74882219 213.7280879 44.41152263 111.36 9018.48 30 P17 M Y 4748.25 47.33258719 264.0016959 31.24279835 366.81 3809.83 31 P17 M Y 16071 54.49906148 112.4128794 34.40329218 114.56 1727.02 32 P17 M Y 7670.25 52.33253243 145.5753317 32.2962963 44.92 15264.84 33 P17 M Y 876631.74913978 220.2561296 34.40329218 130.31 2377.36 34 P17 F Y 8400.75 40.83231669 194.6662059 48.09876543 407.83 19587.61 35 P17 M Y 12053.2536.1661567 212.1613578 96.51775947 621.42 3269.9 36 P17 M Y 8035.5 57.91540599 115.2852178 24.79012346 282.88 8960.27 37 P17 M Y 5478.75 36.33270765 160.4592669 40.72427984 102.32 5006.77 38 P17 F Y 9496.5 34.74910692 329.8991551 40.32921811 417.32 248857.58 39 P18 F N 14.2496731 538.5430144 54.34303351 396
Re: [R] R Codes for fitting Logistic Regression for Multivaraite Data
usually i go thru the manuals of the libraries and the data attached with the libraries to get the code working for my data. not a good way but usually it works out. Nimal Fernando wrote: Hi It would be a great help if someone can direct me to access some existing R codes for fitting Logistic regression models for Multivariate data. I want to find some Robust Estimates (M) for these models. Thanks a lot Best Regards Nimal [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/R-Codes-for-fitting-Logistic-Regression-for-Multivaraite-Data-tp24706374p24757203.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Antw: How to extract the upper xlim and ylim of my plot?
use hilox-range.x=range(x variable) and hiloy-range.y=range(y variable) or store these values in vectors to be later on user as xlim=hilox, ylim=hiloy Frank Bloos wrote: You may want to use the function corner.label from the plotrix-package. Frank Mark Na mtb...@gmail.com 21.07.2009 23:03 Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e. plot(log(all$SR,10)~log(all$AREA,10)) text(.1*max(xlim),.9*max(ylim),text to be placed) (I know how to give absolute coordinates for text location, but I wish to use relative coordinates). My code (above) doesn't work because I don't know how to properly extract the upper xlim and ylim values. Does anyone know how I could extract the upper xlim and ylim values (without using max(x-variable) or max (y-variable)...I wish to keep this as general as possible and not point to the original data. Thanks in advance, Mark [[alternative HTML version deleted]] Universitätsklinikum Jena Körperschaft des öffentlichen Rechts und Teilkörperschaft der Friedrich-Schiller-Universität Jena BachstraÃe 18, 07743 Jena Verwaltungsratsvorsitzender: Prof. Dr. Walter Bauer-Wabnegg; Medizinischer Vorstand: Prof. Dr. Klaus Höffken; Wissenschaftlicher Vorstand: Prof. Dr. Klaus Benndorf; Kaufmännischer Vorstand und Sprecher des Klinikumsvorstandes Rudolf Kruse Bankverbindung: Sparkasse Jena; BLZ: 830 530 30; Kto.: 221; Gerichtsstand Jena Steuernummer: 161/144/02978; USt.-IdNr. : DE 150545777 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Antw%3A--How-to-extract-the-upper-xlim-and-ylim-of-my-plot--tp24619947p24757330.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Newbie in R: Reading .txt files and storing the 'numbers' in a vector
I am also a newbie, but here are the few thing i do eo=read.table(file=path where you have saved your text file/xxx.txt,header=T, ) #this will only read excelfiles saved as *.csv file attach(eo) #attach the data names(eo) go to this website http://www.statmethods.net/stats here is how to store numbers as vectors a-c(1,2,3,4,5,6,7) here is how i means as vector d-aggregate(LMMP8,list(PlateID,Self_T1D),mean, na.rm=T) I would suggest u to search for website for R tutorials here are some good ones go to this website http://www.statmethods.net/stats http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_ttest.html this one has all the codes you can change them according to your data http://www3.imperial.ac.uk/pls/portallive/docs/1/1171930.TXT http://www.mayin.org/ajayshah/KB/R/index.html also download the book by verjani it would be a great help to you. Patrick Schorderet wrote: Hello everybody, I'm a newbie in R and just went through an introduction class recently. Here's my problem. I have 2 text files (.txt) with plain numbers ('doubles' for those who know c++) ordered into 2 columns as below: coordinate1 value1 coordinate2 value2 coordinate3 value3 ... ... coordinateN valueN I would like to write a small programme in which i would: 1. take all values of file 1 and store them in a vector 2. substract to those all values of file 2 (one by one) and store the result in a new vector 3. Create a sliding window of chosen size and calculate the mathematical average and store these averages in a new vector 4. Plot the different graphes with a bar plot So I wrote a c++ script that does the first parts and writes the averages in a output.txt file (which I have up and running). Unfortunately, I seem to fail in reading these as numbers and putting them into a vector (in the R environment). I can read the file , but this is what I get: z=scan(file = /Users/NCCRGENETICS/Desktop/testRnumbers.txt, what = double) Read 19 items z [1] {\\rtf1\\ansi\\ansicpg1252\\cocoartf949\\cocoasubrtf430 [2] {\\fonttbl\\f0\\fswiss\\fcharset0 [3] Helvetica;} [4] {\\colortbl;\\red255\\green255\\blue255;} [5] \\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww9000\ \viewh8400\\viewkind0 [6] \\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\ \tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\ql\\qnatural\\pardirnatural [7] \\f0\\fs24 [8] \\cf0 [9] 13\\ // This is where my file should start reading the numbers I see in the window when I open it with textedit [10] 27\\ [11] 39\\ [12] 48\\ [13] 34\\ [14] 17\\ [15] 23\\ [16] 45\\ [17] 23\\ [18] 4\\ [19] } Thanks so much to any of you who could provoid a little help... I'm getting nuts. Patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Newbie-in-R%3A-Reading-.txt-files-and-storing-the-%27numbers%27-in-a-vector-tp24714734p24757501.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re gression using age and Duration of disease as a continous factors
Thanks Steve,Thanks for the explanation, I agree the question is too vague, I do not what a regression is I have switched to R a couple of months ago, after working in Excel for a long time. I also know the lm, glm functions in R. but due to my data I am completely lost. it looks like the experts individuals just come to poke fun at our expesense who has no background of statistics. I have a 8 proteins and I have two groups with 840 samples in control and 1140 samples in diseases further stratified by sex, draw age, duration of disease. all these groups and sub groups is making the thing very confusing as how to do the regression in R. the pupose is to show the changes in the levels of these proteins as the disease progress or changes in their levels with respect to progression in age, effect of gender, SNPs for these proteins, it is a pretty big dataset. The suggestion that consult the statistician is kind of funny as the statistician in my center is my co-mentor and from past 5 years he is sitting on the data without any output. I am not here to ask someone to do my data analysis, but to get an understanding of the process as well as a proper direction to look for the analysis. after all I do have to explain all these things to my boss as well. Thanks Steve Lianoglou-6 wrote: On Jul 20, 2009, at 5:30 PM, 1Rnwb wrote: I have read that multiple times without understanding anything. If that's the case, then perhaps you should follow Greg's first piece of advice: Greg Snow-2 wrote: If you need an explanation of what regression means, then you need to take a course or 2 at your local university, or at least hire a statistical consultant. We're not trying to be rude, but your question is quite ill formed, and no one can really help you: Please explain me as what it means and how this analysis can be done using R and which library(ies) are needed. It's not clear what you do/don't understand, and your problem statement is too vague for anyone to tell you more. It seems like you're saying you don't understand what regression is, in which case a simple email will not help you. Simply put regression is a method to predict a (typically) continuous output by some combination of inputs, eg. predicting someone's height by knowing their weight and shoe size (these are continuous variables, too). It looks like in your case, your inputs are the continuous factors of your email subject, which are age and duration of disease? You haven't even mentioned what it is you are trying to predict. Survival? The thing is, as soon as one puts something in simple terms, it's often wrong -- which is why Greg suggested taking a class or hiring someone to help you. Anyway, I'm assuming you must know what regression is, otherwise you wouldn't be looking to know how to do it. One way to perform linear regression in R is using the lm function. Type ?lm at the R prompt for help. I thought this forum is for help. now i know what the statistician in my dept does all day long It is for help -- you'll see it's quite active around here. It's *not* for soliciting other people to do your analysis for you, which is how your email comes across. All of us have our own work to do, but are here to help if you're stuck on something *in particular* ... perhaps you can do a bit more legwork and rephrase your question in a more meaningful way. -steve -- Steve Lianoglou Graduate Student: Physiology, Biophysics and Systems Biology Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Regression-using-age-and-Duration-of-disease-as-a-continous-factors-tp24574133p24591056.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dot plot with several points for 2 categories
I use the long way, you might have to play around with my script to get is correct. once you get it to work, you can add as many points to reflect, median, percentile etc. ## generatiing vectors for Group1 a-LMMP8[Self_T1D==N] w - a[!is.na(a)] length(w) c-mean(a, na.rm=TRUE) c n-as.integer(length(w)/7) n n4- length(w)-6*n n4 ###Generating vectors for T1D b-LMMP8[Self_T1D==Y] x - b[!is.na(b)] length(x) d-mean (b, na.rm=TRUE) d m-as.integer(length(x)/7) m m4- length(x)-6*m m4 u-append(w, x, after = length(w)) length(u) x-c(rep(1:6,n),rep(7,n4), rep(11:16,m),rep(17,m4)) length(x) #Plotting the data plot(x,u, ylab=Log MMP8,pch=19,cex.lab=1.5,lty=2,cex=1.1, cex.axis=1.25,xaxt=n) points(4,c,pch=25,col=red,lwd=5) points(14,d,pch=25,col=red,lwd=5) jaregi wrote: I'm trying to wean myself off the very limited capabilities of Excel and Oo. Currently, I am trying to make a plot showing several values for 2 categories in a dot blot (see http://www.nabble.com/file/p24538360/Picture%2B1.png Picture+1.png except that the x axis should contain the category not a number, which was the only way to coax Excel into displaying a plot like this). I started working through some tutorials but the example didn't quite fit what I was looking for. The closest was the car and mpg example but it 1 value per name whereas I need several value per category. Does anybody know this of the top of your expert heads? This would be a great help. I already burned a few hours without getting closer to the solution.. Best, j -- View this message in context: http://www.nabble.com/dot-plot-with-several-points-for-2-categories-tp24538360p24573397.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] heatmap plot
since heatmap is a graphic image it needs the graphics library. you can see these two in the examples for heatmap. require(graphics); require(grDevices) Markus Mühlbacher wrote: Dear R community! I am trying to create a heatmap based on the following data. As you can see the diagonal (0,0 to 10,10) is always 0). If I run the heatmap command like i posted it I get a graph with horizontal lines. What is my mistake? heatmap(activity.matrix, Rowv = NA, Colv = NA, scale=column, xlab=x Compounds, ylab=y Compounds, col=topo.colors(100)) activity.matrix [,1] [,2] [,3][,4] [,5] [,6] [1,] 0.000 -0.1017802 0.3635007 0.62522118 0.8869417 -0.4652809 [2,] 0.1017802 0.000 0.4652809 0.72700138 0.9887219 -0.3635007 [3,] -0.3635007 -0.4652809 0.000 0.26172050 0.5234410 -0.8287816 [4,] -0.6252212 -0.7270014 -0.2617205 0. 0.2617205 -1.0905021 [5,] -0.8869417 -0.9887219 -0.5234410 -0.26172050 0.000 -1.356 [6,] 0.4652809 0.3635007 0.8287816 1.09050206 1.356 0.000 [7,] -0.2471805 -0.3489607 0.1163202 0.37804072 0.6397612 -0.7124613 [8,] 1.0032619 0.9014817 1.3667626 1.62848308 1.8902036 0.5379810 [9,] -0.6833813 -0.7851615 -0.3198806 -0.05816011 0.2035604 -1.1486622 [10,] 1.0759620 0.9741818 1.4394627 1.70118322 1.9629037 0.6106812 [,7][,8][,9] [,10] [1,] 0.2471805 -1.00326190 0.68338129 -1.07596204 [2,] 0.3489607 -0.90148171 0.78516149 -0.97418184 [3,] -0.1163202 -1.36676259 0.31988061 -1.43946272 [4,] -0.3780407 -1.62848308 0.05816011 -1.70118322 [5,] -0.6397612 -1.89020358 -0.20356039 -1.96290371 [6,] 0.7124613 -0.53798102 1.14866217 -0.61068116 [7,] 0.000 -1.25044237 0.43620083 -1.32314250 [8,] 1.2504424 0. 1.68664319 -0.07270014 [9,] -0.4362008 -1.68664319 0. -1.75934333 [10,] 1.3231425 0.07270014 1.75934333 0. Thanks in advance. Greets, Markus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/heatmap-plot-tp24572168p24574102.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re gression using age and Duration of disease as a continous factors
Please explain me as what it means and how this analysis can be done using R and which library(ies) are needed. Thanks -- View this message in context: http://www.nabble.com/Regression-using-age-and-Duration-of-disease-as-a-continous-factors-tp24574133p24574133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re gression using age and Duration of disease as a continous factors
I have read that multiple times without understanding anything. Greg Snow-2 wrote: If you need an explanation of what regression means, then you need to take a course or 2 at your local university, or at least hire a statistical consultant. If you understand regression and just need the explanation of how to do it using R, then read section 11 (as well as everything else) of An Introduction to R. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of 1Rnwb Sent: Monday, July 20, 2009 11:30 AM To: r-help@r-project.org Subject: [R] Re gression using age and Duration of disease as a continous factors Please explain me as what it means and how this analysis can be done using R and which library(ies) are needed. Thanks -- View this message in context: http://www.nabble.com/Regression-using- age-and-Duration-of-disease-as-a-continous-factors- tp24574133p24574133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Regression-using-age-and-Duration-of-disease-as-a-continous-factors-tp24574133p24577937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re gression using age and Duration of disease as a continous factors
I thought this forum is for help. now i know what the statistician in my dept does all day long Rolf Turner-3 wrote: On 21/07/2009, at 5:30 AM, 1Rnwb wrote: Please explain me as what it means and how this analysis can be done using R and which library(ies) are needed. Thanks Go stick your head in a pig! (***) cheers, Rolf Turner (***) Motto of the Sirius Cybernetics Corporation --- see ``The Hitchhiker's Guide to the Galaxy''. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Regression-using-age-and-Duration-of-disease-as-a-continous-factors-tp24574133p24577992.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to do adjust for sex, age, genotype for a data
Hello R gurus, I am biologist doing biomarker research and I have a data set where I have 6 proteins and close to 3000 samples, i have to look for differences between disease(Y) and controls(N) along with genetic risk, genotypes, sex and other demographic info available. however i do not know any of the statistics to do the adjustment for sex, age, genotype, genetic risk. I have been reading in papers where the authors are talking about adjusting for age, sex, genotype, genetic risk. The CDC website suggests for adjusting the age using the weights, but I am not sure as this would apply to my data. one website says that if the distribution is not equal then one has to model sex, age and other demographic parameters as co-variates. I would appreciate if someone can help me to understand this more clearly and provide directions on modeling these to do my analysis. I am attaching a sample data file with this post. Thanks http://www.nabble.com/file/p24534963/Sample%2Bdata.csv Sample+data.csv -- View this message in context: http://www.nabble.com/How-to-do-adjust-for-sex%2C-age%2C-genotype-for-a-data-tp24534963p24534963.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to do adjust for sex, age, genotype for a data
then what will be the other factors needed to be adjusted and whether I should adjust or use them as covariates. Finally how these analysis will be done in R Harrell, Frank E wrote: 1Rnwb wrote: Hello R gurus, I am biologist doing biomarker research and I have a data set where I have 6 proteins and close to 3000 samples, i have to look for differences between disease(Y) and controls(N) along with genetic risk, genotypes, sex and other demographic info available. however i do not know any of the statistics to do the adjustment for sex, age, genotype, genetic risk. I have been reading in papers where the authors are talking about adjusting for age, sex, genotype, genetic risk. The CDC website suggests for adjusting the age using the weights, but I am not sure as this would apply to my data. one website says that if the distribution is not equal then one has to model sex, age and other demographic parameters as co-variates. I would appreciate if someone can help me to understand this more clearly and provide directions on modeling these to do my analysis. I am attaching a sample data file with this post. Thanks http://www.nabble.com/file/p24534963/Sample%2Bdata.csv Sample+data.csv If the only clinical variables you are adjusting for are age and sex this analysis will be misleading at best. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-do-adjust-for-sex%2C-age%2C-genotype-for-a-data-tp24534963p24538093.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ttest in R
Thanks for the help, but ANOVA will give me a single pvalue, then how i can make sure which group is showing the significant differences. Tal Galili wrote: Hello friend. I believe anova might be a better solution for you. You might have a look here: http://www.personality-project.org/r/r.anova.html A simple R session that will work for you is: # getting the data in: data1 - read.table( enter the path of the file here, look at ?read.table for exact syntax) aov1 - aov(data ~ gender + disease + genotype ,data = data1) summary(aov1) If you insist on t.test, here is the way: t.test(data ~ gender ,data = data1) t.test(data ~ disease ,data = data1) t.test(data ~ genotype ,data = data1) Cheers, Tal On Sat, Mar 7, 2009 at 9:23 PM, 1Rnwb sbpuro...@gmail.com wrote: Dear list, i am a biologist who needs to do some ttest between disease and non disease, sex, genotype and the serum levels of proteins on a large number of individuals. i have been using excel for a long time but it is very tedious and time consuming. i am posting the data below and ask your help in generating a code to get this analysis done in R. thanks gender disease genotypedata M N CC 3.206447188 F N CC 8.2 M N CC 15.78908629 M N CC 21.14311843 F N CC 21.48413647 M N CC 30.08028842 M N CC 30.11455009 F N CC 32.41258845 F N CT 6622.253065 M N CT 6763.6 M N CT 7342.023209 F N CT 7617.7 F N CT 7857.3 M N CT 8027.78692 F N CT 8755.950438 M N CT 9007.7 F N CT 9157.76987 M N CT 9398.270953 F N CT 9710.083037 F N CT 9896.887277 M N CT 10082.60082 F N CT 10137.05244 F N CT 10350.76186 M N CT 14629.34508 F N TT 4.614829254 F N TT 5.223593964 F N TT 6.7 M N TT 6.7 M N TT 7.735287229 F N TT 13.68084134 F N TT 14.5 M N TT 15.3 M N TT 16.16826703 M N TT 19.8 M N TT 24.51271254 M N TT 29.92459383 F N TT 30.3993842 M N TT 30.57161207 F N TT 30.72031553 F N TT 31.8 F N TT 34.72409961 M N TT 37 F N TT 38.94507607 M N TT 39.1 M N TT 40.9 M N TT 41.5 F N TT 42.36614019 F Y CC 338.2166757 M Y CC 345.8711007 M Y CC 347.4659528 F Y CC 356.3 F Y CC 358.4 F Y CC 360.184259 F Y CC 453.8 F Y CC 573.7342373 M Y CC 962.1232959 F Y CC 1055.9 F Y CC 1309.532621 F Y CC 2798.6 F Y CC 3568.794326 M Y CT 1.227348206 F Y CT 2.061944986 F Y CT 2.245592643 M Y CT 2.454696412 M Y CT 2.456716738 M Y CT 4.318447391 M Y CT 4.503098245 M Y CT 5.873088452 M Y CT 7.106930564 F Y CT 7.7 M Y CT 10.83537709 M Y CT 11.4 M Y CT 12.1 M Y CT 12.62002743 M Y CT 13.6 F Y CT 13.7 F Y CT 14.35562171 F Y CT 15.9 F Y TT 986.6755719 F Y TT 1206.475083 F Y TT 1237.9 M Y TT 1254.5 F Y TT 1303.6 F Y TT 1573.915019 M Y TT 1756.8 M Y TT 1895 M Y TT 2126.766565 F Y TT 2149.512866 M Y TT 3249.449945 F Y TT 6999.3 M Y TT 7172.479241 M Y TT 8268.909251 M Y TT 8544.229671 -- View this message in context: http://www.nabble.com/ttest-in-R-tp22390889p22390889.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- My contact information
Re: [R] ttest in R
since the estimation is not done pairwise so i cannot use pairwise.t.test, how do i apply tukeyHSD Thomas Petzoldt-4 wrote: 1Rnwb schrieb: Thanks for the help, but ANOVA will give me a single pvalue, then how i can make sure which group is showing the significant differences. Hi, ANOVA is fine and please have a look on ?TukeyHSD and don't forget to consult your statistics textbook about post-hoc testing. If you insist in using t.test, don't forget Bonferroni or Holm-correction (in R: ?p.adjust) or use ?pairwise.t.test !!! ThPe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/ttest-in-R-tp22390889p22401372.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ttest in R
Dear list, i am a biologist who needs to do some ttest between disease and non disease, sex, genotype and the serum levels of proteins on a large number of individuals. i have been using excel for a long time but it is very tedious and time consuming. i am posting the data below and ask your help in generating a code to get this analysis done in R. thanks gender disease genotypedata M N CC 3.206447188 F N CC 8.2 M N CC 15.78908629 M N CC 21.14311843 F N CC 21.48413647 M N CC 30.08028842 M N CC 30.11455009 F N CC 32.41258845 F N CT 6622.253065 M N CT 6763.6 M N CT 7342.023209 F N CT 7617.7 F N CT 7857.3 M N CT 8027.78692 F N CT 8755.950438 M N CT 9007.7 F N CT 9157.76987 M N CT 9398.270953 F N CT 9710.083037 F N CT 9896.887277 M N CT 10082.60082 F N CT 10137.05244 F N CT 10350.76186 M N CT 14629.34508 F N TT 4.614829254 F N TT 5.223593964 F N TT 6.7 M N TT 6.7 M N TT 7.735287229 F N TT 13.68084134 F N TT 14.5 M N TT 15.3 M N TT 16.16826703 M N TT 19.8 M N TT 24.51271254 M N TT 29.92459383 F N TT 30.3993842 M N TT 30.57161207 F N TT 30.72031553 F N TT 31.8 F N TT 34.72409961 M N TT 37 F N TT 38.94507607 M N TT 39.1 M N TT 40.9 M N TT 41.5 F N TT 42.36614019 F Y CC 338.2166757 M Y CC 345.8711007 M Y CC 347.4659528 F Y CC 356.3 F Y CC 358.4 F Y CC 360.184259 F Y CC 453.8 F Y CC 573.7342373 M Y CC 962.1232959 F Y CC 1055.9 F Y CC 1309.532621 F Y CC 2798.6 F Y CC 3568.794326 M Y CT 1.227348206 F Y CT 2.061944986 F Y CT 2.245592643 M Y CT 2.454696412 M Y CT 2.456716738 M Y CT 4.318447391 M Y CT 4.503098245 M Y CT 5.873088452 M Y CT 7.106930564 F Y CT 7.7 M Y CT 10.83537709 M Y CT 11.4 M Y CT 12.1 M Y CT 12.62002743 M Y CT 13.6 F Y CT 13.7 F Y CT 14.35562171 F Y CT 15.9 F Y TT 986.6755719 F Y TT 1206.475083 F Y TT 1237.9 M Y TT 1254.5 F Y TT 1303.6 F Y TT 1573.915019 M Y TT 1756.8 M Y TT 1895 M Y TT 2126.766565 F Y TT 2149.512866 M Y TT 3249.449945 F Y TT 6999.3 M Y TT 7172.479241 M Y TT 8268.909251 M Y TT 8544.229671 -- View this message in context: http://www.nabble.com/ttest-in-R-tp22390889p22390889.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] creating standard curves for ELISA analysis
18 15 122 14 4 2 7 1581496 18 35 20 94 C4 11 270 6 23 20.519.59 14.568 656 15 3 4 79 5995296450 40.517 198.5 D4 12 207 4 27 21 19 10 14 11 39 16 5 3 6.5 1622.5 311 25 25 15 181 E4 13 367 7.5 25 21 19 12 10 13 50 12 7 1 8.5 1395.5 718.5 24 30 19 219 F4 14 462 5 23 20 19 7.5 14 10 107 14 4 0 10 1715.5 484.5 23 22 19 265 G4 15 441.5 5 19 20 18 7 16 29 271 12 5 1 10 6917632524.532 15.5 156 H4 16 521 7 38 22 18 10 14 11 164 16 4 3 23 1967744 25 34.515 202 A5 17 759 5 18 21 16.510 10 10 55 11 4 1.5 16 1731.5 752 19 30 12 288 B5 18 624 6 22.520 21 12.511 12 52 12.54 2 8 2329.5 533 23 30.515 125 C5 19 735 5 21 19 14 10 17 11.5 291.5 9 5 3 10 773 1682.5 26 33 17.5 67 D5 20 450 5 25 16 15.58 17 12 65 12 5 3.5 9 1970335 20 23 14 110 E5 21 405 5 21 18 14 7 12 10 139 13.55 0 8.5 1318433 25.533.514 89 F5 22 155 3.5 12.510 12 4 35 6 24 4.5 3 2 8.5 391 257 19 114.5 8 104 G5 23 472 6 23 17 18 6 12 38.5 348 11 3 2 7 2764161239 967 20 197 H5 24 326 5.5 20 19 17 7.5 13.511 44 13 5 3 66 1579272.5 24 24 13 152.5 A6 25 341 5 24 22 15 8 13.513 68.512 4 2 7 1591483 22 34 11 84 B6 26 460.5 5 21 23 16 10 11 160 677.5 11 5 2 23 5326149546.562 19 138 C6 27 454 4 32.516.515 9 10.514 104.5 10.53 1 50 1468145925.538 17 142 D6 28 604 6 27 18 16.57 14.537 950.5 12.55 4 14 5643598024 36 18 324.5 E6 29 491 7 22.518 19 8 13.523 240 17 4 1 11 3802.5 190230.547.520 297 F6 30 414 4 24.520 20.59 13 14 39 16 3 3 6 1384.5 585.5 23 32 13 95 G6 31 423 5.5 21 19.519 9 16 299 142815 5 2 49 63436018160.5 335 11.5 211 H6 32 286 6 28 18 10 9 14 13 108 13.53 2 27.51369808 20 32 237 70 A7 33 874.5 6 23.520 16 8 12.565 588 6 5.5 3 17 5915509836 81 23 229 B7 34 12113 23 20 16 33 12 9.5 78 9 4.5 2 8 2097693.5 16.528 13 274.5 C7 35 257 4.5 25.517 16.59 12 10 52 10 5 3 7 1456750 24 23 11 70.5 Thanks for the help 1Rnwb wrote: Hello R guru's I am a newbie to R, In my research work I usually generate a lot of ELISA data in form of absorbance values. I ususally use Excel to calculate the concentrations of unknown, but it is too tedious and manual especially when I have 100's of files to process. I would appreciate some help in creating a R script to do this with minimal manual input. s A1-G1 and A2-G2 are standards serially diluted H1 and H2 are Blanks. A3 to H12 are serum samples. I am pasting the structure of my data below: A114821 B111577 C15781 D12580 E1902 F1264 G198 H14 A214569.5 B2
[R] creating standard curves for ELISA analysis
Hello R guru's I am a newbie to R, In my research work I usually generate a lot of ELISA data in form of absorbance values. I ususally use Excel to calculate the concentrations of unknown, but it is too tedious and manual especially when I have 100's of files to process. I would appreciate some help in creating a R script to do this with minimal manual input. s A1-G1 and A2-G2 are standards serially diluted H1 and H2 are Blanks. A3 to H12 are serum samples. I am pasting the structure of my data below: A1 14821 B1 11577 C1 5781 D1 2580 E1 902 F1 264 G1 98 H1 4 A2 14569.5 B2 11060 C2 5612 D2 2535 E2 872 F2 285 G2 85 H2 3 A3 1016 B3 2951.5 C3 547 D3 1145 E3 4393 F3 4694 G3 1126 H3 1278 A4 974.5 B4 3112.5 C4 696.5 D4 2664.5 E4 184.5 F4 1908 G4 108.5 H4 1511 A5 463.5 B5 1365 C5 816 D5 806 E5 1341 F5 1157 G5 542.5 H5 749 -- View this message in context: http://www.nabble.com/creating-standard-curves-for-ELISA-analysis-tp20917182p20917182.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.