Creating data tables

The following makes use of the data.table package. You may need to install it from CRAN using the code install.packages("data.table") if you want to run this on your computer. (The package is already installed on the notebook container, however.)

library(data.table)
UK <- data.table(
           Population = c(55619400,1885400,5424800,3125000),
           Area = c(50301,5460,30090,8023),
           GVA = c(28096,20000,24800,19900),
           country = c("England",
                         "Northern Ireland",
                         "Scotland",
                         "Wales"))
UK
  Population Area  GVA   country         
1 55619400   50301 28096 England         
2  1885400    5460 20000 Northern Ireland
3  5424800   30090 24800 Scotland        
4  3125000    8023 19900 Wales           
class(UK)
[1] "data.table" "data.frame"
DT <- data.table(
    x = rnorm(1000000),
    y = rnorm(1000000))
DT
        x           y          
1       -0.15279818 -0.47783172
2       -1.70539944 -0.22764698
3       -0.83157336  0.54272547
4        1.22603817  0.38108578
5        0.30521037  0.31583837
6        1.13718083  0.69197497
7        0.51842513 -1.40680405
8       -0.71917822  1.02680513
9        0.39633064 -1.36946391
10       0.02244016  1.35067205
11      -1.41041245  1.43463172
12       0.15424717  1.30960037
13      -0.64834247  2.79065757
14      -0.49553384 -2.05155283
15      -0.14673379  0.50991242
16      -0.75601675  0.15452828
17       0.47866941 -0.08568474
18      -1.45425531 -2.20447058
19       0.73526244 -0.72707865
20      -0.56519050 -1.85391521
21       1.51541619  0.82828098
22       0.69653522 -0.16544687
23       0.10405480 -0.94939379
24      -0.18835395 -2.62117304
25       0.05922234  0.23836024
26       0.55200631  1.03270843
27       0.47921075  0.32368910
28      -1.87895045  0.33458745
29      -0.52417448 -0.02576781
30       1.10593164 -0.53994036
⋮       ⋮           ⋮          
999971   1.03720964  0.25952205
999972   1.85559105 -0.64376335
999973   0.30896363  0.90888194
999974  -0.19120411 -0.13836427
999975   0.38456941 -0.41448315
999976   0.19796241  0.18025090
999977  -0.59655868 -1.08715656
999978   1.52224757 -0.39968983
999979   0.97208779 -0.99119966
999980  -0.60255442  0.45956398
999981  -1.10311491 -0.30234050
999982  -1.82785989 -0.04869525
999983   2.02033730 -1.58348097
999984  -0.31190704 -0.34873065
999985   1.78569431  2.14918477
999986  -0.29153104  0.93791961
999987   0.10206375  0.28002396
999988   0.77630696  0.02731268
999989   0.36156982 -0.52059235
999990  -0.36892781 -0.43718632
999991   1.08813807 -0.66400660
999992  -0.03645137 -0.12748503
999993   1.16919951 -0.08199737
999994  -1.17768845 -0.85591426
999995   1.74096286 -1.70328723
999996  -0.41303043 -0.02196034
999997  -0.20724831 -0.98494480
999998  -0.20431187 -0.10192041
999999  -0.33621017 -0.76541307
1000000  1.07567218 -0.24330753
load("bes2010feelings.RData")
setDT(bes2010feelings)
class(bes2010feelings)
[1] "data.table" "data.frame"