33  Datasets

Datasets

R Syntax

# Choose a file interactively
file.choose() 

# Read CSV file
d <- read.csv(pathfile)

# Read text file.
# Set header = TRUE if the first row of the data
# corresponds to the names of the variables
d <- read.table(pathfile, header = TRUE)

# Vector with values 3, 6, 7
c(3, 6, 7)

# Value of data d in row 3 and column 7
d[3, 7]

# Row 3 of data d
d[3, ]

# Column 7 of data d
d[, 7]

# Rows 3 and 5 of data d
d[c(3, 5), ]

# Columns 7 and 9 of data d
d[ , c(7, 9)]

# Data d without rows 3 and 5
d[-c(3, 5), ]

# Data d without columns 7 and 9
d[ , -c(7, 9)]