vectors: Vector functions

Description Usage Arguments Value Author(s) Examples

Description

These functions simplify working with vectors.

Usage

1
2
3
4
5
dot(x, y)

vlength(x)

project(x, u = rep(1, length(x)), type = c("vector", "length"))

Arguments

u

a numeric vector

x

a numeric vector

y

a numeric vector

type

one of c("vector","length") indicating whether the projection should be returned as a vector (the default) or a length.

Value

dot returns the dot product of two vectors.

vlength returns the length of a vector.

project(x,u) returns the vector (or its length) that results from projecting x in the direction of u. It is not necessary that u be a unit vector.

Author(s)

Randall Pruim

Examples

1
2
3
4
5
6
v <- c(1,1,1,1)
x <- c(1,2,3,4)
vlength(v)
dot(x,v)
dot(x,v) / vlength(x)^2
project(x,v)

Example output

Loading required package: mosaic
Loading required package: dplyr

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Loading required package: lattice
Loading required package: ggformula
Loading required package: ggplot2
Loading required package: ggstance

Attaching package: 'ggstance'

The following objects are masked from 'package:ggplot2':

    GeomErrorbarh, geom_errorbarh


New to ggformula?  Try the tutorials: 
	learnr::run_tutorial("introduction", package = "ggformula")
	learnr::run_tutorial("refining", package = "ggformula")
Loading required package: mosaicData
Loading required package: Matrix

The 'mosaic' package masks several functions from core packages in order to add 
additional features.  The original behavior of these functions should not be affected by this.

Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.

Attaching package: 'mosaic'

The following object is masked from 'package:Matrix':

    mean

The following object is masked from 'package:ggplot2':

    stat

The following objects are masked from 'package:dplyr':

    count, do, tally

The following objects are masked from 'package:stats':

    IQR, binom.test, cor, cor.test, cov, fivenum, median, prop.test,
    quantile, sd, t.test, var

The following objects are masked from 'package:base':

    max, mean, min, prod, range, sample, sum

Loading required package: mosaicCalc
Loading required package: mosaicCore

Attaching package: 'mosaicCore'

The following objects are masked from 'package:dplyr':

    count, tally


Attaching package: 'mosaicCalc'

The following object is masked from 'package:stats':

    D


Attaching package: 'fastR'

The following object is masked from 'package:graphics':

    panel.smooth

[1] 2
[1] 10
[1] 0.3333333
[1] 2.5 2.5 2.5 2.5

fastR documentation built on May 2, 2019, 5:53 p.m.