-------- Original Message --------
Subject:        Reformatting an R code matrix for use in MorphoJ
Date:   Thu, 3 Feb 2011 14:45:18 -0800
From:   David Katz <[email protected]>
To:     morphmet <[email protected]>



After hours of wrestling with a bit of R code (which included several
e-mails b/w myself and the mod) which would reformat R matrix data so
that it was ready to use in MorphoJ, I think I've got it finalized.  At
the suggestion of the mod, I'm passing it along in case someone else
finds it useful.

########################

#Function for data reformatting
morphoJ.export <- function(data, specimens, landmarks, dimensions)
   {#'data' refers to the existing data matrix
    #'specimens' refers to a vector of specimen names
    #'landmarks' refers to a vector of landmark names with length = to
the number of landmarks
    #'dimensions' refers to an 'argument' specifying the number of
dimensions to the data
    export <- matrix(t(data), nrow=length(specimens),
ncol=length(landmarks)*
      dimensions, byrow=TRUE);
    row.names(export) <- specimens;
    return(export)
}

#Run function
morphoJ.data <- morphoJ.export (coords, specs, lms, dims)

#Export as MorphoJ-friendly text file
write.table (morphoJ.data, "morphoJ.data.txt", row.names=specs,
   quote=FALSE, sep = ", ")


#########################

Regards.
DK
--
David Katz
Graduate Student
Department of Anthropology (Evolutionary Wing)
University of California, Davis
Young Hall 204

/--Trying to focus on one distraction at a time/--

Reply via email to