I have the following R code which creates 5 objects dynamically with names such as cluster1_dataset, ...., cluster5_dataset as follows:
# Extract cluster data
for (i in 1:K) {
assign(paste("cluster",i,"_dataset",sep=""), subset(clustered_input_dataset, cluster == i))
}
How do i access these 5 dynamically created objects in R?
I have tried the following:
# Plot histograms & boxplots for each cluster to look at shift_length_avg frequency distribution
par(mfrow=c(K,2))
for (i in 1:K) {
# Analyze cluster#1
hist(dataset$shift_length_avg)
}
which gives me the following error:
Error in dataset$shift_length_avg :
$ operator is invalid for atomic vectors