calculating the log ratio of two variables from a dataset with 10 variables and conversion of the values into data

Hi,
I would like to ask for some help on how to calculate the log ratio of two variables log(Rb/Sr). The dataset I am using is comprised of 10 chemical elements as you will see below, so 10 columns. I think there are two ways you can do this, but I would like to cross check that in order to see if I am doing this right. The code is as follows:

setwd("C:/Users/30693/Desktop/Μεταπτυχιακό 2019-2021/Διπλωματική 2019-2021/Διπλωματική 2019-2021 Λουσοί/XRF Datasets")
library(readxl)
Tri = read_excel("C:/Users/30693/Desktop/Μεταπτυχιακό 2019-2021/Διπλωματική 2019-2021/Διπλωματική 2019-2021 Λουσοί/XRF Datasets/TRI1_all.xlsx")
Tri1=Tri[,c("Al","Si","K","Ca","Ti","Mn","Fe", "Rb","Sr","Zr")]
logarithm1=log(Tri1$Rb)-log(Tri1$Sr)

OR LIKE THIS
setwd("C:/Users/30693/Desktop/Μεταπτυχιακό 2019-2021/Διπλωματική 2019-2021/Διπλωματική 2019-2021 Λουσοί/XRF Datasets")
library(readxl)
Tri = read_excel("C:/Users/30693/Desktop/Μεταπτυχιακό 2019-2021/Διπλωματική 2019-2021/Διπλωματική 2019-2021 Λουσοί/XRF Datasets/TRI1_all.xlsx")
Tri1=Tri[,c("Al","Si","K","Ca","Ti","Mn","Fe", "Rb","Sr","Zr")]
Di=log(Tri1[c("Rb","Sr")])
Di2= Di$Rb-Di$Sr

Now both of these ways seem to give me the same result. Are these two ways right and is there a better way to do this? Also one more thing is there a way to convert Di2 and logarithm1 from values into data and make them part of the original Tri dataset? Thanks in advance.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.