For the future, as @Ronak Shan said in the comment, create a minimum reproducible example (MRE) and post your failed attempts to help the community to help you !!!. I don't know if I've understood your question, but for subsetting data frame in r there are lots of methods. In base r the most straightforward methods are:
set.seed(55)#for reproducibility
#simulate the data.frame you posted
df <-
data.frame(
id = 1:10,
survived = sample(c(0, 1), 10, replace = T),
pclass = sample(c(1:3), 10, replace = T),
sex = sample(c("M", "F"), 10, replace = T),
age=round(runif(10,10,15)),
sibsp = sample(c(1:3), 10, replace = T),
parch=sample(c(0:2), 10, replace = T)
)
#subset
new.df <- subset(df,survived==1&sex=="F"&pclass==2&age==10)
#same thing
new.df2 <-df[df$survived==1&df$sex=="F"&df$pclass==2&df$age==10,]
As you can see create a new data frame is a very simple solution, then you can run a correlation analysis on the data you are interested in. From your question, it doesn't show exactly what you want to do, but a simple correlation can be computed as:
cor(new.df)
but this will throw an error because correlation can be computed only for numeric vector, matrix, or data frame.
new.df.for.cor <- new.df[,-4]#drop out the "sex" column
cor(new.df.for.cor)
For a better explanation, you have to edit the question to add more information on your data and the output you would like to get.