I want to extract some information from a .osm.pbf file. I looked through OpenStreetMapX.jl package but didn't find a function to read this data. I am wondering if anyone know a method to read this data. Alternatively is there a way to convert .osm.pbf to .osm file so that I found just use the get_map_data() method offered by OpenStreetMapX package
I would use Osmosis for that:
osmosis --read-pbf myFile.osm.pbf --write-xml myFile.osm
I would use osmium to do this:
osmium cat myFile.osm.pbf -o myFile.osm
Related
Good moorning
I would like to know if there is a way to find where a package is installed.
Actually, I am currently documenting a package. In my package, I have a function called "read.myfile" which reads a specific kind of file (roughly like read.table).
I have an instance of this kind of file named "myfile.txt" in my package's folder. On my documentation, I want to run an executable example of this function.
That's why I need the path, where the user has installed the package. So with this path, I can obtain the path of the file "myfile.txt" and use the function "read.myfile" in the .Rd help file, which gives help about the function "read.myfile".
Thus my example will be executable wherever the user has installed the package.
I hope my message was clear.
I don't know if it's possible to do that, but if anyone knows, thanks for helping me.
Use the function system.file.
For example:
system.file(package="ggplot2")
[1] "C:/Users/Andrie/Documents/R/win-library/3.0/ggplot2"
You can use installed.packages and subset to get the only the location of the library in which it is installed:
installed.packages()["tools","LibPath"]
[1] "C:/Program Files/R/R-2.15.2/library"
I need to do numerical calculations with high precision. There is a c++ library which is called "CLN",although i installed this package , but i do not know how to use it.
Is there an example program which shows how to use it?
Thanks
Something like that ?
http://www.warrenweckesser.net/software/cln/
Download the CLN source code from here, unpack it, and have a look into the examples/ folder. Alternatively, you may browse the same folder using gitweb.
I'm trying to debug my first R script and I came across this line:
data <- read.data(dir, indiv, label)
I've been googling "R read.data" for the past 30 minutes and absolutely nothing is coming up. Am I doing something wrong? Is there a good way to look up things I see in R scripts that I don't know what they are?
And what is this particular line doing anyway?
It's probably a function defined by the author of the script. Search for it in the code you have.
A couple of things to check:
Does your script define the function 'read.data' somewhere? read.data <- function(...
Does your script use library() or require() to load another package? In that case, the read.data function can be defined in that package.
Does your script use source to read another script? Check that script then...
package sos to the rescue:
read.data is a deprecated function in the rjags package
> library(sos)
> findFn("read.data")
Finds this result:
http://finzi.psych.upenn.edu/R/library/rjags/html/read.data.html
From this page:
Read data for a JAGS model from a file.
Usage
read.jagsdata(file)
read.bugsdata(file)
Note
Earlier versions of the rjags package had a read.data function which read data
in either format, but the function name was ambiguous (There are many data file
format in R) so this is now deprecated.
There isn't a base function named read.data. If you want to find help for an R function (for example read.table), simply type ?read.table at the interactive prompt.
This line calls a read.data function which is either defined in that script or in something else it loads (such as libraries with the library() or require(), other scripts with source()). You'll need to search those sources to find this function.
In R, one very neat feature is that the source code of functions is accessible as objects in the workspace.
Thus, if I wanted to know the source code of, for example, grep() I can simply type grep into the console and read the code.
Similarly, I can read the documentation for grep by typing ?grep into the console.
Question: How can I get the source code for the documentation of a function? In other words, where do I find the .rd files?
I find studying the source of well-written code an excellent way of learning the idioms. Now I want to study how to write documentation for some very specific cases. I have not been able to find the documentation files for any of the base R functions in my R installation. Perhaps I have been looking in the wrong place.
It seems you can extract the Rd sources from an installed R. I'm using R-devel (2011-09-05 r56942).
Get the database of Rd for the base package.
library(tools)
db <- Rd_db("base")
Search for "grep.Rd" in the names of the Rd DB, for example:
grep("grep.Rd", names(db), value = TRUE)
[1] "d:/murdoch/recent/R64/src/library/base/man/agrep.Rd"
[2] "d:/murdoch/recent/R64/src/library/base/man/grep.Rd"
Get just the Rd object for grep.
db[grep("/grep.Rd", names(db))]
$`d:/murdoch/recent/R64/src/library/base/man/grep.Rd`
\title{Pattern Matching and Replacement}
\name{grep}
\alias{grep}
\alias{grepl}
\alias{sub}
\alias{gsub}
\alias{regexpr}
\alias{gregexpr}
\alias{regexec}
\keyword{character}
\keyword{utilities}
\description{
\code{grep}, \code{grepl}, \code{regexpr} and \code{gregexpr} search
for matches to argument \code{pattern} within each element of a
character vector: they differ in the format of and amount of detail in
the results.
\code{sub} and \code{gsub} perform replacement of the first and all
matches respectively.
}\usage{
...
...
There are tools for getting the components from the Rd objects, so you can refine searching to keywords or name, see examples in ?Rd_db and try this.
lapply(db, tools:::.Rd_get_metadata, "name")
I have some European Data Format (EDF) files that I would like to import into R.
There are some Python libraries for parsing EDF files and the EDF spec is available, so I know it's possible, but I would avoid writing code if I could.
Does there already exist a facility for importing these kinds of files?
Was looking for the same thing. Found this function written by Fabien Feschet - works well for my data. http://feschet.fr/?p=11
Found another resource recently. This works very well. Need to download both read_edf.R and utilities.R
https://github.com/bwrc/edf/tree/master/R
I tried look for the same thing a while ago, but I couldn't find anything for R. I ended up using biosig Python module to convert edfs to ascii. There is also this edf2ascii-converter.
I guess there wasn't any package available at the time when the question was asked but now you could use edfReader:
https://cran.r-project.org/web/packages/edfReader/
https://github.com/Pisca46/edfReader