简体   繁体   English

如何在R Studio中将两个数据集合并为一个并用两个数据集绘制一个图形

[英]How to combine two data sets into one and plotting one graph with both data sets in R Studio

Currently I have combined the Apple stock market and the Samsung stock market from 2014- 2018. I have combined the Date,Open,High, low and Close using cbind and changed the names so it says Apple/ Samsung. 目前,我将2014年至2018年的苹果股票市场和三星股票市场合并。我使用cbind合并了日期,开盘价,最高价,最低价和收盘价,并更改了名称,因此称苹果/三星。

My problem is with the graph, Now my dataset is combined in columns so I feel like this might be part of the problem, but none the less I would prefer to keep it like that. 我的问题是关于图形的问题,现在我的数据集被合并到列中,因此我觉得这可能是问题的一部分,但是我仍然希望保持这种状态。 I would love a graph that would have both of the open figures on it over the years. 我希望有一个图表,这些图表在过去的几年中都有两个开放的数字。

If I just use plot(Total$OpenApple, Total$OpenSam) the plot is a huge block compared to the line graph I would like. 如果我只使用plot(Total $ OpenApple,Total $ OpenSam) ,则与我想要的折线图相比,该图是一个巨大的块。

Thanks. 谢谢。

Without any example data its difficult to understand your problem fully. 没有任何示例数据,很难完全理解您的问题。 However, I would try using the ggplot2 package and dplyr package. 但是,我会尝试使用ggplot2包和dplyr包。 Then you can change your data so that OpenApple and OpenSam are both part of the same column, and then use a function from ggplot2 to change the colors of your lines based on what group they are a part of. 然后,您可以更改数据,以便OpenApple和OpenSam都属于同一列,然后使用ggplot2的函数根据ggplot2的组更改行的颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在R中的两个数据集中的一张图上绘制两个简单的线性回归散点图和直线 - plotting two simple linear regression scatterplots and lines on one graph from two data sets in R 在R中再次绘制两组数据 - Plotting two sets of data againnst one another in r 将两个带有标签和值的 excel 数据集合并到一个带标签的 SPSS - Combine two excel data sets with labels and values to one labeled SPSS COVID19 数据-如何将两个数据集组合并绘制在一个图中? - COVID19 data-how do I combine two data sets and plot in one figure? 在R中的图形上绘制多组不同的数据点 - plotting multiple sets of different data points on a graph in R R - 组合两个数据集,不重复,并返回其比较的值进行一次比较,其余 NA 返回零 - R - Combine two data sets without duplicates and return the value its comparing for one comparison, and zero for remaining NA's 将数据分为两个训练和一个测试集 - Split data into two training and one test sets 在漏斗图上绘制两组数据点(metafor for R) - Plotting two sets of data points on funnel plot (metafor for R) R:如何读取固定宽度的数据文件,其中将数据分为两组,并堆叠在一个文件中 - R: How to read fixed width datafile where the data is concatenated into two sets, stacked on top in one file 如何使用两个数据集绘制一个热图 - how can I plot one heatmap using two data sets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM