gen_agfile: Autograde Single Column CSV File Format

Description Usage Arguments Value Examples

View source: R/gen_agfile.R

Description

Creates a valid autograde file when supplied with a single prediction vector

Usage

1
gen_agfile(yhat, file.name = "ag_sub")

Arguments

yhat

A vector of predicted y values.

file.name

A string to name the file (without a file extension).

Value

A .csv with observations on each new line written to the working directory given by getwd().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Set seed for reproducibility
set.seed(1337)

# Simulate values
n = 100
beta = 2.5
x = beta*rnorm(n, 0, 1)
y = x + rnorm(n, 1, 2)

# Create a regression model
mod = lm(y~x)

## Predict under model
yhat = predict(mod)

gen_agfile(yhat,file.name="ag_org")

## Predict under new data
new = data.frame(x = seq(-3, 3, 0.5))
yhat2 = predict(mod, new)

gen_agfile(yhat2, file.name="ag_new")

coatless/autograde documentation built on May 13, 2019, 8:45 p.m.