Projekt in Textmining

Good evening,
i have a dataset in which i have daily stock prices of three companies since 2010.
I have to calculate the daily returns of each one of them in this form:

return = [ stock price (t) - sock price (t-1) ] / [ stock price (t-1) ]

and store them each in a new column -> Retrun A, Return B, Return C.

I dont know how to use the dataset and calculate it. It is important, please help me

PLEASE HELP ME. I HAVE NO IDEA. I have never done R before

Welcome to the forum and R in general. It seems that you have some reading to do - would be a good start :slight_smile:

Pay special attention to dplyr::lag() function, such as in this example:


frm <- data.frame(price = c(10, 20, 30, 40, 50))

frm <- frm %>% 
  mutate(return = (price - lag(price, 1)) / lag(price, 1))


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