titanic <- read.csv("Titanic-Dataset.csv")

data_selected <- titanic[, c("Age", "SibSp", "Parch", "Fare")]

data_clean <- na.omit(data_selected)

summary(data_clean)
##       Age            SibSp            Parch             Fare       
##  Min.   : 0.42   Min.   :0.0000   Min.   :0.0000   Min.   :  0.00  
##  1st Qu.:20.12   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:  8.05  
##  Median :28.00   Median :0.0000   Median :0.0000   Median : 15.74  
##  Mean   :29.70   Mean   :0.5126   Mean   :0.4314   Mean   : 34.69  
##  3rd Qu.:38.00   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.: 33.38  
##  Max.   :80.00   Max.   :5.0000   Max.   :6.0000   Max.   :512.33
cor_matrix <- cor(data_clean)
cor_matrix
##               Age      SibSp      Parch       Fare
## Age    1.00000000 -0.3082468 -0.1891193 0.09606669
## SibSp -0.30824676  1.0000000  0.3838199 0.13832879
## Parch -0.18911926  0.3838199  1.0000000 0.20511888
## Fare   0.09606669  0.1383288  0.2051189 1.00000000
cov_matrix <- cov(data_clean)
cov_matrix
##              Age      SibSp      Parch        Fare
## Age   211.019125 -4.1633339 -2.3441911   73.849030
## SibSp  -4.163334  0.8644973  0.3045128    6.806212
## Parch  -2.344191  0.3045128  0.7281027    9.262176
## Fare   73.849030  6.8062117  9.2621760 2800.413100
eigen_result <- eigen(cov_matrix)
eigen_result$values
## [1] 2802.5636587  209.0385659    0.9438783    0.4787214
eigen_result$vectors
##             [,1]        [,2]         [,3]          [,4]
## [1,] 0.028477552  0.99929943 -0.024018111  0.0035788596
## [2,] 0.002386349 -0.02093144 -0.773693322  0.6332099362
## [3,] 0.003280818 -0.01253786 -0.633088089 -0.7739712590
## [4,] 0.999586200 -0.02837826  0.004609234  0.0009266652

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.