[英]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.