Hi @sonjiiic,
Welcome to the RStudio Community Forum.
You need to set-up a vector to contain the balance at each month, and then save to that vector for each step inside the while loop. Then you can use the vector to plot the loan progress:
loan <- 1000
monthlyrate <- 0.11/12
repayment <- 12
month <- 0
target <- 0
balance <- vector()
while(loan > target){
month <- month + 1
interestpayment <- round(loan*monthlyrate,2)
loan <- loan - (repayment - interestpayment)
#print(loan)
balance[month] <- loan
}
plot(x=1:length(balance), y=balance, type="l",
xlab="Time in months",
ylab="Remaining balance ($)")

Created on 2021-11-27 by the reprex package (v2.0.1)