{"action":"created","comment":{"url":"https://api.github.com/repos/USGS-R/repgen/pulls/comments/77898343","id":77898343,"diff_hunk":"@@ -7,47 +7,73 @@\n extremesTable <- function(rawData){\n   \n   data <- applyQualifiers(rawData)\n-  no_data <- isEmptyOrBlank(data$dv$min) && isEmptyOrBlank(data$dv$max)\n-  \n-  if (no_data) return (\"The dataset requested is empty.\")\n-  \n+\n+  no_primary <- isEmptyOrBlank(data$primary$min) && isEmptyOrBlank(data$primary$max)\n+  no_upchain <- isEmptyOrBlank(data$upchain$min) && isEmptyOrBlank(data$upchain$max)\n+  no_dv <- isEmptyOrBlank(data$dv$min) && isEmptyOrBlank(data$dv$max)\n+\n+  #No valid data recieved\n+  if(no_primary && no_upchain && no_dv){\n+    return(\"The dataset requested is empty.\")\n+  }\n+    \n   primaryLabel <- getReportMetadata(rawData,'primaryLabel')\n   primaryParameter <- getReportMetadata(rawData,'primaryParameter')\n   primaryUnit <- getReportMetadata(rawData,'primaryUnit')\n   \n-  upchainLabel <- getReportMetadata(rawData,'upchainLabel')\n-  upchainParameter <- getReportMetadata(rawData,'upchainParameter')\n-  upchainUnit <- getReportMetadata(rawData,'upchainUnit')\n-  \n-  dvLabel <- getReportMetadata(rawData,'dvLabel')\n-  dvParameter <- getReportMetadata(rawData,'dvParameter')\n-  dvComputation <- getReportMetadata(rawData,'dvComputation')\n-  dvUnit <- getReportMetadata(rawData,'dvUnit')\n-  \n-  columnNames <- c(\"\",\n-                   \"Date\", \n-                   \"Time\", \n-                   paste(\"Primary series </br>\", primaryParameter, \"</br> (\", primaryUnit, \")\"), \n-                   paste(\"Upchain series </br>\", upchainParameter, \"</br> (\", upchainUnit, \")\")\n-                   )\n+  columnNames <- c(\"\", \"Date\", \"Time\", paste(\"Primary series </br>\", primaryParameter, \"</br> (\", primaryUnit, \")\"))\n+  maxRows <- list()\n+  minRows <- list()\n+\n+  if(!no_upchain){\n+    upchainLabel <- getReportMetadata(rawData,'upchainLabel')\n+    upchainParameter <- getReportMetadata(rawData,'upchainParameter')\n+    upchainUnit <- getReportMetadata(rawData,'upchainUnit')\n+\n+    columnNames <- append(columnNames, paste(\"Upchain series </br>\", upchainParameter, \"</br> (\", upchainUnit, \")\"))\n+\n+    maxRows <- append(maxRows, createDataRows(data[[which(names(data) %in% c(\"upchain\"))]], \"max\", paste(\"Max Inst \", upchainParameter, \" and corresponding \", primaryParameter), TRUE))\n+    maxRows <- append(maxRows, createDataRows(data[[which(names(data) %in% c(\"primary\"))]], \"max\", paste(\"Max Inst \", primaryParameter, \" and corresponding \", upchainParameter), FALSE))\n+    minRows <- append(minRows, createDataRows(data[[which(names(data) %in% c(\"upchain\"))]], \"min\", paste(\"Min Inst \", upchainParameter, \" and corresponding \", primaryParameter), TRUE))\n+    minRows <- append(minRows, createDataRows(data[[which(names(data) %in% c(\"primary\"))]], \"min\", paste(\"Min Inst \", primaryParameter, \" and corresponding \", upchainParameter), FALSE))\n+  } else {\n+    maxRows <- append(maxRows, createDataRows(data[[which(names(data) %in% c(\"primary\"))]], \"max\", paste(\"Max Inst \", primaryParameter), FALSE, FALSE))\n+    minRows <- append(minRows, createDataRows(data[[which(names(data) %in% c(\"primary\"))]], \"min\", paste(\"Min Inst \", primaryParameter), FALSE, FALSE))\n+  }\n   \n-  orderedRowNames <- c(paste(\"Max Inst \", upchainParameter, \" and corresponding \", primaryParameter), \n-                       paste(\"Max Inst \", primaryParameter, \" and corresponding \", upchainParameter),\n-                       paste(\"Max Daily \", dvComputation, \" \", dvParameter),\n-                       paste(\"Min Inst \", upchainParameter, \" and corresponding \", primaryParameter),\n-                       paste(\"Min Inst \", primaryParameter, \" and corresponding \", upchainParameter),\n-                       paste(\"Min Daily \", dvComputation, \" \", dvParameter)\n-                       )\n+  if(!no_dv){\n+    dvLabel <- getReportMetadata(rawData,'dvLabel')\n+    dvParameter <- getReportMetadata(rawData,'dvParameter')\n+    dvComputation <- getReportMetadata(rawData,'dvComputation')\n+    dvUnit <- getReportMetadata(rawData,'dvUnit')\n+    if(!no_upchain){\n+      maxRows <- append(maxRows, createDataRows(data[[which(names(data) %in% c(\"dv\"))]], \"max\", paste(\"Max Daily \", dvComputation, \" \", dvParameter), FALSE))\n+      minRows <- append(minRows, createDataRows(data[[which(names(data) %in% c(\"dv\"))]], \"min\", paste(\"Min Daily \", dvComputation, \" \", dvParameter), FALSE))\n+    } else {\n+      maxRows <- append(maxRows, createDataRows(data[[which(names(data) %in% c(\"dv\"))]], \"max\", paste(\"Max Daily \", dvComputation, \" \", dvParameter), FALSE, FALSE))\n+      minRows <- append(minRows, createDataRows(data[[which(names(data) %in% c(\"dv\"))]], \"min\", paste(\"Min Daily \", dvComputation, \" \", dvParameter), FALSE, FALSE))\n+    }\n+  }\n+\n+  dataRows <- c(maxRows, minRows)\n+\n+  #Change column and row names to their correct forms and add them into the dataframe.\n+  toRet <- data.frame()\n   \n-  index <- which(names(data) %in% c(\"upchain\", \"primary\", \"dv\")) \n-  results <- list()\n+  for(i in 1:length(dataRows)){\n+    toAdd <- cbind(dataRows[[i]][[\"name\"]],dataRows[[i]][,-1]) \n+    colnames(toAdd) <- columnNames\n+    toRet <- rbind(toRet,toAdd)\n+  }\n   \n-  for (i in index) {  \n-    \n-    subset <- data[[i]][which(names(data[[i]])%in%c(\"min\",\"max\"))]\n-    \n-    min.max <- lapply(subset, function(x) {\n+  return(toRet)\n+}\n+\n+createDataRows <- function(data, param, rowName, isUpchain, includeRelated=TRUE, doMerge=TRUE){  \n+    subset <- data[which(names(data)%in%c(param))]","path":"R/extremes-data.R","position":100,"original_position":100,"commit_id":"8e2305ea72d2943706a0a3a4a30dc1c290095d8c","original_commit_id":"8e2305ea72d2943706a0a3a4a30dc1c290095d8c","user":{"login":"lindsaycarr","id":13220910,"avatar_url":"https://avatars.githubusercontent.com/u/13220910?v=3","gravatar_id":"","url":"https://api.github.com/users/lindsaycarr","html_url":"https://github.com/lindsaycarr","followers_url":"https://api.github.com/users/lindsaycarr/followers","following_url":"https://api.github.com/users/lindsaycarr/following{/other_user}","gists_url":"https://api.github.com/users/lindsaycarr/gists{/gist_id}","starred_url":"https://api.github.com/users/lindsaycarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindsaycarr/subscriptions","organizations_url":"https://api.github.com/users/lindsaycarr/orgs","repos_url":"https://api.github.com/users/lindsaycarr/repos","events_url":"https://api.github.com/users/lindsaycarr/events{/privacy}","received_events_url":"https://api.github.com/users/lindsaycarr/received_events","type":"User","site_admin":false},"body":"rename subset to something else (maybe `subsetData`) because subset is a function name and you are overwriting here. You can check if the name already is a function by typing it and then hitting tab in the console - if no suggestions pop up then you're good","created_at":"2016-09-07T20:34:30Z","updated_at":"2016-09-07T20:34:30Z","html_url":"https://github.com/USGS-R/repgen/pull/399#discussion_r77898343","pull_request_url":"https://api.github.com/repos/USGS-R/repgen/pulls/399","_links":{"self":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/comments/77898343"},"html":{"href":"https://github.com/USGS-R/repgen/pull/399#discussion_r77898343"},"pull_request":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/399"}}},"pull_request":{"url":"https://api.github.com/repos/USGS-R/repgen/pulls/399","id":84326887,"html_url":"https://github.com/USGS-R/repgen/pull/399","diff_url":"https://github.com/USGS-R/repgen/pull/399.diff","patch_url":"https://github.com/USGS-R/repgen/pull/399.patch","issue_url":"https://api.github.com/repos/USGS-R/repgen/issues/399","number":399,"state":"open","locked":false,"title":"AQCU-772: Allow extremes report generation for single parameter workflows","user":{"login":"zmoore-usgs","id":20842403,"avatar_url":"https://avatars.githubusercontent.com/u/20842403?v=3","gravatar_id":"","url":"https://api.github.com/users/zmoore-usgs","html_url":"https://github.com/zmoore-usgs","followers_url":"https://api.github.com/users/zmoore-usgs/followers","following_url":"https://api.github.com/users/zmoore-usgs/following{/other_user}","gists_url":"https://api.github.com/users/zmoore-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/zmoore-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmoore-usgs/subscriptions","organizations_url":"https://api.github.com/users/zmoore-usgs/orgs","repos_url":"https://api.github.com/users/zmoore-usgs/repos","events_url":"https://api.github.com/users/zmoore-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/zmoore-usgs/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-07T15:52:13Z","updated_at":"2016-09-07T20:34:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27204f5516e79dd9e865da540d2006445ee11c38","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/USGS-R/repgen/pulls/399/commits","review_comments_url":"https://api.github.com/repos/USGS-R/repgen/pulls/399/comments","review_comment_url":"https://api.github.com/repos/USGS-R/repgen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/USGS-R/repgen/issues/399/comments","statuses_url":"https://api.github.com/repos/USGS-R/repgen/statuses/8e2305ea72d2943706a0a3a4a30dc1c290095d8c","head":{"label":"zmoore-usgs:feature/single-param-extremes","ref":"feature/single-param-extremes","sha":"8e2305ea72d2943706a0a3a4a30dc1c290095d8c","user":{"login":"zmoore-usgs","id":20842403,"avatar_url":"https://avatars.githubusercontent.com/u/20842403?v=3","gravatar_id":"","url":"https://api.github.com/users/zmoore-usgs","html_url":"https://github.com/zmoore-usgs","followers_url":"https://api.github.com/users/zmoore-usgs/followers","following_url":"https://api.github.com/users/zmoore-usgs/following{/other_user}","gists_url":"https://api.github.com/users/zmoore-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/zmoore-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmoore-usgs/subscriptions","organizations_url":"https://api.github.com/users/zmoore-usgs/orgs","repos_url":"https://api.github.com/users/zmoore-usgs/repos","events_url":"https://api.github.com/users/zmoore-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/zmoore-usgs/received_events","type":"User","site_admin":false},"repo":{"id":65741799,"name":"repgen","full_name":"zmoore-usgs/repgen","owner":{"login":"zmoore-usgs","id":20842403,"avatar_url":"https://avatars.githubusercontent.com/u/20842403?v=3","gravatar_id":"","url":"https://api.github.com/users/zmoore-usgs","html_url":"https://github.com/zmoore-usgs","followers_url":"https://api.github.com/users/zmoore-usgs/followers","following_url":"https://api.github.com/users/zmoore-usgs/following{/other_user}","gists_url":"https://api.github.com/users/zmoore-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/zmoore-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmoore-usgs/subscriptions","organizations_url":"https://api.github.com/users/zmoore-usgs/orgs","repos_url":"https://api.github.com/users/zmoore-usgs/repos","events_url":"https://api.github.com/users/zmoore-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/zmoore-usgs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zmoore-usgs/repgen","description":"report generation in R","fork":true,"url":"https://api.github.com/repos/zmoore-usgs/repgen","forks_url":"https://api.github.com/repos/zmoore-usgs/repgen/forks","keys_url":"https://api.github.com/repos/zmoore-usgs/repgen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zmoore-usgs/repgen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zmoore-usgs/repgen/teams","hooks_url":"https://api.github.com/repos/zmoore-usgs/repgen/hooks","issue_events_url":"https://api.github.com/repos/zmoore-usgs/repgen/issues/events{/number}","events_url":"https://api.github.com/repos/zmoore-usgs/repgen/events","assignees_url":"https://api.github.com/repos/zmoore-usgs/repgen/assignees{/user}","branches_url":"https://api.github.com/repos/zmoore-usgs/repgen/branches{/branch}","tags_url":"https://api.github.com/repos/zmoore-usgs/repgen/tags","blobs_url":"https://api.github.com/repos/zmoore-usgs/repgen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zmoore-usgs/repgen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zmoore-usgs/repgen/git/refs{/sha}","trees_url":"https://api.github.com/repos/zmoore-usgs/repgen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zmoore-usgs/repgen/statuses/{sha}","languages_url":"https://api.github.com/repos/zmoore-usgs/repgen/languages","stargazers_url":"https://api.github.com/repos/zmoore-usgs/repgen/stargazers","contributors_url":"https://api.github.com/repos/zmoore-usgs/repgen/contributors","subscribers_url":"https://api.github.com/repos/zmoore-usgs/repgen/subscribers","subscription_url":"https://api.github.com/repos/zmoore-usgs/repgen/subscription","commits_url":"https://api.github.com/repos/zmoore-usgs/repgen/commits{/sha}","git_commits_url":"https://api.github.com/repos/zmoore-usgs/repgen/git/commits{/sha}","comments_url":"https://api.github.com/repos/zmoore-usgs/repgen/comments{/number}","issue_comment_url":"https://api.github.com/repos/zmoore-usgs/repgen/issues/comments{/number}","contents_url":"https://api.github.com/repos/zmoore-usgs/repgen/contents/{+path}","compare_url":"https://api.github.com/repos/zmoore-usgs/repgen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zmoore-usgs/repgen/merges","archive_url":"https://api.github.com/repos/zmoore-usgs/repgen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zmoore-usgs/repgen/downloads","issues_url":"https://api.github.com/repos/zmoore-usgs/repgen/issues{/number}","pulls_url":"https://api.github.com/repos/zmoore-usgs/repgen/pulls{/number}","milestones_url":"https://api.github.com/repos/zmoore-usgs/repgen/milestones{/number}","notifications_url":"https://api.github.com/repos/zmoore-usgs/repgen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zmoore-usgs/repgen/labels{/name}","releases_url":"https://api.github.com/repos/zmoore-usgs/repgen/releases{/id}","deployments_url":"https://api.github.com/repos/zmoore-usgs/repgen/deployments","created_at":"2016-08-15T15:12:50Z","updated_at":"2016-08-15T15:12:51Z","pushed_at":"2016-09-07T18:28:00Z","git_url":"git://github.com/zmoore-usgs/repgen.git","ssh_url":"git@github.com:zmoore-usgs/repgen.git","clone_url":"https://github.com/zmoore-usgs/repgen.git","svn_url":"https://github.com/zmoore-usgs/repgen","homepage":null,"size":11076,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"USGS-R:master","ref":"master","sha":"8c68974081860645c923be596bab9ae93f96c3b0","user":{"login":"USGS-R","id":3188813,"avatar_url":"https://avatars.githubusercontent.com/u/3188813?v=3","gravatar_id":"","url":"https://api.github.com/users/USGS-R","html_url":"https://github.com/USGS-R","followers_url":"https://api.github.com/users/USGS-R/followers","following_url":"https://api.github.com/users/USGS-R/following{/other_user}","gists_url":"https://api.github.com/users/USGS-R/gists{/gist_id}","starred_url":"https://api.github.com/users/USGS-R/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/USGS-R/subscriptions","organizations_url":"https://api.github.com/users/USGS-R/orgs","repos_url":"https://api.github.com/users/USGS-R/repos","events_url":"https://api.github.com/users/USGS-R/events{/privacy}","received_events_url":"https://api.github.com/users/USGS-R/received_events","type":"Organization","site_admin":false},"repo":{"id":31678130,"name":"repgen","full_name":"USGS-R/repgen","owner":{"login":"USGS-R","id":3188813,"avatar_url":"https://avatars.githubusercontent.com/u/3188813?v=3","gravatar_id":"","url":"https://api.github.com/users/USGS-R","html_url":"https://github.com/USGS-R","followers_url":"https://api.github.com/users/USGS-R/followers","following_url":"https://api.github.com/users/USGS-R/following{/other_user}","gists_url":"https://api.github.com/users/USGS-R/gists{/gist_id}","starred_url":"https://api.github.com/users/USGS-R/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/USGS-R/subscriptions","organizations_url":"https://api.github.com/users/USGS-R/orgs","repos_url":"https://api.github.com/users/USGS-R/repos","events_url":"https://api.github.com/users/USGS-R/events{/privacy}","received_events_url":"https://api.github.com/users/USGS-R/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/USGS-R/repgen","description":"report generation in R","fork":false,"url":"https://api.github.com/repos/USGS-R/repgen","forks_url":"https://api.github.com/repos/USGS-R/repgen/forks","keys_url":"https://api.github.com/repos/USGS-R/repgen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/USGS-R/repgen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/USGS-R/repgen/teams","hooks_url":"https://api.github.com/repos/USGS-R/repgen/hooks","issue_events_url":"https://api.github.com/repos/USGS-R/repgen/issues/events{/number}","events_url":"https://api.github.com/repos/USGS-R/repgen/events","assignees_url":"https://api.github.com/repos/USGS-R/repgen/assignees{/user}","branches_url":"https://api.github.com/repos/USGS-R/repgen/branches{/branch}","tags_url":"https://api.github.com/repos/USGS-R/repgen/tags","blobs_url":"https://api.github.com/repos/USGS-R/repgen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/USGS-R/repgen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/USGS-R/repgen/git/refs{/sha}","trees_url":"https://api.github.com/repos/USGS-R/repgen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/USGS-R/repgen/statuses/{sha}","languages_url":"https://api.github.com/repos/USGS-R/repgen/languages","stargazers_url":"https://api.github.com/repos/USGS-R/repgen/stargazers","contributors_url":"https://api.github.com/repos/USGS-R/repgen/contributors","subscribers_url":"https://api.github.com/repos/USGS-R/repgen/subscribers","subscription_url":"https://api.github.com/repos/USGS-R/repgen/subscription","commits_url":"https://api.github.com/repos/USGS-R/repgen/commits{/sha}","git_commits_url":"https://api.github.com/repos/USGS-R/repgen/git/commits{/sha}","comments_url":"https://api.github.com/repos/USGS-R/repgen/comments{/number}","issue_comment_url":"https://api.github.com/repos/USGS-R/repgen/issues/comments{/number}","contents_url":"https://api.github.com/repos/USGS-R/repgen/contents/{+path}","compare_url":"https://api.github.com/repos/USGS-R/repgen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/USGS-R/repgen/merges","archive_url":"https://api.github.com/repos/USGS-R/repgen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/USGS-R/repgen/downloads","issues_url":"https://api.github.com/repos/USGS-R/repgen/issues{/number}","pulls_url":"https://api.github.com/repos/USGS-R/repgen/pulls{/number}","milestones_url":"https://api.github.com/repos/USGS-R/repgen/milestones{/number}","notifications_url":"https://api.github.com/repos/USGS-R/repgen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/USGS-R/repgen/labels{/name}","releases_url":"https://api.github.com/repos/USGS-R/repgen/releases{/id}","deployments_url":"https://api.github.com/repos/USGS-R/repgen/deployments","created_at":"2015-03-04T20:24:02Z","updated_at":"2016-08-31T01:50:11Z","pushed_at":"2016-09-07T19:59:27Z","git_url":"git://github.com/USGS-R/repgen.git","ssh_url":"git@github.com:USGS-R/repgen.git","clone_url":"https://github.com/USGS-R/repgen.git","svn_url":"https://github.com/USGS-R/repgen","homepage":null,"size":11104,"stargazers_count":7,"watchers_count":7,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":9,"forks":11,"open_issues":9,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/399"},"html":{"href":"https://github.com/USGS-R/repgen/pull/399"},"issue":{"href":"https://api.github.com/repos/USGS-R/repgen/issues/399"},"comments":{"href":"https://api.github.com/repos/USGS-R/repgen/issues/399/comments"},"review_comments":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/399/comments"},"review_comment":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/USGS-R/repgen/pulls/399/commits"},"statuses":{"href":"https://api.github.com/repos/USGS-R/repgen/statuses/8e2305ea72d2943706a0a3a4a30dc1c290095d8c"}}}}
{"actor":{"display_login":"lindsaycarr"}}