'Timeseries Train and Test Set Selection

I have a 2 column df and time series with 400 observations. I am trying to select the first 300 observations for the training set and the last 100 observations for the test set but am not getting the correct output. I know it's something with start/end commands. Can someone help? My code below:

z <- read.csv("MData.csv")
y <- z[-c(1)]
head(y)
ts.plot(y)
ts()
training.data = ts(y, end = ?, frequency = 1)
training.data

The Data is stored in this format:

1  0013-06-16 01:00:00  1024
2  0013-06-16 02:00:00  555
3  0013-06-16 03:00:00  340 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source