Giter VIP home page Giter VIP logo

Comments (10)

sckott avatar sckott commented on September 26, 2024

@cboettig Hey, looking at now

from rnexml.

karthik avatar karthik commented on September 26, 2024

Some quick thoughts.

arrange() in plyr can help get the order right.

You can do a rbind.fill if need be to get non-overlapping rows together.

Then you can recast with reshape's dcast which will fill in all available values for any taxon and drop in NAs for the rest.

ldply only works if everything is nice and symmetric.

from rnexml.

sckott avatar sckott commented on September 26, 2024

woops, forgot to mention in commit message Does this (859d87c) work? @cboettig

from rnexml.

sckott avatar sckott commented on September 26, 2024

Okay, see most recent commit:

RNeXML/R/characters.R

Lines 53 to 76 in 5a5701e

#' Get character data.frame, accepts either nexml object, or a list of data.frames
#'
#' @examples \dontrun{
#' # library(RNeXML)
#' f <- system.file("examples", "comp_analysis.xml", package="RNeXML")
#' nex <- read.nexml(f)
#' RNeXML:::get_characters(nex)
#'
#' # with different row.names
#' char_list <- get_characters_list(nex)
#' row.names(char_list[[1]])[1:3] <- c("taxon_18","taxon_20","taxon_30")
#' RNeXML:::get_characters(char_list
#' }
get_characters <- function(input){
if(inherits(input, "nexml")){
list_chars <- get_characters_list(input)
} else { list_chars <- input }
mrecurse <- function(dfs, ...){
merge(dfs, ..., by='row.names', all = TRUE, sort = FALSE)
}
tmp <- Reduce(mrecurse, list_chars)
row.names(tmp) <- tmp[,1]
tmp[,-1]
}
(p.s. sorry, forgot to mention issue again!)

from rnexml.

cboettig avatar cboettig commented on September 26, 2024

@schamberlain perfect. rock on.

from rnexml.

sckott avatar sckott commented on September 26, 2024

hmmm, doesn't work for lists > 2, sorry, fixing

from rnexml.

cboettig avatar cboettig commented on September 26, 2024

@schamberlain good catch. Can you throw some test_that tests for it into test_characters.R when it's running?

from rnexml.

sckott avatar sckott commented on September 26, 2024

yep

from rnexml.

cboettig avatar cboettig commented on September 26, 2024

@schamberlain looks good. I fixed the get_characters_matrix subroutine so that the example characters.xml is also working. Feel free to close this issue when you're ready.

from rnexml.

cboettig avatar cboettig commented on September 26, 2024

@schamberlain closing for now, reopen if there's still any outstanding issues here.

from rnexml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.