attribute_data: Data-attribution

Description Usage Arguments Value Examples

View source: R/setAttributes.R

Description

Attempts to attribute data in a data frame describing data on a grid to a another data frame (with irregular points in x and y. The data frame is assumed to have coordinate values as integer values. Hence, If the data-containing data frame describes a spacing of 1, a simple merge is carried out. If not a nearest-grid interpolation is carried out.

Usage

1
attribute_data(df, info_df, miss_value = 0, averaging_box = NA)

Arguments

df

data frame to which data is attributed. Must contain fields x and y.

info_df

the data-containing data frame. Must contain fields x, y and z and points must lie on an ordered grid.

miss_value

the value attributed to data points which cannot be mapped.

averaging_box

a vector of length 4 describing a box around the values which cannot be matched to the data. The missing value will then be replaced with the average of data found in this box. The vector should of the format (-x1,-y1,x2,y2).

Value

a vector of the data mapped onto the coordinates in df

Examples

1
2
3
df <- data.frame(x=runif(100),y=runif(100))
info_df <- cbind(expand.grid(x=seq(0,1,0.1),y=seq(0,1,0.1)),z=runif(121))
df$z <- attribute_data(df=df,info_df = info_df)

shazhe/mvst0 documentation built on May 29, 2019, 9:20 p.m.