我正在从之前创建的dataFrame中读取数据。我必须从数据框中选择一些矢量来完成此任务。但是,当我重新缩放数据框对象时,它变成了“双精度”(而不是原来的“列表”)。
我可以成功地对数据进行聚类,但是无法绘制它。
但是我无法在简单的2D图中绘制它,因为出现以下错误:
错误:data
必须是数据帧或fortify()
可强制执行的其他对象,而不是列表
我也尝试使用as.list将ilpd_df2转换为从“ double”转换为“ list”,但它仍未打印。
#Task 2.1 - Load Preprocessed Data and Subset Data as directed
ilpd_df <- readRDS(file="ilpd_preprocessed.Rda")
ilpd_df1 <-
select(ilpd_df,"TB","DB","Alkphos","Sgpt","Sgot","TP","Albumin")
#Task 2.2 - Re-Scaling
ilpd_df2 <- apply(ilpd_df1, MARGIN = 2, FUN=function(X)
(X - min(X))/diff(range(X)))
#Task 2.3 - Cluster the Data into 2 Clusters
set.seed(44)
ilpd_clusters <- kmeans(ilpd_df2, 2, nstart = 25, iter.max=5)
ggplot(ilpd_df2, aes(Alkphos, TP)) + geom_point()
Error: `data` must be a data frame, or other object coercible by `fortify()`, not a list