Arman Akbarian
UNIVERSITY OF BRITISH COLUMBIA
PHYSICS & ASTRONOMY DEPT.

#------------------------------------
# AAK:  Sat  8 Aug 2014 23:31:17 PDT
# Simple I/O in R
#-------------------------------------

#Reading tabular data into R:
data <- read.table("mydata.txt")

# read.csv is also avaialable for commo seperated version 

data2 <- read.csv("mydata.csv")

x <- data.frame(a = 3.2 , b = 7.1)

# dput creates a R code that reconstructs the data
# See the file x.R that it creates:
dput(x,file="x.R")

# the file can be read to create the data:
y <- dget("x.R")

print(y)

#dump is similar to dput put can take multiple objects:
x <- 2.3
y <- factor( c("apple","apple","banana"))
dump( c("x","y") , file="Y.R")

rm(x,y)

# See the file Y.R that it creates
source("Y.R")

print(x)
print(y)


last update: Wed Aug 19, 2015