maak een dataframe met jaar van 2015 tot 2023 in r

You can create a dataframe with years from 2015 to 2023 using the seq() function to generate a sequence of years and the data.frame() function to create a dataframe. Here's the code:

main.r
# Create a sequence of years
years <- seq(2015, 2023)

# Create a dataframe with years as a column
df <- data.frame(year = years)

# Print the dataframe
df
156 chars
9 lines

Output:

main.r
   year
1  2015
2  2016
3  2017
4  2018
5  2019
6  2020
7  2021
8  2022
9  2023
80 chars
11 lines

In this code, we first create a sequence of years using seq() function, which generates a sequence of numbers from the start value 2015 to the end value 2023. We then use the data.frame() function to create a dataframe with the years vector as a column. Finally, we print the dataframe to see its contents.

related categories

gistlibby LogSnag