Clustering longitudinal data can be done in very different ways. In answering, I assume that you have a panel with a relatively long time series dimension. If this is the case, it depends on how many variables you observe: if you can choose just one, it is possible to cluster the cross-sectional units using time series clustering methods. You can find a very nice explanation of commonly used approaches by looking at the "TSclust" package in R. However, if you have many variables the task becomes more complicated. There is a huge literature on clustering panel data (you can also make simple research by looking at clustering approaches for multivariate time trajectories). However, as far I know there is not an R package for this task so you should program a k-means like clustering procedure by yourself.