Learn R Programming

Rpdb (version 2.0)

coords.data.frame: Create coords Object From data.frame or matrix

Description

Create an object of class coords from a data.frame or a matrix.

Usage

## S3 method for class 'data.frame':
coords(x, basis = NULL, \dots)

## S3 method for class 'matrix': coords(x, basis = NULL, \dots)

Arguments

x
a data.frame containing x, y and z or a, b and c columns.
basis
a single element character vector indicating the type of basis vector used to express the atomic coordinates.
...
further arguments passed to or from other methods.

Value

  • Return a data.frame of class coords whose columns contain the three coordinates of the atoms of a molecular system. The coordinates can either be Cartesian (basis attribute equal to "xyz") or fractional coordinates (basis attirbute equal to "abc").

Details

When basis==NULL this function search x, y, z or a, b, c columns in x.

If x, y, z columns are found in x they are used to a set the first, second and third coordinates of the returned coords object. In that case the basis set of x is set to "xyz".

If a, b, c columns are found in x they are used to a set the first, second and third coordinates of the returned coords object. In that case the basis set of x is set to "abc".

If the function doesn't found neither the x, y, z nor the a, b, c columns an error is returned.

When basis!=NULL it has to be equal to "xyz" or "abc" and x must have exactly 3 columns.

See Also

basis, coords

Examples

Run this code
x <- data.frame(x=1:3,y=4:6,z=7:9)
class(x)
x <- coords(x)
class(x)
x <- data.frame(a=1:3,b=4:6,c=7:9)
class(x)
x <- coords(x)
class(x)

x <- data.frame(x=1:3,a=4:6,V=7:9)
x <- coords(x)

Run the code above in your browser using DataLab