1 year ago

#389198

test-img

DRisse

Times series in R : how to change y-axis?

New R user here, working with meteorological data (data frame is called "Stations"). Trying to plot 3 time series with temperature on y-axis with a regression line on each one, but I encounter a few problems and there is no error messages.

  1. Loop doesn't seem to be working and I can't figure out why.
  2. Didn't manage to change x-axis graduation values for years ("Année" in the data frame) instead of a number.
  3. Title is the same for the 3 plots, how do I change it so each plot has its own title?
  4. Regression line is not shown on the graph.

Thanks in advance!

Here is my code :

for (i in c(6,8,10))
  plot(ts(Stations[,i]), col="dodgerblue4", xlab="Temps", ylab="Température", main="Genève")
for (i in c(6,8,10))
  abline(h=Stations[,i])```


Nb.enr   time   Année  Mois Jour T2m_GE pcp_GE T2m_PU pcp_PU T2m_NY
1      19810101  1981    1    1    1.3    0.3    2.8    0.0    2.3
2      19810102  1981    1    2    1.2    0.1    2.3    1.2    1.6
3      19810103  1981    1    3    4.1   21.8    4.9    5.2    3.8
4      19810104  1981    1    4    5.1   10.3    5.1   17.4    4.9
5      19810105  1981    1    5    0.9    0.0    1.0    0.1    0.8
6      19810106  1981    1    6    0.5    5.7    0.7    6.0    0.5
7      19810107  1981    1    7   -2.7    0.0   -2.1    0.1   -1.9
8      19810108  1981    1    8   -3.2    0.0   -4.1    0.0   -3.8
9      19810109  1981    1    9   -5.2    0.0   -3.5    0.0   -5.1
10     19810110  1981    1   10   -3.1   10.6   -0.9    6.0   -2.6

r

loops

time-series

0 Answers

Your Answer

Accepted video resources