{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter4 - Chapter 4 Chapter 4 4.1 R Export/Import Data...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 4 R - 1 - Chapter 4 Export/Import Data 4.1 Data Export a. The function cat is 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 print prints its argument. It is a generic function which means that new printing methods can be easily added for new classes. > print("Good morning!") [1] "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.table and 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)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon