Chapter 4 R- 1 -Chapter 4 Export/Import Data 4.1 Data Export a.The function catis useful for producing output in user-defined functions. > cat("Good morning!","\n") #\n: newline Good morning! > cat(file="K:\\6360\\Rdata\\test.txt", "123456", "987654", sep="\n") Note that "K:\\" in the file path is not a mistake. b.The function printprints its argument. It is a generic function which means that new printing methods can be easily added for new classes. > print("Good morning!")  "Good morning!" c.The commonest task is to write a matrix or data frame to file as a rectangular grid of numbers, possibly with row and column labels. This can be done by the functions write.tableand write. i.Command to copy and paste from R into Excel or other programs. It writes the data of an R data frame object into the clipboard from where it can be pasted into other applications. > age=18:29 > height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1, 81.2,81.8,82.8,83.5) > village=data.frame(age=age,height=height)
This preview has intentionally blurred sections.
Sign up to view the full version.