According to a journal I've read, in determining the K in fourier series term the lowest AIC must be picked, but what AIC are they talking about? How would we determine K? BTW, we are using r.
They refer to the Aikaike information criterion. Roughly, it is a measure that can be used for comparing candidate models and choose the one that is more likely to have generated the data. The better the quality of the fit (the higher the likelihood of the model), the more are the chances that the model is close to the true model. This measure includes a penalty term that prevents overfitting; see for example this post for more comments about overfitting. The function
R returns the AIC value for several types of models.
As regards $K$, they most likely refer to the number of Fourier terms (sine-cosine waves) to be included in the model. Basically, these terms consist of sine waves of different amplitudes and frequencies that allow the model to capture cycles of certain periodicites that may be present in the dynamic of the data. For further details you may search for information about harmonic regression; some examples in
R: here and here.
Typically, the procedure is to propose and fit different models containing different cycles or regressor variables; then choose the one with the lowest AIC as the most plausible model given the data.