----- Forwarded message from David Katz <dck...@ucdavis.edu> -----

Date: Tue, 1 Apr 2014 16:36:14 -0400
From: David Katz <dck...@ucdavis.edu>
Reply-To: David Katz <dck...@ucdavis.edu>
Subject: Re: Identify groups in R
To: "morphmet@morphometrics.org" <morphmet@morphometrics.org>

This should get you started. Assume your ID designation for a specimen looks like this:

"AI-dl-3233"

where "AI" identifies group, "dl" identifies curating institution, and "3233" accession number. You want group to extract group information. 

For the single case.... 

specimen <- "AI-dl-3233"

group <- head(unlist(strsplit(specimen, "-")), n=1)

To modify so that it suits your format, search R help on head (or 'tail'), unlist, and strsplit.

For the whole thing....

You want to build a group vector of length n. I'm going to assume your data are in the form of an n * (p*k) data frame (or matrix) and that the first column contains the ID information.

d <- [your data frame]

group.vec <- rep(NA, nrow(d))

for (i in 1:nrow(d))
   {group.vec[i] <- head(unlist(strsplit(d[i,1], "-")), n=1)}

Basically, you create an empty vector of appropriate length and then fill it with the data you want. Then you append it to your original data frame or matrix.

Hope that helps




On Tue, Apr 1, 2014 at 12:26 PM, <morphmet_modera...@morphometrics.org> wrote:


----- Forwarded message from morphmet_modera...@morphometrics.org -----

Date: Tue, 01 Apr 2014 00:50:39 -0700
From: morphmet_modera...@morphometrics.org
Reply-To: morphmet_modera...@morphometrics.org
Subject: Identify groups in R
To: morphmet@morphometrics.org


----- Forwarded message from Raquel Mendes <raquelgmen...@gmail.com> -----

Date: Tue, 18 Mar 2014 12:55:27 -0400
From: Raquel Mendes <raquelgmen...@gmail.com>
Reply-To: Raquel Mendes <raquelgmen...@gmail.com>
Subject: Identify groups in R
To: morphmet@morphometrics.org

Dear all,

I´m trying to read and analyze my landmark data with R. I have upload a tps file from tpsdig2, with 26 landmarks/specimen; ID and scale factor and preformed a procrustes superimposition.

My problem is in analysing groups in subsequent analysis, since group information is included within the ID for each specimen. How do I tell R which specimen belongs to each group? Should I be using other types of dataset? I´m fairly new at R and any help would be most appreciated.

Thank you in advance.

Best,



Raquel Mendes



----- End forwarded message -----





----- End forwarded message -----






--
David Katz
Doctoral Candidate
Department of Anthropology--Evolutionary Wing
University of California, Davis
Young Hall 204



----- End forwarded message -----



Reply via email to