setwd("C:/Documents and Settings/Brian Yandell/Desktop/mydemo")

print("Hello World!")

mygreet <- function(place)
  cat("Hello", place, "!\n")

## Use new function.
mygreet("World")

## Create man page for mygreet().
prompt("mygreet")

## Create data and save it as R workspace. And create man page.
mybig <- "Supercalifragilisticexpialidocious"
save(mybig, file = "mybig.RData", compress = TRUE)
prompt("mybig")

################################################################
## Now go off an create package.
##   Folder needs following (See Writing R Extensions):
##     DESCRIPTION	standardized package description
##     R			folder with R code in *.R files
##     man			folder with man pages in *.Rd
##     data			(optional) folder for data
## 
## Now install package.
##   Some steps in Windows or Mac/OS.
##   Straightforward in Linux.
##   % R CMD INSTALL mypackage
## or
##   % R CMD INSTALL mypackage -library=mylibloc
##
## If creating on Linux for use on Windows, go to mylibloc
## and create a zip file. Not convention with version number.
##   % zip -r mypackage_0.5.1.zip mypackage
##
## To build a package to share source with others.
##   % R CMD build mypackage
##
################################################################
## Install local zip file.
utils:::menuInstallLocal()

library(mypackage)
mygreet
rm(mygreet)
mygreet

mygreet("World")
mygreet("Moon","Goodbye")
mygreet(mybig)

## Use a dataset in the library.
## You don't need the data() call if you use
## LazyData: yes
## in the DESCRIPTION file.
rm(mybig)
data(mybig) ## This destroys local copy if it still exists.
mygreet(mybig)
