Chi squared in R I am trying to do a chi squared test in R but I ma not sure it is being done correctly.  I am using the Titanic dataset from Tidyverse and seeing if there was an effect of age on survival rate.  Counts of a survivors by class (crew, 1st, 2nd and 3rd), age (child or adult) and gender (male or female) are listed.
library(plyr)
library(dplyr)
library(Tidyverse)
ship=data.frame(Titanic) #making df

kids=ship %>% filter(Age == "Child") #function from dplyr, makes new dataframe using rows which match criteria listed
dead_kids=kids %>% filter(Survived == "No")
dead_kids=sum(dead_kids$Freq)
living_kids=kids %>% filter(Survived == "Yes")
living_kids=sum(living_kids$Freq)

grown_ups=ship %>% filter(Age == "Adult")
dead_grown_ups=grown_ups %>% filter(Survived == "No")
dead_grown_ups=sum(dead_grown_ups$Freq)
living_grown_ups=grown_ups %>% filter(Survived == "Yes")
living_grown_ups=sum(living_grown_ups$Freq)


Survival_by_age <- matrix(c(living_grown_ups,living_kids,dead_grown_ups,dead_kids),ncol=2,byrow=TRUE)
colnames(Survival_by_age) = c('Adults', 'Children')
rownames(Survival_by_age) = c('Lived', 'Died')

if I run chisq.test() I get...
> chisq.test(Survival_by_age)

    Pearson's Chi-squared test with Yates' continuity correction

data:  Survival_by_age
X-squared = 20.005, df = 1, p-value = 7.725e-06

But I am not sure if this is correct.  if you print the values in the table you will see...
> Survival_by_age
      Adults Children
Lived    654       57
Died    1438       52

And I do not think there is much of an effect there, certainly not with such a high significance score.
> chisq.test(Survival_by_age$Child, Survival_by_age$Adult)
Error in Survival_by_age$Child : $ operator is invalid for atomic vectors

So am I correctly interpretting the first test?  And do I need to run this differently?  Why am I getting that error when I run the chisq.test on the child and adult columns?
 A: I agree with @whuber that results are clear without
a formal test. However, it you are interested in
checking the validity of your testing procedure in R, some
results from R may be helpful.
Data:
liv = c(654, 57); die = c(1438, 52)
tot = liv + die
prop = liv/tot
prop
[1] 0.3126195 0.5229358

Test of binomial proportions.
You can do a test to see if the two binomial proportions of about 31% survival for adults
and about 52% for children are statistically
significant in view of sample sizes. In particular, you could
do a prop.test in R, which shows a very highly
significant difference with a P-value near $0.$
(The continuity correction is used on account of the
small numbers of children)
prop.test(liv, tot)

        2-sample test for equality of proportions 
        with continuity correction

data:  liv out of tot
X-squared = 20.005, df = 1, p-value = 7.725e-06
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.3109899 -0.1096426
sample estimates:
   prop 1    prop 2 
0.3126195 0.5229358

The P-value is not meaningfully different, without
the continuity correction--still very near $0:$
prop.test(liv, tot, cor=F)$p.val
[1] 4.700752e-06

Chi-squared test on 2-by-2 table.
Alternatively, you could do a chi-squared test on
a $2 \times 2$ table with a Yates correction. There is still a very high level of statistical significance with P-value near $0.$
TBL = rbind(liv,die); TBL
    [,1] [,2]
liv  654   57
die 1438   52
chisq.test(TBL)

         Pearson's Chi-squared test 
         with Yates' continuity correction

 data:  TBL
 X-squared = 20.005, df = 1, p-value = 7.725e-06

Without Yates' correction, the P-value is as follows:
chisq.test(TBL, cor=F)$p.val
[1] 4.700752e-06

In this example, P-values (with or without correction)
for prop.test and chisq.test are in exact
agreement. Children survived at a significantly higher rate than adults.
Note: Because I don't have access to your data frame and how you are using it, I can't say why the
$-notation is causing an Error message. Strictly speaking, debugging R code is off-topic on this site, but maybe another user will see an obvious answer and comment.
