Plot in R for showing two columns in a data set on x axis using single line graph

r
datavisualization
ggplot2
datamanipulation

#1

I have a data set in excel. There are total 9 columns:
col1 - member_id
col2 - A_timespent_in_hrs
col3 - B_timespent_in_hrs
col4 - total_timespent_in_hrs (col2 + col3)
col5 - A_pv (not to be considered in the problem)
col6 - B_pv (not to be considered in the problem)
col7 - total_pv (col5 + col6)(not to be considered in the problem)
col8 - A_timespent_in_hrs % wrt to total_timespent_in_hrs
col9 - B__timespent_in_hrs % wrt to total_timespent_in_hrs

I need to plot a graph in R (line graph) where i need to show the col8 ( A_timespent_in_hrs %) and col9 ( B_timespent_in_hrs %) on x axis and the count of col1 ( member_id) on the y axis.

Any help will be appreciated!

Thanks in advance,

Neel


#2

Hello Neel,
Hope you are familiar with ggplot2.

Add geom_path() with proper parameters to your ggplot object.

Here is the doc file http://docs.ggplot2.org/current/geom_path.html. It contains some examples.

Vipin


#3

Hi Vipin,

Thanks for the reply!

I have used ggplot2 for the plot. I am having one issue in that, the col 8 is starting from the left end of the x axis and the col 9 should start from the right end of the x axis and the labeling is also a concern, like when col 8 starting at left end of the x axis the value is 0 and the line graph achieve the 100 at the end of the x axis. Conversely col 9 is starting from the right end of the x axis with 0 as the starting value and coming towards the left achieve 100 at the starting point of the col 8 starting point.

Kindly share your idea in this respect!

Thanks in advance.

Neel