Lia, welcome to R programming. It looks like you're new to programming, so welcome to the journey!
I'll try to answer some bits of what you asked.
Q1) this depends on how your data is structured. Does your data have each input variable as a different column in the data frame like df_wide below or is does it have a variable that contains the name of the variable, like df_long below?
library(tidyverse)
n <- 5
df_wide <- data.frame(
d1 = rnorm(n),
d2 = rnorm(n),
d3 = rnorm(n),
d4 = rnorm(n)
)
df_wide
#> d1 d2 d3 d4
#> 1 -0.30013188 -1.15724871 -0.6842435 -1.69573506
#> 2 0.07135999 0.37691683 -0.5642811 -1.14831895
#> 3 0.07540957 -0.05911097 1.0084456 1.31179016
#> 4 1.04405814 -0.72960569 0.7876833 -0.89300680
#> 5 -0.27028056 -1.02603006 -1.4922447 -0.05271003
df_long <- gather(df_wide, key="variable", value="value")
df_long
#> variable value
#> 1 d1 -0.30013188
#> 2 d1 0.07135999
#> 3 d1 0.07540957
#> 4 d1 1.04405814
#> 5 d1 -0.27028056
#> 6 d2 -1.15724871
#> 7 d2 0.37691683
#> 8 d2 -0.05911097
#> 9 d2 -0.72960569
#> 10 d2 -1.02603006
#> 11 d3 -0.68424352
#> 12 d3 -0.56428113
#> 13 d3 1.00844559
#> 14 d3 0.78768332
#> 15 d3 -1.49224469
#> 16 d4 -1.69573506
#> 17 d4 -1.14831895
#> 18 d4 1.31179016
#> 19 d4 -0.89300680
#> 20 d4 -0.05271003
if your data looks like df_wide you can just call cor on the data frame:
cor(df_wide, method="spearman")
#> d1 d2 d3 d4
#> d1 1.0 0.5 -0.4 0.1
#> d2 0.5 1.0 -0.6 0.4
#> d3 -0.4 -0.6 1.0 0.3
#> d4 0.1 0.4 0.3 1.0
The result is a matrix object.
Q2) set the name in a text variable then use paste(my_filename, ".pdf") to change the file name. But you may want to do many pairwise plots on one graph. One easy way to do this is with the GGally package:
library(GGally)
ggpairs(df_wide)

Q3) yes, R is a programming language so you can make it do almost anything that you can describe. You'd be really well served to spend a couple of days reading R for Data Science: https://r4ds.had.co.nz
R4DS will help you get oriented as to what is possible and how to structure your analysis.
Created on 2019-01-10 by the reprex package (v0.2.1)