#===================================================================================
#Extreme gradient boosted machines
#===================================================================================
#install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
#install.packages("xgboost")
#install.packages("xgboost", repos="http://dmlc.ml/drat/", type = "source")
library(xgboost)
#install.packages(" DiagrammeR")
#install.packages("drat", repos="https://cran.rstudio.com")
#install.packages("DiagrammeR")
library(DiagrammeR)
require(xgboost)
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
str(train)
List of 2
$ data :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. ..@ i : int [1:143286] 2 6 8 11 18 20 21 24 28 32 ...
.. ..@ p : int [1:127] 0 369 372 3306 5845 6489 6513 8380 8384 10991 ...
.. ..@ Dim : int [1:2] 6513 126
.. ..@ Dimnames:List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:126] "cap-shape=bell" "cap-shape=conical" "cap-shape=convex" "cap-shape=flat" ...
.. ..@ x : num [1:143286] 1 1 1 1 1 1 1 1 1 1 ...
.. ..@ factors : list()
$ label: num [1:6513] 1 0 0 1 0 0 0 1 0 0 ...
train$data
6513 x 126 sparse Matrix of class "dgCMatrix"
[[ suppressing 44 column names ‘cap-shape=bell’, ‘cap-shape=conical’, ‘cap-shape=convex’ ... ]]
[[ suppressing 44 column names ‘cap-shape=bell’, ‘cap-shape=conical’, ‘cap-shape=convex’ ... ]]
[1,] . . 1 . . . . . . 1 1 . . . . . . . . . 1 . . . . . . . . 1 . . . 1 . 1 . . . 1 1 . . . ......
[2,] . . 1 . . . . . . 1 . . . . . . . . . 1 1 . 1 . . . . . . . . . . 1 . 1 . . 1 . 1 . . . ......
[3,] 1 . . . . . . . . 1 . . . . . . . . 1 . 1 . . 1 . . . . . . . . . 1 . 1 . . 1 . . 1 . . ......
[4,] . . 1 . . . . . 1 . . . . . . . . . 1 . 1 . . . . . . . . 1 . . . 1 . 1 . . . 1 . 1 . . ......
[5,] . . 1 . . . . . . 1 . . . 1 . . . . . . . 1 . . . . . . 1 . . . . 1 . . 1 . 1 . 1 . . . ......
[6,] . . 1 . . . . . 1 . . . . . . . . . . 1 1 . 1 . . . . . . . . . . 1 . 1 . . 1 . . 1 . . ......
[7,] 1 . . . . . . . . 1 . . . . . . . . 1 . 1 . 1 . . . . . . . . . . 1 . 1 . . 1 . . . . . ......
[8,] . . 1 . . . . . 1 . . . . . . . . . 1 . 1 . . . . . . . . 1 . . . 1 . 1 . . . 1 . . . . ......
[9,] 1 . . . . . . . . 1 . . . . . . . . . 1 1 . 1 . . . . . . . . . . 1 . 1 . . 1 . . . . . ......
[10,] . . 1 . . . . . 1 . . . . . . . . . . 1 1 . . 1 . . . . . . . . . 1 . 1 . . 1 . . . . . ......
[11,] . . 1 . . . . . 1 . . . . . . . . . . 1 1 . 1 . . . . . . . . . . 1 . 1 . . 1 . . 1 . . ......
..............................
........suppressing columns and rows in show(); maybe adjust 'options(max.print= *, width = *)'
..............................
[[ suppressing 44 column names ‘cap-shape=bell’, ‘cap-shape=conical’, ‘cap-shape=convex’ ... ]]
[6503,] 1 . . . . . . . . 1 . . . . . . . . 1 . . 1 . . . . . . 1 . . . . 1 . . 1 . 1 . . . . . ......
[6504,] . . 1 . . . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . . . . ......
[6505,] . . . . 1 . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . . . . ......
[6506,] . . . 1 . . . . 1 . . . 1 . . . . . . . . 1 . . . . . 1 . . . 1 . . . 1 . . 1 . . . . . ......
[6507,] . . 1 . . . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . . . . ......
[6508,] . . . . 1 . . . 1 . 1 . . . . . . . . . . 1 . . . . . . . . 1 . . 1 . 1 . . . 1 . . 1 . ......
[6509,] . . . . 1 . . . . 1 . . . . . . . 1 . . . 1 . . . 1 . . . . . . . 1 . 1 . . . 1 . . 1 . ......
[6510,] . . . . 1 . . . 1 . 1 . . . . . . . . . . 1 . . . . 1 . . . . . . 1 . 1 . . . 1 . . 1 . ......
[6511,] . . 1 . . . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . . . . ......
[6512,] . . . 1 . . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . 1 . . ......
[6513,] . . 1 . . . . . . 1 1 . . . . . . . . . . 1 . . . . . . 1 . . 1 . . . 1 . . 1 . . . . . ......
class(train)
[1] "list"
#dgCMatrix
model <- xgboost(data = train$data, label = train$label,
nrounds = 2, objective = "binary:logistic")
[1] train-error:0.000614
[2] train-error:0.001228
#preds = predict(model, test)
#confusionMatrix(test$label,preds)
cv.res <- xgb.cv(data = train$data, label = train$label, nfold = 5,
nrounds = 2, objective = "binary:logistic")
[1] train-error:0.000921+0.000282 test-error:0.001228+0.001041
[2] train-error:0.001075+0.000260 test-error:0.001228+0.001041
loglossobj <- function(preds, dtrain) {
# dtrain is the internal format of the training data
# We extract the labels from the training data
labels <- getinfo(dtrain, "label")
# We compute the 1st and 2nd gradient, as grad and hess
preds <- 1/(1 + exp(-preds))
grad <- preds - labels
hess <- preds * (1 - preds)
# Return the result as a list
return(list(grad = grad, hess = hess))
}
model <- xgboost(data = train$data, label = train$label,
nrounds = 2, objective = loglossobj, eval_metric = "error")
[1] train-error:0.001228
[2] train-error:0.001228
bst <- xgb.cv(data = train$data, label = train$label, nfold = 5,
nrounds = 20, objective = "binary:logistic",
early_stopping_rounds = 3, maximize = FALSE)
[1] train-error:0.000921+0.000372 test-error:0.001228+0.000376
Multiple eval metrics are present. Will use test_error for early stopping.
Will train until test_error hasn't improved in 3 rounds.
[2] train-error:0.001228+0.000094 test-error:0.001228+0.000376
[3] train-error:0.000653+0.000448 test-error:0.001075+0.000614
[4] train-error:0.000192+0.000243 test-error:0.000461+0.000614
[5] train-error:0.000000+0.000000 test-error:0.000000+0.000000
[6] train-error:0.000000+0.000000 test-error:0.000000+0.000000
[7] train-error:0.000000+0.000000 test-error:0.000000+0.000000
[8] train-error:0.000000+0.000000 test-error:0.000000+0.000000
Stopping. Best iteration:
[5] train-error:0.000000+0.000000 test-error:0.000000+0.000000
dtrain <- xgb.DMatrix(train$data, label = train$label)
model <- xgboost(data = dtrain, nrounds = 2, objective = "binary:logistic")
[1] train-error:0.000614
[2] train-error:0.001228
pred_train <- predict(model, dtrain, outputmargin=TRUE)
setinfo(dtrain, "base_margin", pred_train)
[1] TRUE
model <- xgboost(data = dtrain, nrounds = 2, objective = "binary:logistic")
[1] train-error:0.000614
[2] train-error:0.000614
dat <- matrix(rnorm(128), 64, 2)
label <- sample(0:1, nrow(dat), replace = TRUE)
for (i in 1:nrow(dat)) {
ind <- sample(2, 1)
dat[i, ind] <- NA
}
model <- xgboost(data = dat, label = label, missing = NA,
nrounds = 2, objective = "binary:logistic")
[1] train-error:0.250000
[2] train-error:0.250000
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2, objective = "binary:logistic")
[1] train-error:0.046522
[2] train-error:0.022263
xgb.plot.tree(feature_names = agaricus.train$data@Dimnames[[2]], model = bst)
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 10, objective = "binary:logistic")
[1] train-error:0.046522
[2] train-error:0.022263
[3] train-error:0.007063
[4] train-error:0.015200
[5] train-error:0.007063
[6] train-error:0.001228
[7] train-error:0.001228
[8] train-error:0.001228
[9] train-error:0.001228
[10] train-error:0.000000
xgb.plot.tree(feature_names = agaricus.train$data@Dimnames[[2]], model = bst)
bst <- xgboost(data = train$data, label = train$label, max.depth = 15,
eta = 1, nthread = 2, nround = 30, objective = "binary:logistic",
min_child_weight = 50)
[1] train-error:0.039306
[2] train-error:0.024413
[3] train-error:0.015507
[4] train-error:0.015507
[5] train-error:0.012283
[6] train-error:0.015507
[7] train-error:0.017350
[8] train-error:0.014740
[9] train-error:0.015354
[10] train-error:0.013051
[11] train-error:0.016889
[12] train-error:0.015354
[13] train-error:0.015815
[14] train-error:0.015815
[15] train-error:0.015815
[16] train-error:0.015815
[17] train-error:0.015815
[18] train-error:0.015815
[19] train-error:0.015815
[20] train-error:0.015815
[21] train-error:0.015815
[22] train-error:0.015815
[23] train-error:0.015815
[24] train-error:0.015815
[25] train-error:0.015815
[26] train-error:0.015815
[27] train-error:0.015815
[28] train-error:0.015815
[29] train-error:0.015815
[30] train-error:0.015815
xgb.plot.multi.trees(model = bst, feature_names = agaricus.train$data@Dimnames[[2]], features_keep = 3)
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
[1] train-error:0.046522
[2] train-error:0.022263
importance_matrix <- xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst)
xgb.plot.importance(importance_matrix)
bst <- xgboost(data = train$data, label = train$label, max.depth = 15,
eta = 1, nthread = 2, nround = 30, objective = "binary:logistic",
min_child_weight = 50)
[1] train-error:0.039306
[2] train-error:0.024413
[3] train-error:0.015507
[4] train-error:0.015507
[5] train-error:0.012283
[6] train-error:0.015507
[7] train-error:0.017350
[8] train-error:0.014740
[9] train-error:0.015354
[10] train-error:0.013051
[11] train-error:0.016889
[12] train-error:0.015354
[13] train-error:0.015815
[14] train-error:0.015815
[15] train-error:0.015815
[16] train-error:0.015815
[17] train-error:0.015815
[18] train-error:0.015815
[19] train-error:0.015815
[20] train-error:0.015815
[21] train-error:0.015815
[22] train-error:0.015815
[23] train-error:0.015815
[24] train-error:0.015815
[25] train-error:0.015815
[26] train-error:0.015815
[27] train-error:0.015815
[28] train-error:0.015815
[29] train-error:0.015815
[30] train-error:0.015815
xgb.plot.deepness(model = bst)
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 10, objective = "binary:logistic")
[1] train-error:0.046522
[2] train-error:0.022263
[3] train-error:0.007063
[4] train-error:0.015200
[5] train-error:0.007063
[6] train-error:0.001228
[7] train-error:0.001228
[8] train-error:0.001228
[9] train-error:0.001228
[10] train-error:0.000000
xgb.plot.tree(feature_names = agaricus.train$data@Dimnames[[2]], model = bst)
library(xgboost)
library(readr)
library(stringr)
library(caret)
Loading required package: lattice
Loading required package: ggplot2
library(car)
#=========================================================================================================================
#
# DiagrammeR package Tutorial
#
#=========================================================================================================================
ls("package:DiagrammeR")
[1] "%>%" "add_balanced_tree" "add_cycle"
[4] "add_edge" "add_edge_clone" "add_edge_df"
[7] "add_edges_from_table" "add_edges_w_string" "add_forward_edges_ws"
[10] "add_full_graph" "add_global_graph_attrs" "add_gnp_graph"
[13] "add_graph_action" "add_grid_2d" "add_grid_3d"
[16] "add_mathjax" "add_n_node_clones" "add_n_nodes"
[19] "add_n_nodes_ws" "add_node" "add_node_df"
[22] "add_nodes_from_df_cols" "add_nodes_from_table" "add_pa_graph"
[25] "add_path" "add_prism" "add_reverse_edges_ws"
[28] "add_star" "add_to_series" "cache_edge_attrs"
[31] "cache_edge_attrs_ws" "cache_edge_count_ws" "cache_node_attrs"
[34] "cache_node_attrs_ws" "cache_node_count_ws" "clear_global_graph_attrs"
[37] "clear_selection" "colorize_edge_attrs" "colorize_node_attrs"
[40] "combine_edfs" "combine_graphs" "combine_ndfs"
[43] "copy_edge_attrs" "copy_node_attrs" "count_asymmetric_node_pairs"
[46] "count_automorphisms" "count_mutual_node_pairs" "count_unconnected_node_pairs"
[49] "create_complement_graph" "create_edge_df" "create_graph"
[52] "create_node_df" "create_random_graph" "create_series"
[55] "create_subgraph_ws" "delete_edge" "delete_edges_ws"
[58] "delete_global_graph_attrs" "delete_graph_actions" "delete_node"
[61] "delete_nodes_ws" "DiagrammeR" "DiagrammeROutput"
[64] "display_metagraph" "do_bfs" "do_dfs"
[67] "drop_edge_attrs" "drop_node_attrs" "edge_count"
[70] "edge_info" "edge_present" "edge_rel"
[73] "export_csv" "export_graph" "from_adj_matrix"
[76] "from_igraph" "generate_dot" "get_adhesion"
[79] "get_agg_degree_in" "get_agg_degree_out" "get_agg_degree_total"
[82] "get_all_connected_nodes" "get_alpha_centrality" "get_articulation_points"
[85] "get_attr_dfs" "get_authority_centrality" "get_betweenness"
[88] "get_bridging" "get_cache" "get_closeness"
[91] "get_closeness_vitality" "get_cmty_edge_btwns" "get_cmty_fast_greedy"
[94] "get_cmty_l_eigenvec" "get_cmty_louvain" "get_cmty_walktrap"
[97] "get_common_nbrs" "get_constraint" "get_coreness"
[100] "get_degree_distribution" "get_degree_histogram" "get_degree_in"
[103] "get_degree_out" "get_degree_total" "get_dice_similarity"
[106] "get_eccentricity" "get_edge_attrs" "get_edge_attrs_ws"
[109] "get_edge_count_w_multiedge" "get_edge_df" "get_edge_ids"
[112] "get_edges" "get_eigen_centrality" "get_girth"
[115] "get_global_graph_attrs" "get_graph_actions" "get_graph_from_series"
[118] "get_graph_log" "get_graph_name" "get_graph_time"
[121] "get_jaccard_similarity" "get_last_edges_created" "get_last_nodes_created"
[124] "get_leverage_centrality" "get_max_eccentricity" "get_mean_distance"
[127] "get_min_cut_between" "get_min_eccentricity" "get_min_spanning_tree"
[130] "get_multiedge_count" "get_nbrs" "get_node_attrs"
[133] "get_node_attrs_ws" "get_node_df" "get_node_ids"
[136] "get_non_nbrs" "get_pagerank" "get_paths"
[139] "get_periphery" "get_predecessors" "get_radiality"
[142] "get_reciprocity" "get_s_connected_cmpts" "get_selection"
[145] "get_similar_nbrs" "get_successors" "get_w_connected_cmpts"
[148] "graph_count" "graph_info" "grViz"
[151] "grVizOutput" "image_icon" "import_graph"
[154] "invert_selection" "is_edge_loop" "is_edge_multiple"
[157] "is_edge_mutual" "is_graph_connected" "is_graph_dag"
[160] "is_graph_directed" "is_graph_empty" "is_graph_simple"
[163] "is_graph_weighted" "is_property_graph" "join_edge_attrs"
[166] "join_node_attrs" "layout_nodes_w_string" "mermaid"
[169] "mutate_edge_attrs" "mutate_edge_attrs_ws" "mutate_node_attrs"
[172] "mutate_node_attrs_ws" "node_count" "node_info"
[175] "node_present" "node_type" "nudge_node_positions_ws"
[178] "open_graph" "recode_edge_attrs" "recode_node_attrs"
[181] "remove_from_series" "rename_edge_attrs" "rename_node_attrs"
[184] "render_graph" "render_graph_from_series" "renderDiagrammeR"
[187] "renderGrViz" "reorder_graph_actions" "replace_in_spec"
[190] "rescale_edge_attrs" "rescale_node_attrs" "rev_edge_dir"
[193] "rev_edge_dir_ws" "save_graph" "select_edges"
[196] "select_edges_by_edge_id" "select_edges_by_node_id" "select_last_edges_created"
[199] "select_last_nodes_created" "select_nodes" "select_nodes_by_degree"
[202] "select_nodes_by_id" "select_nodes_in_neighborhood" "series_info"
[205] "set_cache" "set_df_as_edge_attr" "set_df_as_node_attr"
[208] "set_edge_attrs" "set_edge_attrs_ws" "set_global_graph_attrs"
[211] "set_graph_name" "set_graph_time" "set_graph_undirected"
[214] "set_node_attr_to_display" "set_node_attr_w_fcn" "set_node_attrs"
[217] "set_node_attrs_ws" "set_node_position" "subset_series"
[220] "to_igraph" "trav_both" "trav_both_edge"
[223] "trav_in" "trav_in_edge" "trav_in_node"
[226] "trav_out" "trav_out_edge" "trav_out_node"
[229] "trav_reverse_edge" "trigger_graph_actions" "visnetwork"
[232] "x11_hex"
grViz("
digraph boxes_and_circles{
node [shape = box]
A; B; C; D
}
")
grViz("
digraph bayesModel {
graph [overlap = true, fontsize = 10]
# I'll make the data a triangle
node [shape = triangle,
fontname = Helvetica]
y
# parameters will be boxes
node [shape = box,
fontname = Helvetica]
theta; sigma2; mu; tau2; lambda; phi2; psi;
delta; gamma; omega2; c; d
# distributions will be circles.
node [shape = circle,
fixedsize = false,
width = 0.9] // sets as circles
normal1 normal2 normal3 normal4 invGamma1 invGamma2
# several 'edge' statements
{gamma omega2}->normal1->lambda
{c d}->invGamma1->phi2
{lambda phi2}->normal2->mu
{psi delta}->invGamma2->tau2
{mu tau2}->normal3->theta
{theta sigma2}->normal4->y
}
")
mermaid("
graph TD
a[gamma]-->c(normal1)
b[omega2]-->c(normal1)
c-->d[lambda]
e[c]-->g(invGamma1)
f[d]-->g(invGamma1)
g-->h[phi2]
d-->k(normal2)
h-->k(normal2)
k-->l[mu]
m[psi]-->o(invGamma2)
n[delta]-->o(invGamma2)
o(invGamma2)-->p[tau2]
l-->q(normal3)
p-->q(normal3)
q-->r[theta]
r-->t(normal4)
s[sigma2]-->t(normal4)
t-->u>y]
")
#=========================================================================================================================
#
# editR package
#
#=========================================================================================================================
#devtools::install_github("trestletech/shinyAce")
#devtools::install_github("swarm-lab/editR")
#install.packages(c("shiny", "shinyFiles", "shinyBS", "rmarkdown", "knitr"))
library(editR) # renders an r files as a markdown document
library(shinyAce)
library(rmarkdown)
#Now that that's installed and attached, I'm just supposed to call editR() on a .Rmd file. Here goes with my cold winter
#stats./) post from last spring.
#editR(file = "coldWinterStats.Rmd")
# editR
#
# IMPORTANT: the latest version of editR (>=0.2) has undergone important modifications (see release notes below). The most important changes are the following:
#
# - editR is now fully compatible with the latest version of shiny on CRAN (>=0.11). editR was modified to support Twitter Bootstrap version 3 instead of version 2 as in the previous releases.
#
# - editR now relies (almost) entirely on packages available through CRAN and not on a large number of experimental packages as previously. This will facilitate the installation process.
#
# As a consequence of these modifications I strongly recommend that you reinstall editR following the new instructions below.
#
# Release notes
#
# editR is a basic Rmarkdown editor with instant previewing of your document. It allows you to create and edit Rmarkdown documents while instantly previewing the result of your writing and coding. It also allows you to render your Rmarkdown file in any format permitted by the rmarkdown R package.
#
# Screenshot of editR window
#
# Installation
#
# Installing editR from this GitHub repository is now pretty straightforward. Simply copying the following lines of code in your R terminal should to install everything you need to run editR on your computer:
#
# if (!require("devtools")) install.packages("devtools")
# devtools::install_github("trestletech/shinyAce")
# devtools::install_github("swarm-lab/editR")
#
# library(editR)
# editR requires the installation of the latest versions of following packages on CRAN:
#
# shiny
# shinyFiles
# shinyBS
# rmarkdown
# knitr
# It also requires the installation of the development version of the following package on GitHub:
#
# shinyAce
# Finally, to render documents in various output formats (.html, .pdf, .docx), editR uses the render function from the rmarkdown package. This function requires the installation of pandoc to work. Installation instructions for pandoc can be found at: http://johnmacfarlane.net/pandoc/installing.html. For Mac users, I recommend that you install pandoc via Homebrew or MacPorts.
#
# Usage
#
# To start editR, simply run this line of code in your R console:
#
# editR("path/to/file.Rmd")
# with "path/to/file.Rmd" the path to a new or existing .Rmd (or .md) file. If this is a new file, it will be created at this location. You can also open an existing file from within editR using the File > Open file menu.
#
# You can also open editR without providing a path to a new or existing .Rmd file.
#
# editR()
# In this case a temporary new file will be created that can then be saved from withing the user interface of editR.
#
# For more information about authoring Rmarkdown files, visit http://rmarkdown.rstudio.com/.
#
#
#=========================================================================================================================
#
# servr package
#
#=========================================================================================================================
#Yihui Xie's servr can apparently do real-time rendering as well. I can't speak to its functionality, but I
#may try it in the future
#=========================================================================================================================
#
# R Function to Make Octopress Posts
#
#=========================================================================================================================
#I've taken my first steps with Octopress, but I'm still a little wobbly on my feet (er, arms). Since I write most of
#my posts in RStudio using the RMarkdown language and the knitr package, I thought I'd try writing a function in R that
#knits my .rmd (that's the RMarkdown extension) files directly to my blog, including making a new post and assigning
#categories and tags. When I was using wordpress I could use the knit2wp function, but that was back when I was still
#doing things the easy way. Here goes!
# knit2blog = function(file, layout = "post", title,
# comments = c("true", "false"), categories = "",
# blogdir = getOption("blogdir"),
# postdir = getOption("postdir"), mate = F){
#
# curdir = getwd(); on.exit(setwd(curdir))
#
# # knit to temporary html file
# outfile = "temp_outfile.html"
# knit2html(file, output = outfile) # HTML content, temporarily stored in wd
#
# # Make yaml front matter:
# comments = match.arg(comments)
# curtime = format(Sys.time(), "%Y-%m-%d %H:%M:%S %z")
#
# if(length(categories) > 1)
# categstr = paste0("[", paste(categories, collapse = ", "), "]")
# else categstr = categories
#
# yamlfm = paste0("---\nlayout: ", layout, '\ntitle: "', title, '"\ndate: ',
# curtime, "\ncomments: ", comments, "\ncategories: ",
# categstr, "\n---")
#
# # make file with only yaml front matter
# curdate = format(Sys.time(), "%Y-%m-%d-")
# postname = paste0(curdate, title, ".html")
# postloc = paste0('"', blogdir, postdir, '"')
# write.table(yamlfm, postname, quote = F, row.names = F, col.names = F)
#
# # Add html content to yaml front matter html file
# file.append(postname, outfile)
# file.remove(outfile)
#
# pn.q = paste0('"', postname, '"') # NEED EXTRA QUOTES FOR CALLING mv
#
# calstr = paste("mv -f", pn.q, postloc, sep = " ")
# print(calstr)
# system(calstr)
#
# # Optionally open in TextMate
# if(mate) system(paste0("mate ", postloc, "/", pn.q))
# }
#
# options(blogdir = "/Users/nanaakwasiabayieboateng/Documents/memphisclassesbooks/DataMiningscience",
# postdir = "source/_posts/")
# # knit2blog("USGS dataRetrieval.rmd", title = "testtest", categories = c("cat1", "cat2"),
# # mate = T)