Skip to content

Commit

Permalink
Add documentation. Convert to "data =" syntax. Change pch.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpbray committed Nov 3, 2015
1 parent 278e86c commit 14fb47e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
26 changes: 17 additions & 9 deletions R/plot_ss.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#' plot_ss
#' @description what does this do?
#' @param x
#' @param y
#' @param showSquares
#' @param leastSquares
#'
#' An interactive function that will generate a scatterplot of two variables, then
#' allow the user to click the plot in two locations to draw a best fit line.
#' Residuals are drawn by default; boxes representing the squared residuals are
#' optional.
#'
#' @param x the name of numerical vector 1
#' @param y the name of numerical vector 2
#' @param data the dataframe in which x and y can be found
#' @param showSquares logical option to show boxes representing the squared residuals
#' @param leastSquares logical option to bypass point entry and automatically draw the least squares line
#' @export
#'
#'

plot_ss <- function(x, y, showSquares = FALSE, leastSquares = FALSE){
plot(y~x, asp = 1)# xlab = paste(substitute(x)), ylab = paste(substitute(y)))
plot_ss <- function(x, y, data, showSquares = FALSE, leastSquares = FALSE){
x <- eval(substitute(x), data)
y <- eval(substitute(y), data)
plot(y ~ x, asp = 1, pch = 16)# xlab = paste(substitute(x)), ylab = paste(substitute(y)))

if(leastSquares){
m1 <- lm(y~x)
m1 <- lm(y ~ x)
y.hat <- m1$fit
} else{
cat("Click two points to make a line.")
Expand Down
17 changes: 11 additions & 6 deletions man/plot_ss.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
\alias{plot_ss}
\title{plot_ss}
\usage{
plot_ss(x, y, showSquares = FALSE, leastSquares = FALSE)
plot_ss(x, y, data, showSquares = FALSE, leastSquares = FALSE)
}
\arguments{
\item{x}{}
\item{x}{the name of numerical vector 1}

\item{y}{}
\item{y}{the name of numerical vector 2}

\item{showSquares}{}
\item{data}{the dataframe in which x and y can be found}

\item{leastSquares}{}
\item{showSquares}{logical option to show boxes representing the squared residuals}

\item{leastSquares}{logical option to bypass point entry and automatically draw the least squares line}
}
\description{
what does this do?
An interactive function that will generate a scatterplot of two variables, then
allow the user to click the plot in two locations to draw a best fit line.
Residuals are drawn by default; boxes representing the squared residuals are
optional.
}

0 comments on commit 14fb47e

Please sign in to comment.