Skip to content

Commit

Permalink
added in read and save functions that are really just convenience wra…
Browse files Browse the repository at this point in the history
…ppers around basic functions
  • Loading branch information
eharpste committed Jun 27, 2016
1 parent 1af93cf commit 369d13f
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ vignettes/*.pdf
*.knit.md

# personal files to ignore
setupScript.R
setupScript.R
.Rproj.user
18 changes: 9 additions & 9 deletions ds.plot/R/ds_plot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(ggplot2)

#' A function for ploting DataShop Learning Curves
#' A Smooth Plot DataShop Learning Curves
#'
#' Creates a loess smoothed ggplot from a student step roll up output from Datashop.
#'
Expand All @@ -11,21 +12,20 @@
#' @keywords ds.plot
#' @export
#' @examples
#' ds.plot()

ds.plot <- function(stu.step, model, kc="all", title="",axis.scale=1){

mod.name <- paste0("KC (",model,")")
opp.name <- paste0("Opportunity (",model,")")
pred.name <- paste0("Predicted Error Rate (",model,")")

ds <- stu.step
ds$knowledge_component <- as.factor(ds[[mod.name]])
ds$opportunity <- ds[[opp.name]]
ds$afm.predict <- ds[[pred.name]]
ds$actual <- 1
ds$actual[ds[["First Attempt"]] == "correct"] <- 0

if (kc == "all" || kc < 1) {
opp <- ds$opportunity
y <- ds$actual
Expand All @@ -49,7 +49,7 @@ ds.plot <- function(stu.step, model, kc="all", title="",axis.scale=1){
error <- c(y, afm.std)
label <- as.factor(c(rep("Actual", length(y)), rep("AFM", length(afm.std))))
plotData = data.frame(opp, error, label)

if(title == "") {
if(kc.name == "all") {
title = model
Expand All @@ -58,7 +58,7 @@ ds.plot <- function(stu.step, model, kc="all", title="",axis.scale=1){
title = kc.name
}
}

plot <- ggplot() +
geom_smooth(data=plotData, aes(x=opp, y=error, group=label, color=label, fill=label)) +
coord_cartesian(ylim=c(0, 1)) +
Expand All @@ -72,6 +72,6 @@ ds.plot <- function(stu.step, model, kc="all", title="",axis.scale=1){
axis.title = element_text(size=rel(axis.scale)),
legend.position = "none"
)

return(plot)
}
}
7 changes: 7 additions & 0 deletions ds.plot/R/ds_read.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' Read in a DataShop Student-Step rollup file
#'
#' @param file.name The name of the file to read in.

ds.read <- function(file.name) {
return(read.csv(file = file.name,sep="\t",check.names=F))
}
5 changes: 5 additions & 0 deletions ds.plot/R/ds_save.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library(ggplot2)

ds.save <- function(plot, name, width=3, height=2.5, dpi=300) {
ggsave(plot,name,width=width,height=height,dpi=300,units="in")
}
5 changes: 5 additions & 0 deletions ds.plot/ds.plot.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

Expand Down
5 changes: 1 addition & 4 deletions ds.plot/man/ds.plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions ds.plot/man/ds.read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 369d13f

Please sign in to comment.