# P3d

### From Wiki1

This page describes the 'p3d' package in R. See also the spida package.

The 'p3d' package has a small number of functions that are designed to simplify plotting data and fitted surfaces for models that are functionally defined by two continuous variables or by two continuous variables and one categorical variable.

The currently available version of the p3d package has been compiled with R-3.0.0

## Contents |

## Installation

#### On a PC

# install some required packages and their dependencies install.packages(c('car', 'rgl')) # to install 'p3d' download.file("http://blackwell.math.yorku.ca/R/p3d.zip", "p3d.zip") install.packages("p3d.zip", repos = NULL)

The commands above only need to be used occasionally to update your version of the package or when you have installed a new version of R.

At each R session, you load the package with the R commands:

library(p3d)

#### On a Mac

On a Mac, you need to install this packages using the shell (Terminal in Mac)

- First, you need to install developer tools - that is Xcode 3.1 for Mac OS X 10.5 (Leopard) or Xcode 3.2 for Mac OS X 10.6 (Snow Leopard) or Xcode 4 for Mac OS X 10.7 (Lion) Xcode is present on the OS X installation DVD or can be downloaded from http://developer.apple.com/mac/. Xcode 4 is also available for free in the App Store. (If you want Xcode 3.1 or 3.2 but don't want to join Apple Developer, it is available other places if you are a bit resourceful.)

## The following 3 lines only need to be run when you start using R and after ## installing a new version of R. ## They install the package 'p3d' in your R libraries ## so they are available to be loaded with the library command. install.packages(c('car','rgl','mgcv')) path <- .libPaths()[1] download.file("http://blackwell.math.yorku.ca/R/p3d.tar.gz", paste(path,"/p3d.tar.gz", sep="")) .libPaths()[1]

- This last line of code will print out the file path to the newly downloaded files. Copy the whole path from R.
- Next, go outside of R to
**Finder -> Applications -> Utilities -> Terminal**- In the terminal window type: cd <paste file path>
- In the terminal window type: R CMD INSTALL p3d.tar.gz

The commands above only need to be used occasionally to update your version of the packages or when you have installed a new version of R.

At each R session, you load the package with the R commands:

library(p3d) # note that a number of other packages get loaded at the same time

If you run into problems, have a look at this MacOSX help file. Please let me know if you find a solution.

#### On All Operating Systems (including Linux)

## On All Operating Systems (including Linux)

You can use Hadley Wickam's package 'devtools':

install.packages("devtools") library(devtools) install_url("http://blackwell.math.yorku.ca/R/p3d.tar.gz")

## Overview

The major functions are:

- Init3d()
- Initializes a 3D plotting window so that mouse controls are appropriate for regression data where the axis of the dependent variable maintains a vertical orientation.
- Plot3d(y ~ x + z | g, data)
- Plots data with distinct colors for each group identified by distinct values of 'g'.
- Fit3d(lm(y ~ x * z * g , data))
- Graphs regression surfaces.
- Id3d()
- Identifies points.