How to subset a geomorph data frame

321 views
Skip to first unread message

cybil.c...@gmail.com

unread,
Feb 23, 2021, 12:12:19 PM2/23/21
to geomorph R package

Hello all,

 

Does anyone know how to subset a geomorph data frame or know where I can find a vignette or tutorial on how to do so?

 I have made several attempts but have not been successful. I would like to extract just one population from my data set.  I have difficulty wrapping my head around the structure of geomorph data frames.

If someone could please share this information with me it would make my life exceedingly less frustrating and I would be forever grateful.

 

Cheers,

Cybil

Bryan H. Juarez

unread,
Feb 23, 2021, 12:32:28 PM2/23/21
to geomorph-...@googlegroups.com
I think I would advise (without knowing more about why you are trying to subset a gdf): subsetting your data before using geomorph.data.frame() if using for a linear model. 

If one must subset a gdf, then you can do this by calling the gdf, the variable name, and then using the [] operators: gdf$var[#] or gdf$var[#,] depending on the dimensions of the original data. As far as I know one cannot subset all variables within a gdf at once using existing functions since the gdf is meant as direct input to lm.rrpp or related functions, but I am sure you could write custom code to subset all variables within a gdf using base operators or apply functions.

Best,
Bryan Juarez

--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/5f8e7f69-f74c-4f7e-a5d0-168771d86e14n%40googlegroups.com.


--
Bryan H. Juarez (he/him/his)
NSF Fellow
PhD Candidate
Adams Lab
EEOB Dept.
Iowa State University
Twitter: @bhjuarez


Cybil Cavalieri

unread,
Feb 23, 2021, 2:16:07 PM2/23/21
to geomorph-...@googlegroups.com
Dear Bryan,

You make an interesting and valid point with your suggestion of " I think I would advise (without knowing more about why you are trying to subset a gdf): subsetting your data before using geomorph.data.frame() if using for a linear model. " when you're fighting to structure data sometimes you lose your perspective of what you were trying to do in the beginning. Thank you for sharing the information of how to work more effectively with geomorph data frames.

I greatly appreciate the help thank you,

Cybil

Mike Collyer

unread,
Feb 23, 2021, 2:24:46 PM2/23/21
to geomorph R package
As an additional note, if one has a data.frame object — which is a list that can be coerced into a matrix — the geomorph functions that use geomorph data frames can also use regular data frames, and those are easier to subset.

The reason for geomorph data frames is one cannot add things like class phylo trees to data frames and these cannot be subsetted easily.  Coordinates in 3d arrays cannot be added to regular data frames.  The geomorph data frame will check to make sure there are equal numbers of observation but is more like a standard list.  Subsetting of regular data frames is a convenience because rows can be removed.  In geomorph data frames, rows have less meaning.

Nonetheless, when functions like procD.lm come across regular data frames, they have no trouble to treat them the same as geomorph data frames.

Best,
Mike



Cybil Cavalieri

unread,
Feb 24, 2021, 9:38:04 AM2/24/21
to geomorph-...@googlegroups.com
Dear Mike,
I did not know this thank you for sharing it with me.
" procD.lm come across regular data frames, they have no trouble to treat them the same as geomorph data frames. "
Cheers,
Cybil

Reply all
Reply to author
Forward
0 new messages