[R] Doing dist on separate objects in a text file

R. Michael Weylandt michael.weylandt at gmail.com
Sun Nov 6 03:57:35 CET 2011


Perhaps split() directly or more abstractly tapply() from base or one
of the d_ply() from plyr?

Michael

On Sat, Nov 5, 2011 at 7:20 PM, ScottDaniel <scottdaniel25 at gmail.com> wrote:
> So I have a text file that looks like this:
>        "Label" "X"     "Y"     "Slice"
> 1       "Field_1_R3D_D3D_PRJ_w617.tif"  348     506     1
> 2       "Field_1_R3D_D3D_PRJ_w617.tif"  359     505     1
> 3       "Field_1_R3D_D3D_PRJ_w617.tif"  356     524     1
> 4       "Field_1_R3D_D3D_PRJ_w617.tif"  2       0       1
> 5       "Field_1_R3D_D3D_PRJ_w617.tif"  412     872     1
> 6       "Field_1_R3D_D3D_PRJ_w617.tif"  422     863     1
> 7       "Field_1_R3D_D3D_PRJ_w617.tif"  429     858     1
> 8       "Field_1_R3D_D3D_PRJ_w617.tif"  429     880     1
> 9       "Field_1_R3D_D3D_PRJ_w617.tif"  437     865     1
> 10      "Field_1_R3D_D3D_PRJ_w617.tif"  447     855     1
> 11      "Field_1_R3D_D3D_PRJ_w617.tif"  450     868     1
> 12      "Field_1_R3D_D3D_PRJ_w617.tif"  447     875     1
> 13      "Field_1_R3D_D3D_PRJ_w617.tif"  439     885     1
> 14      "Field_1_R3D_D3D_PRJ_w617.tif"  2       8       1
>
> What it represents are the locations of centromeres per nucleus in a
> microscope image. What I need to do is do a dist() on each grouping (the
> grouping being separated by the low values of x and y's) and then compute an
> average. The part that I'm having trouble with is writing code that will
> allow R to separate these objects. Do I have to find some way of creating
> separate data frames for each object? Or is there a way to parse the file
> and generate a single data frame of all the pairwise distances? Any
> suggestions or example code would be much appreciated. Thanks!
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Doing-dist-on-separate-objects-in-a-text-file-tp3994515p3994515.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list