I have a list like this:
anteilSelbststaendige <- ((100/input$bevoelkerung) * input$selbststaendige) anteilSelbststaendige [1] 5.460547 5.551961 5.561330 5.474761 5.460763 5.455431 5.467829 5.409999 5.356277 5.159937 4.990305 4.915012 4.882196 [14] 4.860807 4.855824 4.826342 4.768927 4.719400 4.660732 4.615460 4.527033 4.486686 4.455891 4.908780 4.964310 4.973149 [27] 5.011707 5.050273 5.016059 5.000409 4.976963 5.014764 5.064687 5.122957 5.163057 5.284785 5.368078 5.566300 5.816041 [40] 6.028620 6.257261 6.434038 6.676781 7.157343
and I want to know the difference between the value and the following value. (For all values of the list) Like this:
anteilSelbststaendigeV <- anteilSelbststaendige[2] - anteilSelbststaendige[1]
The result should be a list of the differences of the next following values.
I tried "for" loops, but it doesn't work and I don't know why. I'm new to R and don't really know what functions there are and what to do.
https://stackoverflow.com/questions/65875859/how-to-substract-list-elements-of-the-same-list-in-r January 25, 2021 at 04:54AM
没有评论:
发表评论