我对多元数据很感兴趣。我使用pairs
来获取数据的成对图。我将模型拟合到数据,为了检查模型与数据的拟合度,我根据拟合模型进行了模拟。然后,我想将数据的真实图与拟合模型的模拟数据结合在一对图中。我试过这个:
pairs(mydata)
point(simdata)
但是,这并没有给我我想要的。 这是我的数据的成对图。
我想要与此类似但具有配对图。
最佳答案
假设您想坚持使用基本 R 的对
,您可以尝试以下操作:
pairs(iris, col = iris$Species)
如果您有两个不同的数据集,则想法是相同的。唯一的区别是我们需要创建一个两个数据集共享的变量,以便我们在使用 col = df$some_variable
时可以区分它们:
# Two different datasets
observed <- iris[1:75,]
simulated <- iris[76:150,]
# Adding 'observed' and 'simulated' values to a 'type' column
observed$type <- "observed"
simulated$type <- "simulated"
# Binding the observed and simulated dataset
df <- rbind(observed, simulated)
# Convert to factor
df$type <- as.factor(df$type)
# Plot
pairs(df, col = df$type)
关于r - 如何将观察到的和模拟的对图合并到一个图中以实现良好拟合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47737972/