cc | R Documentation |
Copy a table to the clipboard for transferring to excel.
cc(data, destination = NA, includeRowNames = FALSE, nestedOrderOutToIn = TRUE, forceNested = FALSE)
data |
A table or data frame to copy to the clipboard. |
destination |
(optional) output file, in case the data is to be written to a file rather than the clipboard. |
includeRowNames |
(optional) parameter to save the row names. Generally row names don't contain useful information, so by default they are dropped. But if required they can be kept by setting this value to TRUE. |
nestedOrderOutToIn |
(optional) parameter to determine the order of levels for a nested table. By default it is ordered first by te outer variable, then the next outer most variable, etc. This is reveresed if set to FALSE. |
forceNested |
(optional) if input is not a nested table, then can still attempt to use the second last column to reshape into a wide format table. |
A quick and simple way to transfer data to excel. A table or data frame can copied directly to the clipboard, so you can just switch to Excel and hit paste (or ctrl+v).
cc2 is indentical, but exists for compatibility with older versions of DectechR package.
See also write.table
and writeClipboard
.
See cc_varlist
for getting a character vector in a nice format for use in a script.
# Using the built in data frame, mtcars:
# make a frequency table of number of gears
gearsTable <- with(mtcars, table(gear))
# Copy the table to clipboard...
cc2(gearsTable)
# ...Now go to Excel and paste!
# Two variable cross tab...
gearsVsCylindersTab <- with(mtcars, table(gear,cyl))
cc(gearsVsCylindersTab)
# Three variable cross tab...
threeWayTable <- with(mtcars, table(gear,cyl,carb))
cc(threeWayTable)
# Forcing a data.frame to be "nested"...
# ...the following is a data.frame, so won't be automatically nested
averageMpg <- with(mtcars, aggregate(mpg,list("cyl" = cyl,"gear" = gear),mean))
# ...but compare the output of:
cc(averageMpg)
# ...to this:
cc(averageMpg, forceNested = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.