create a dataframe with column names in r

# Step 1: Create column names
column_names <- c("ID", "Name", "Age", "City", "Salary")

# Step 2: Create an empty dataframe with specified column names
my_dataframe <- data.frame(matrix(ncol = length(column_names), nrow = 0))
colnames(my_dataframe) <- column_names

# Step 3: Add data to the dataframe
my_dataframe <- rbind(my_dataframe, c(1, "John", 25, "New York", 50000))
my_dataframe <- rbind(my_dataframe, c(2, "Alice", 30, "Los Angeles", 60000))
my_dataframe <- rbind(my_dataframe, c(3, "Bob", 22, "Chicago", 45000))

# Step 4: Print the resulting dataframe
print(my_dataframe)