Basic read/write capability for the x3p surface metrology format in R
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Basic read/write utilities for the x3p surface metrology format in R. The package also supports the DigitalSurf .sur () format. X3pr is now failrly stable, but still under some development and hence not up on CRAN yet. The best way to install x3pr is with Hadley Wickham's devtools (cf. and

  • If you haven't already done so, first install R ( and then RStudio ( for your operating system. Note that both are open-source (and thus peer-reviewed, ...many times over if that is a concern) and free.

  • Install devtools in your R distribution. In the RStudio Console window type:

    • install.packages("devtools")
  • Windows users: Install Rtools 3.1 as recommended by the devtools package:

  • Mac users: Make sure to install XQuartz ( which is required by rgl.

  • Linux users: Being singularly DIY, you are probably ok. But, ... just incase ... make sure gcc is installed and running. Any toolchain should suffice however. For shinyRGL, try to install from git directly:

    • There is no shinyRGL for Linux up on CRAN
  • Install the required support packages for x3pr. In the RStudio Console window, execute:

    • install.packages("XML")
    • install.packages("rgl")
    • install.packages("shiny")
    • install.packages("shinyRGL") (Windows and Mac only...)
  • Finally, in the RStudio Console window execute: devtools()::install_github("x3pr", username="npetraco").

Examples are provided in the help pages. If you are new to R, below is an example R script which:

  • Loads the x3pr package
  • Reads in the example X3P file shipped with the package (glock.x3p)
  • Prints out the header information in the file
  • Plots the surface (a primer shear) in interactive 3D


file.path <- system.file("extdata", "glock.x3p", package="x3pr") <- read.x3p(file.path)[[1]])

plot3D.x3p.file(, 1024, 80, aspect=c(1,3,0.4), plot.type="surface")