Skip to content

Instantly share code, notes, and snippets.

@amoeba
amoeba / r-error.md
Last active November 24, 2015 22:12

1. The string '2+2' in PowerPoint, which was running in Parallels

$ pbpaste | hexdump
0000000 32 2b 32 0d

When run in R:

"rror: unexpected input in "2+2

# Query for the list of named graphs available
curl -H "Accept: application/json" "http://harvest.geolink.org:8080/openrdf-sesame/repositories/glharvest?queryLn=SPARQL&infer=false&query=SELECT%20DISTINCT%20%3Fg%20WHERE%20%7B%20%20GRAPH%20%3Fg%20%7B%3Fs%20%3Fp%20%3Fo%7D%7D"
# Query a particular named graph:
curl -H "Accept: application/json" "http://harvest.geolink.org:8080/openrdf-workbench/repositories/glharvest/query?action=exec&queryLn=SPARQL&query=SELECT%20*%20FROM%20%3Chttp%3A%2F%2Flocalhost%3A8080%2Fopenrdf-sesame%2Frepositories%2Fglharvest%2Frdf-graphs%2Fsesar%3E%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20LIMIT%205&limit=100&infer=true"
library(dataone)
mn <- MNode("https://arcticdata.io/metacat/d1/mn/v2")
pid <- "arctic-data.6230.1"
# Modify System Metadata
sysmeta <- getSystemMetadata(mn, pid)
sysmeta@formatId # You can see that it's "application/vnd.ms-excel"
#' Sytem Metadata formatId values are from a controlled list of identifires
<project>
<title>Collaborative Research: Resolving centennial- to millennial-scale trends in glacier extent and lake sedimentation in the Brooks Range, Arctic Alaska</title>
<personnel>
<individualName>
<givenName>William</givenName>
<surName>D'Andrea</surName>
</individualName>
<electronicMailAddress>[email protected]</electronicMailAddress>
<role>Principcal Investigator</role>
</personnel>
#' overnight_temps.R
#' https://twitter.com/AbsLawson/status/777799977393270784
#'
#' rstats q: want to calc overnight temp (~22:00-4:00) from hrly temps w/ missing
#' values (rows). Desired timespan overlaps dates, unsure how
# Create dummy data to use
df <- data.frame(datetime = seq(ISOdate(2016,1,1), ISOdate(2016,3,1), by = "hour"))
df$temp_c <- runif(nrow(df), 0, 20)
#!/usr/bin/env python
''' wt-regiser-dataone.py
A command-line utility intended to be a working demonstration of how a DataONE
dataset can be mapped to a file system.
The input to this tool is a string which is either a DataONE landing page URL or
A DataONE resolve/object URL.
---
title: "Practical_EML_inR"
author: "Jeanette Clark"
date: "2/9/2017"
output: html_document
---
This document is a practical tutorial for using the EML package to solve many metadata problems seen in the ADC. Much of this information can be found in the vignettes here: https://github.com/ropensci/EML/blob/master/vignettes/creating-EML.Rmd
First, load in some packages.
```{r}
obj: class=`character`; value=``
obj: class=`access`; value=``
obj: class=`dataset`; value=``
obj: class=`xml_attribute`; value=``
obj: class=`xml_attribute`; value=``
obj: class=`slot_order`; value=``
obj: class=`ListOfalternateIdentifier`; value=``
obj: class=`shortName`; value=``
obj: class=`ListOftitle`; value=`My title`
obj: class=`title`; value=`My title`
> df <- as.tbl(data.frame(x = c("a", "b", "c")))
> df
# A tibble: 3 × 1
x
<fctr>
1 a
2 b
3 c
> df %>% filter(x == "a")
# A tibble: 1 × 1
<?xml version="1.0" encoding="UTF-8"?>
<eml:eml
xmlns:eml="eml://ecoinformatics.org/eml-2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packageId="doi:10.5063/F15B00CC" scope="system" system="knb" xsi:schemaLocation="eml://ecoinformatics.org/eml-2.1.1 eml.xsd">
<access authSystem="knb" order="allowFirst" scope="document">
<allow>
<principal>public</principal>
<permission>read</permission>
</allow>
<allow>