Git Product home page Git Product logo

eml.tools's Introduction

Build status Build Status codecov

Package in construction for using EML (Ecological Metadata Language) in data analysis, currently only one function. For creating a new EML, see the rOpenSci EML package. This package will take advantage from the fact that EML is machine readable to make some analysis steps easier. Any suggestion or contribution is welcome, but please note that this package has a code of conduct.

Translating factors into their meanings

When the EML only has one table

library("eml.tools")
data("animals_eml")
data("animals_data")
animals_data
##    animal age      size
## 1       A   A 50.902957
## 2       A   A 48.834863
## 3       A   A 51.521256
## 4       A   A 50.919211
## 5       A   A 50.801015
## 6       A   B 80.519204
## 7       A   B 80.889112
## 8       A   B 79.751250
## 9       A   B 80.310155
## 10      A   B 79.971646
## 11      B   A 10.609813
## 12      B   A  9.782217
## 13      B   A  9.753498
## 14      B   A 10.371456
## 15      B   A 10.487272
## 16      B   B 20.630848
## 17      B   B 19.361207
## 18      B   B 18.735406
## 19      B   B 19.214350
## 20      B   B 21.500681
eml_translate_factors(df = animals_data, eml = animals_eml, keep = FALSE)
## # A tibble: 20 × 3
##         size     animal      age
##        <dbl>      <chr>    <chr>
## 1  50.902957 monstercat juvenile
## 2  48.834863 monstercat juvenile
## 3  51.521256 monstercat juvenile
## 4  50.919211 monstercat juvenile
## 5  50.801015 monstercat juvenile
## 6  80.519204 monstercat    adult
## 7  80.889112 monstercat    adult
## 8  79.751250 monstercat    adult
## 9  80.310155 monstercat    adult
## 10 79.971646 monstercat    adult
## 11 10.609813 monsterdog juvenile
## 12  9.782217 monsterdog juvenile
## 13  9.753498 monsterdog juvenile
## 14 10.371456 monsterdog juvenile
## 15 10.487272 monsterdog juvenile
## 16 20.630848 monsterdog    adult
## 17 19.361207 monsterdog    adult
## 18 18.735406 monsterdog    adult
## 19 19.214350 monsterdog    adult
## 20 21.500681 monsterdog    adult
eml_translate_factors(df = animals_data, eml = animals_eml, keep = TRUE)
## # A tibble: 20 × 5
##    animal   age      size animal_meaning age_meaning
##     <chr> <chr>     <dbl>          <chr>       <chr>
## 1       A     A 50.902957     monstercat    juvenile
## 2       A     A 48.834863     monstercat    juvenile
## 3       A     A 51.521256     monstercat    juvenile
## 4       A     A 50.919211     monstercat    juvenile
## 5       A     A 50.801015     monstercat    juvenile
## 6       A     B 80.519204     monstercat       adult
## 7       A     B 80.889112     monstercat       adult
## 8       A     B 79.751250     monstercat       adult
## 9       A     B 80.310155     monstercat       adult
## 10      A     B 79.971646     monstercat       adult
## 11      B     A 10.609813     monsterdog    juvenile
## 12      B     A  9.782217     monsterdog    juvenile
## 13      B     A  9.753498     monsterdog    juvenile
## 14      B     A 10.371456     monsterdog    juvenile
## 15      B     A 10.487272     monsterdog    juvenile
## 16      B     B 20.630848     monsterdog       adult
## 17      B     B 19.361207     monsterdog       adult
## 18      B     B 18.735406     monsterdog       adult
## 19      B     B 19.214350     monsterdog       adult
## 20      B     B 21.500681     monsterdog       adult

When the EML only has several tables

This is the case if the EML documents a database. In this case, we need to use the entityName of the table for which we want to perform the translation.

library("eml.tools")
data("animals_db_eml")
data("animals_data")
animals_data
## # A tibble: 20 × 3
##    animal    age      size
##    <fctr> <fctr>     <dbl>
## 1       A      A 50.902957
## 2       A      A 48.834863
## 3       A      A 51.521256
## 4       A      A 50.919211
## 5       A      A 50.801015
## 6       A      B 80.519204
## 7       A      B 80.889112
## 8       A      B 79.751250
## 9       A      B 80.310155
## 10      A      B 79.971646
## 11      B      A 10.609813
## 12      B      A  9.782217
## 13      B      A  9.753498
## 14      B      A 10.371456
## 15      B      A 10.487272
## 16      B      B 20.630848
## 17      B      B 19.361207
## 18      B      B 18.735406
## 19      B      B 19.214350
## 20      B      B 21.500681
eml_translate_factors(df = animals_data,
                      eml = animals_db_eml,
                      which_table = "english_animals",
                      keep = FALSE)
## # A tibble: 20 × 3
##         size     animal      age
##        <dbl>      <chr>    <chr>
## 1  50.902957 monstercat juvenile
## 2  48.834863 monstercat juvenile
## 3  51.521256 monstercat juvenile
## 4  50.919211 monstercat juvenile
## 5  50.801015 monstercat juvenile
## 6  80.519204 monstercat    adult
## 7  80.889112 monstercat    adult
## 8  79.751250 monstercat    adult
## 9  80.310155 monstercat    adult
## 10 79.971646 monstercat    adult
## 11 10.609813 monsterdog juvenile
## 12  9.782217 monsterdog juvenile
## 13  9.753498 monsterdog juvenile
## 14 10.371456 monsterdog juvenile
## 15 10.487272 monsterdog juvenile
## 16 20.630848 monsterdog    adult
## 17 19.361207 monsterdog    adult
## 18 18.735406 monsterdog    adult
## 19 19.214350 monsterdog    adult
## 20 21.500681 monsterdog    adult
eml_translate_factors(df = animals_data,
                      eml = animals_db_eml,
                      which_table = "english_animals",
                      keep = TRUE)
## # A tibble: 20 × 5
##    animal   age      size animal_meaning age_meaning
##     <chr> <chr>     <dbl>          <chr>       <chr>
## 1       A     A 50.902957     monstercat    juvenile
## 2       A     A 48.834863     monstercat    juvenile
## 3       A     A 51.521256     monstercat    juvenile
## 4       A     A 50.919211     monstercat    juvenile
## 5       A     A 50.801015     monstercat    juvenile
## 6       A     B 80.519204     monstercat       adult
## 7       A     B 80.889112     monstercat       adult
## 8       A     B 79.751250     monstercat       adult
## 9       A     B 80.310155     monstercat       adult
## 10      A     B 79.971646     monstercat       adult
## 11      B     A 10.609813     monsterdog    juvenile
## 12      B     A  9.782217     monsterdog    juvenile
## 13      B     A  9.753498     monsterdog    juvenile
## 14      B     A 10.371456     monsterdog    juvenile
## 15      B     A 10.487272     monsterdog    juvenile
## 16      B     B 20.630848     monsterdog       adult
## 17      B     B 19.361207     monsterdog       adult
## 18      B     B 18.735406     monsterdog       adult
## 19      B     B 19.214350     monsterdog       adult
## 20      B     B 21.500681     monsterdog       adult

eml.tools's People

Contributors

maelle avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

eml.tools's Issues

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.