Tips and Tricks
# "Using bulltes"
# " use * and +"
# * One
# * Two
# * Three
# + 1
# + 2
# + 3
# type
# what type of plot should be drawn. Possible types are
# "p" for points,
# "l" for lines,
# "b" for both,
# "c" for the lines part alone of "b",
# "o" for both ‘overplotted’,
# "h" for ‘histogram’ like (or ‘high-density’) vertical lines,
# "s" for stair steps,
# "S" for other steps, see ‘Details’ below,
# "n" for no plotting.
General
# na.omit() function deletes any row with missing data
# fix() will give you an pop up windodws for you to change your variables or data
# use as.date() to transform dates.
# as.Date(x, "input_format")
# use the order function to sort your data!!! very useful.
# For Example
# attach(leadership)
# newdata <-leadership[order(gender, -age),]
# detach(leadership)
# this sorts the rows by gender, and then from oldest to youngest manager within each gender.
# format(x, format="output_format")
# The format() function takes an argument (a date in this case) and applies an output format
# To merge two data frames (datasets) horizontally, you use the merge() function. In most cases, two data frames are joined by one or more common key variables (that is, an inner join).
# total <- merge(dataframeA, dataframeB, by="ID")
# If you’re joining two matrices or data frames horizontally and don’t need to specify a common key, you can use the cbind() function:
# total <- cbind(A, B)
# To join two data frames (datasets) vertically, use the rbind() function:
# total <- rbind(dataframeA, dataframeB)
#The two data frames must have the same variables, but they don’t have to be in the same order. If dataframeA has variables that dataframeB doesn’t, then before joining them, do one of the following:
# Delete the extra variables in dataframeA.
# Create the additional variables in dataframeB # and set them to NA (missing).
Insert a picture
# But you must use this code outside of the R chunks
# 