Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Award Numbers function #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

nguyenmmegan
Copy link
Contributor

No description provided.

#get outpath name from metapid
systema <- getSystemMetadata(mn, metapid)
systema_name <- systema@fileName
outpath <- paste("/home/mnguyen/", systema_name, sep = "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a path to my user... not sure how else to create an outpath that could apply to any user

Copy link
Member

@dmullen17 dmullen17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start. See if you can make some of the changes and then we can move forward from there

outpath <- paste("/home/mnguyen/", systema_name, sep = "")

#download data from metapid
download_data_objects(mn, c(metapid), c(outpath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty useful: You can download dataone objects directly like this eml <- read_eml(rawToChar(dataone::getObject(mn, metapid)))

So you won't need to use download_data_objects

#the raw award string numbers
raw_award_string <- c()
funding <- eml@dataset@project@funding@para
for(i in 1:length(funding)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you change this to seq_along(funding) then it handles the case where length = 0. Rather than the case of for in 1:0 which gives you an error

raw_award_string <- c()
funding <- eml@dataset@project@funding@para
for(i in 1:length(funding)){
award <- funding@.Data[[i]]@.Data[[1]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to replace some of these with eml_get function. Look up the documentation with ?eml_get and see if you can use it to simplify some of the code


#get xml from metapid
eml <- read_eml(eml_file) #read in eml_file
list <- list() #will be output list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You generally don't want to name your objects using already existing names. Since list is already the name of a function you want to rename your list to something like "output"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants