Split clustered data and interpolate by a power function

148 views Asked by At

Here is my question: I have a data frame that looks like this (I have used Mclust and some complementary functions to extract the cluster of origin of each couple [KN, DTM]):

KN            DTM           CLUST
-20.272190218 -31.0272310     1
-18.933174425 -29.6409366     1
-17.956946728 -28.5448150     1
-17.645953576 -31.0272310     2
-17.150920199 -27.3383515     1

In general I have only 2 clusters. I want to regroup all the data belonging to each cluster to a separate data frame in order to calculate the best interpolating function for each cluster. The best interpolating function should be of the type ''power''.

I have used split in order to separate data following the cluster of origin but I do not know how to proceed from here. If I understand well the split function create 2 vectors containing the data separated. How can I store this data in a file? Is it possible to apply immediately an interpolating function to the data obtained from split?

1

There are 1 answers

1
Morris Greenberg On

The split function returns a list of vectors. So, if you store the results of the split function, and then access each element of the list you produced, that is how you can access each result:

splitData <- split(data, f=data$CLUST) cluster1 <- splitData[[1]] cluster2 <- splitData[[2]]