IQSS / dataverse-client-r

R Client for Dataverse Repositories
https://iqss.github.io/dataverse-client-r
61 stars 25 forks source link

Expand documentation #1

Closed leeper closed 7 years ago

leeper commented 8 years ago
leeper commented 8 years ago

vignettes were added here: https://github.com/IQSS/dataverse-client-r/commit/a16c0cdc7a95b86a9147305506b413324f832b5a but aren't finished yet

brownaa commented 8 years ago

I'm open to forking this and adding documentation for reading data into R. However, I can't make it work myself. The documentation in the latest commit gives errors and I've tried to debug the issue to no avail.

To expand on this, I've written the following codechunk in R 3.3.1

dataset = get_dataset("doi:10.7910/DVN/FIE0S4") files = dataset_files("doi:10.7910/DVN/FIE0S4", version = 1) files[[1]]

files[[1]] $description

[1] "Climate Historical Normals (1981-2010)"

$label [1] "Climate_HistoricalNormals.tab"

$version [1] 3

$datasetVersionId [1] 69729

$datafile $datafile$id [1] 2701494

$datafile$name [1] "Climate_HistoricalNormals.tab"

$datafile$contentType [1] "text/tab-separated-values"

$datafile$filename [1] "14f5cac1cfc-74c415bb5b97"

$datafile$originalFileFormat [1] "text/csv"

$datafile$originalFormatLabel [1] "Comma Separated Values"

$datafile$UNF [1] "UNF:6:mWGimIcPNjkK1GnVYpEtSw=="

$datafile$md5 [1] "092c31d53d7aa6869abb7213f498b632"

$datafile$description [1] "Climate Historical Normals (1981-2010)"

attr(,"class") [1] "dataverse_file"

f = get_file(files[[1]]) f

[1] 49 74 65 6d 2c 49 74 65 6d 20 44 65 74 61 69 6c 2c 4a 61 6e 2c 46 65 62 2c 4d 61 72 2c [30] 41 70 72 2c 4d 61 79 2c 4a 75 6e 2c 4a 75 6c 2c 41 75 67 2c 53 65 70 2c 4f 63 74 2c 4e [59] 6f 76 2c 44 65 63 2c 59 65 61 72 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 52 61 69 [88] 6e 66 61 6c 6c 20 28 6d 6d 29 2c 32 34 32 2e 33 2c 31 37 34 2e 32 2c 31 36 38 2e 33 2c [117] 31 34 34 2e 34 2c 31 31 31 2e 37 2c 39 37 2e 33 2c 36 32 2e 34 2c 36 34 2e 38 2c 38 31 [146] 2e 32 2c 32 30 32 2e 31 2c 33 30 34 2c 32 33 30 2e 39 2c 31 38 38 33 2e 36 0a 50 72 65 [175] 63 69 70 69 74 61 74 69 6f 6e 2c 53 6e 6f 77 66 61 6c 6c 20 28 63 6d 29 2c 31 38 2e 38 [204] 2c 31 35 2e 31 2c 33 2e 38 2c 31 2e 33 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2e 32 2c 34 [233] 2e 31 2c 31 39 2e 33 2c 36 32 2e 36 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 50 72 [262] 65 63 69 70 69 74 61 74 69 6f 6e 20 28 6d 6d 29 2c 32 36 31 2e 31 2c 31 38 39 2e 33 2c [291] 31 37 32 2c 31 34 35 2e 37 2c 31 31 31 2e 37 2c 39 37 2e 33 2c 36 32 2e 34 2c 36 34 2e [320] 38 2c 38 31 2e 32 2c 32 30 32 2e 33 2c 33 30 38 2e 31 2c 32 35 30 2e 32 2c 31 39 34 36 [349] 2e 32 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 41 76 65 72 61 67 65 20 53 6e 6f 77 [378] 20 44 65 70 74 68 20 28 63 6d 29 2c 32 2c 32 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 [407] 2c 30 2c 30 2c 31 2c 30 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 4d 65 64 69 61 6e [436] 20 53 6e 6f 77 20 44 65 70 74 68 20 28 63 6d 29 2c 31 2c 30 2c 30 2c 30 2c 30 2c 30 2c [465] 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 53 [494] 6e 6f 77 20 44 65 70 74 68 20 61 74 20 4d 6f 6e 74 68 2d 65 6e 64 20 28 63 6d 29 2c 31 [523] 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 34 2c 30 0a 50 72 65 63 [552] 69 70 69 74 61 74 69 6f 6e 2c 45 78 74 72 65 6d 65 20 44 61 69 6c 79 20 52 61 69 6e 66 [581] 61 6c 6c 20 28 6d 6d 29 2c 31 35 32 2e 31 2c 37 36 2e 36 2c 38 32 2e 36 2c 35 39 2e 39 [610] 2c 36 30 2e 38 2c 35 32 2e 31 2c 37 30 2e 34 2c 37 38 2e 34 2c 38 36 2e 36 2c 39 31 2e [639] 32 2c 31 30 32 2e 31 2c 31 30 38 2e 32 2c 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c [668] 44 61 74 65 20 28 79 79 79 79 2f 64 64 29 2c 31 39 36 38 2f 31 38 2c 31 39 38 36 2f 32 [697] 33 2c 31 39 39 37 2f 31 37 2c 31 39 39 31 2f 30 33 2c 31 39 38 39 2f 31 37 2c 31 39 38 [726] 34 2f 32 38 2c 31 39 37 32 2f 31 31 2c 31 39 39 31 2f 32 36 2c 31 39 36 38 2f 31 36 2c [755] 31 39 37 35 2f 31 36 2c 31 39 36 34 2f 32 39 2c 31 39 37 32 2f 32 35 2c 0a 50 72 65 63 [784] 69 70 69 74 61 74 69 6f 6e 2c 45 78 74 72 65 6d 65 20 44 61 69 6c 79 20 53 6e 6f 77 66 [813] 61 6c 6c 20 28 63 6d 29 2c 33 31 2e 35 2c 33 30 2c 32 35 2e 34 2c 31 34 2c 30 2c 30 2c [842] 30 2c 30 2c 30 2c 33 2c 32 32 2e 39 2c 33 33 2c 0a 50 72 65 63 69 70 69 74 61 74 69 6f [871] 6e 2c 44 61 74 65 20 28 79 79 79 79 2f 64 64 29 2c 31 39 37 31 2f 31 32 2c 31 39 37 31 [900] 2f 32 36 2c 31 39 36 32 2f 30 31 2c 31 39 37 32 2f 30 38 2c 31 39 36 30 2f 30 31 2c 31 [929] 39 36 30 2f 30 31 2c 31 39 36 30 2f 30 31 2c 31 39 36 30 2f 30 31 2c 31 39 36 30 2f 30 [958] 31 2c 31 39 38 34 2f 33 31 2c 31 39 36 32 2f 32 39 2c 31 39 37 35 2f 31 32 2c 0a 50 72 [987] 65 63 69 70 69 74 61 74 69 6f 6e 2c 45 78 74 72 65 6d 65 20 44 61 69 6c 79 20 50 72 65 [1016] 63 69 70 69 74 61 74 69 6f 6e 20 28 6d 6d 29 2c 31 35 32 2e 31 2c 37 36 2e 36 2c 38 32 [1045] 2e 36 2c 35 39 2e 39 2c 36 30 2e 38 2c 35 32 2e 31 2c 37 30 2e 34 2c 37 38 2e 34 2c 38 [1074] 36 2e 36 2c 39 31 2e 32 2c 31 30 32 2e 31 2c 31 30 38 2e 32 2c 0a 50 72 65 63 69 70 69 [1103] 74 61 74 69 6f 6e 2c 44 61 74 65 20 28 79 79 79 79 2f 64 64 29 2c 31 39 36 38 2f 31 38 [1132] 2c 31 39 38 36 2f 32 33 2c 31 39 39 37 2f 31 37 2c 31 39 39 31 2f 30 33 2c 31 39 38 39 [1161] 2f 31 37 2c 31 39 38 34 2f 32 38 2c 31 39 37 32 2f 31 31 2c 31 39 39 31 2f 32 36 2c 31 [1190] 39 36 38 2f 31 36 2c 31 39 37 35 2f 31 36 2c 31 39 36 34 2f 32 39 2c 31 39 37 32 2f 32 [1219] 35 2c 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 45 78 74 72 65 6d 65 20 53 6e 6f 77 [1248] 20 44 65 70 74 68 20 28 63 6d 29 2c 34 39 2c 33 34 2c 31 33 2c 33 2c 30 2c 30 2c 30 2c [1277] 30 2c 30 2c 30 2c 31 31 2c 34 32 2c 0a 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 44 61 [1306] 74 65 20 28 79 79 79 79 2f 64 64 29 2c 31 39 39 31 2f 30 38 2c 31 39 39 30 2f 31 36 2c [1335] 31 39 39 31 2f 30 32 2c 31 39 38 31 2f 31 32 2c 31 39 38 31 2f 30 31 2c 31 39 38 31 2f [1364] 30 31 2c 31 39 38 31 2f 30 31 2c 31 39 38 30 2f 30 31 2c 31 39 38 31 2f 30 31 2c 31 39 [1393] 38 31 2f 30 31 2c 31 39 38 35 2f 32 37 2c 31 39 39 30 2f 33 31 2c 0a 44 61 79 73 20 77 [1422] 69 74 68 20 52 61 69 6e 66 61 6c 6c 2c 3e 3d 20 30 2e 32 20 6d 6d 2c 31 38 2e 35 2c 31 [1451] 34 2e 39 2c 31 38 2e 33 2c 31 37 2c 31 35 2e 31 2c 31 33 2e 32 2c 38 2e 36 2c 38 2e 34 [1480] 2c 39 2e 34 2c 31 36 2e 38 2c 32 31 2e 34 2c 31 37 2e 39 2c 31 37 39 2e 35 0a 44 61 79 [1509] 73 20 77 69 74 68 20 52 61 69 6e 66 61 6c 6c 2c 3e 3d 20 35 20 6d 6d 2c 31 32 2e 32 2c [1538] 39 2e 31 2c 39 2e 37 2c 38 2e 34 2c 37 2c 35 2e 37 2c 33 2e 37 2c 33 2e 33 2c 34 2c 39 [1567] 2e 38 2c 31 34 2e 33 2c 31 31 2c 39 38 2e 32 0a 44 61 79 73 20 77 69 74 68 20 52 61 69 [1596] 6e 66 61 6c 6c 2c 3e 3d 20 31 30 20 6d 6d 2c 37 2e 39 2c 36 2e 33 2c 36 2e 32 2c 35 2e [1625] 32 2c 34 2c 33 2e 35 2c 32 2e 32 2c 31 2e 39 2c 32 2e 37 2c 37 2e 33 2c 31 30 2e 37 2c [1654] 37 2e 39 2c 36 35 2e 37 0a 44 61 79 73 20 77 69 74 68 20 52 61 69 6e 66 61 6c 6c 2c 3e [1683] 3d 20 32 35 20 6d 6d 2c 32 2e 38 2c 32 2c 31 2e 35 2c 31 2e 33 2c 30 2e 38 35 2c 30 2e [1712] 38 31 2c 30 2e 33 38 2c 30 2e 37 31 2c 30 2e 38 36 2c 32 2e 36 2c 34 2e 31 2c 32 2e 39 [1741] 2c 32 30 2e 38 0a 44 61 79 73 20 57 69 74 68 20 53 6e 6f 77 66 61 6c 6c 2c 3e 3d 20 30 [1770] 2e 32 20 63 6d 2c 33 2e 31 2c 32 2e 35 2c 31 2e 31 2c 30 2e 35 37 2c 30 2c 30 2c 30 2c [1799] 30 2c 30 2c 30 2e 31 2c 31 2e 32 2c 34 2e 31 2c 31 32 2e 37 0a 44 61 79 73 20 57 69 74 [1828] 68 20 53 6e 6f 77 66 61 6c 6c 2c 3e 3d 20 35 20 63 6d 2c 31 2e 34 2c 31 2c 30 2e 32 34 [1857] 2c 30 2e 30 35 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2e 33 33 2c 31 2e 33 2c 34 2e [1886] 33 0a 44 61 79 73 20 57 69 74 68 20 53 6e 6f 77 66 61 6c 6c 2c 3e 3d 20 31 30 20 63 6d [1915] 2c 30 2e 38 36 2c 30 2e 35 32 2c 30 2e 31 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c [1944] 30 2e 31 2c 30 2e 35 2c 32 2e 31 0a 44 61 79 73 20 57 69 74 68 20 53 6e 6f 77 66 61 6c [1973] 6c 2c 3e 3d 20 32 35 20 63 6d 2c 30 2c 30 2e 30 35 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 [2002] 2c 30 2c 30 2c 30 2c 30 2e 31 35 2c 30 2e 32 0a 44 61 79 73 20 77 69 74 68 20 50 72 65 [2031] 63 69 70 69 74 61 74 69 6f 6e 2c 3e 3d 20 30 2e 32 20 6d 6d 2c 31 39 2e 38 2c 31 36 2e [2060] 34 2c 31 38 2e 34 2c 31 37 2e 31 2c 31 35 2e 31 2c 31 33 2e 32 2c 38 2e 36 2c 38 2e 34 [2089] 2c 39 2e 34 2c 31 36 2e 39 2c 32 31 2e 38 2c 31 39 2e 36 2c 31 38 34 2e 38 0a 44 61 79 [2118] 73 20 77 69 74 68 20 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 3e 3d 20 35 20 6d 6d 2c [2147] 31 33 2e 32 2c 31 30 2e 31 2c 31 30 2e 31 2c 38 2e 36 2c 37 2c 35 2e 37 2c 33 2e 37 2c [2176] 33 2e 33 2c 34 2c 39 2e 38 2c 31 34 2e 35 2c 31 32 2e 35 2c 31 30 32 2e 35 0a 44 61 79 [2205] 73 20 77 69 74 68 20 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 3e 3d 20 31 30 20 6d 6d [2234] 2c 38 2e 39 2c 37 2e 31 2c 36 2e 35 2c 35 2e 33 2c 34 2c 33 2e 35 2c 32 2e 32 2c 31 2e [2263] 39 2c 32 2e 37 2c 37 2e 33 2c 31 30 2e 38 2c 38 2e 36 2c 36 38 2e 38 0a 44 61 79 73 20 [2292] 77 69 74 68 20 50 72 65 63 69 70 69 74 61 74 69 6f 6e 2c 3e 3d 20 32 35 20 6d 6d 2c 33 [2321] 2c 32 2c 31 2e 35 2c 31 2e 33 2c 30 2e 38 35 2c 30 2e 38 31 2c 30 2e 33 38 2c 30 2e 37 [2350] 31 2c 30 2e 38 36 2c 32 2e 36 2c 34 2e 32 2c 33 2e 32 2c 32 31 2e 34 0a 44 61 79 73 20 [2379] 77 69 74 68 20 53 6e 6f 77 20 44 65 70 74 68 2c 3e 3d 20 31 20 63 6d 2c 35 2e 39 2c 33 [2408] 2e 31 2c 30 2e 35 32 2c 30 2e 31 34 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 31 2e 34 2c [2437] 35 2e 31 2c 31 36 2e 32 0a 44 61 79 73 20 77 69 74 68 20 53 6e 6f 77 20 44 65 70 74 68 [2466] 2c 3e 3d 20 35 20 63 6d 2c 34 2e 32 2c 32 2e 32 2c 30 2e 32 34 2c 30 2c 30 2c 30 2c 30 [2495] 2c 30 2c 30 2c 30 2c 30 2e 36 32 2c 33 2c 31 30 2e 33 0a 44 61 79 73 20 77 69 74 68 20 [2524] 53 6e 6f 77 20 44 65 70 74 68 2c 3e 3d 20 31 30 20 63 6d 2c 33 2e 34 2c 31 2e 36 2c 30 [2553] 2e 31 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2e 31 34 2c 31 2e 35 2c 36 2e 36 [2582] 0a 44 61 79 73 20 77 69 74 68 20 53 6e 6f 77 20 44 65 70 74 68 2c 3e 3d 20 32 30 20 63 [2611] 6d 2c 31 2e 34 2c 30 2e 35 35 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c 30 2c [2640] 30 2e 33 35 2c 32 2e 33 0a attr(,"filename") [1] "Climate_HistoricalNormals.csv"

tmp = tempfile(fileext = ".dta") writeBin(f, tmp)

Final command produces the following error:

Error in writeBin(f, tmp) : can only write vector objects Called from: writeBin(f, tmp)

brownaa commented 8 years ago

I figured out a process for working with CSV and other text-based files. I don't know how to generalize this to all file types yet though. How should I communicate that to include in the project?

pdurbin commented 8 years ago

@brownaa maybe for now you could attach your script or whatever to this issue. You might need to change the extension to ".txt".