Hello dear world,
I am a bloody beginner and struggeling to write a code that changes dynamically and was hoping someone could help me.
SO basically I have an exel table with Prices and different properties of which each property should be correlated to the price.
Question no. 1: How do I programm in R so that I don't have to keep changing the changing input veriable (property 1, property 2,...)?
I have got as far as:
cor.create <- function (my_data) {
cor (my_data$x, my_data$y, method = "spearman")}
so in the coding I would like to be abble to change the "y" to different variables without typing? (I have a large amount of data for my master thesis)
Question no. 2: Before that I would like to do scatterplots. How can I make R change the title of the pdf its creating fit to the input data?
I have the following code:
function (my_data) {
ggplot(data = my_data, mapping = aes (x, y)) +
geom_point() +
labs (title = 'my_data', x = 'Preis (in Euro pro 100g)', y = 'Qualitätsurteil der Stiftung Warentest') +
ggsave("my_data.pdf", plot = last_plot()) }
so in the coding "my_data.pdf" I would like R to change this according to what I put in as "my_data"?
Question no. 3: If I have the data stored in different Variables, is it possible to get R to use my built functions with each of these?
Sorry to bother you. Any tips also as in where I can find help for these questions will be very much appreciated!
Lia