Last active
May 23, 2016 23:20
-
-
Save benjamin-chan/091209ab4eee1f171540 to your computer and use it in GitHub Desktop.
Function to create metadata object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
makeMetadata <- function(D, note=NULL) { | |
if (is.data.frame(D)) { | |
list(objectName = deparse(substitute(D)), | |
timeStamp = sprintf("%s", Sys.time()), | |
objectSize = format(object.size(D), units="auto"), | |
note = note, | |
rowCount = nrow(D), | |
colCount = ncol(D), | |
colNames = names(D), | |
colClasses = sapply(D, class), | |
sysInfo = Sys.info(), | |
sessionInfo = sessionInfo()) | |
} else { | |
warning(sprintf("Object %s is not a data.frame", deparse(substitute(D)))) | |
} | |
} | |
# Examples: | |
# makeMetadata(cars) | |
# x <- 1 | |
# makeMetadata(x) # Returns a warning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment