## 11.1 Size & dimensions & creation of data

• Data comes in different formes
• Often in dataframe/matrix/table form
• A table/dataframe/matrix has the dimensions m (rows) by n (columns)
• Q: What are the data size measures? GB, MB, Byte etc.?
• Let’s create datasets of different sizes → easy to create a big one…
library(randomNames)
n.rows <- 100000
data <- data.frame(id = 1:n.rows,
first.name = randomNames(1:n.rows, which.names="first"),
last.name = randomNames(1:n.rows, which.names="last"),
age = sample(15:90, n.rows, replace = T),
income = sample(500:3000, n.rows, replace = T)
)
write_csv(data, "./www/data_artificial_100000.csv") # 2.7 MB
# How many rows (m) and columns (n) does that dataset have?

n.rows <- 1000000
data <- data.frame(id = 1:n.rows,
first.name = randomNames(1:n.rows, which.names="first"),
last.name = randomNames(1:n.rows, which.names="last"),
age = sample(15:90, n.rows, replace = T),
income = sample(500:3000, n.rows, replace = T)
)
write_csv(data, "./www/data_artificial_1000000.csv") # 28 MB
# How many rows (m) and columns (n) does that dataset have?

n.rows <- 10000000
data <- data.frame(id = 1:n.rows,
first.name = randomNames(1:n.rows, which.names="first"),
last.name = randomNames(1:n.rows, which.names="last"),
age = sample(15:90, n.rows, replace = T),
income = sample(500:3000, n.rows, replace = T)
)
write_csv(data, "./www/data_artificial_10000000.csv") # 294 MB

# You wanna get stuck?
# n.rows <- 100000000
# data <- data.frame(id = 1:n.rows,
#                    first.name = randomNames(1:n.rows, which.names="first"),
#                    last.name = randomNames(1:n.rows, which.names="last"),
#                    age = sample(15:90, n.rows, replace = T),
#                    income = sample(500:3000, n.rows, replace = T)
#                    )
# write_csv(data, "./www/data_artificial_10000000.csv") # 2.97 GB