Home > Back-end >  How to plot 'log' and 'first difference of log' in R?
How to plot 'log' and 'first difference of log' in R?

Time:02-10

This might sound easy question to some people, but I am a beginner in R and I couldn't find an answer to my problem.

So, basically, I have uploaded my excel data into R. I have three variables. The first variable is in the format of the date (1994-01-03), the other two are just numbers.

enter image description here

Hope this is helpful!

CodePudding user response:

You can use the following code for plotting a graph of the "log" of two variables:
x = log(dataset$observation_date) y = log(dataset$interest_rate) plot(x, y, type = "l", xlab = "Observation date" , ylab = "Interest Rate")

You can use the following code for plotting a graph of the "first difference of log" of two variables:
x = diff(log(dataset$observation_date)) y = diff(log(dataset$interest_rate)) plot(x, y, type = "l", xlab = "Observation date" , ylab = "Interest Rate")

  •  Tags:  
  • r
  • Related