# geom_path: each group consists of only one observation. do you need to adjust the group aesthetic?

88 views
geom_path: each group consists of only one observation. do you need to adjust the group aesthetic?

retagged

I have stored some weather data in csv file for average temperature per month for previous four years.

The data is as following:

\$ cat /tmp/climatetemperature.csv

"month","aveTem"

"January",2.111111111111111

"February",3.111111111111111

"March",8.111111111111111

"April",12.323

"May",11.111111111111111

"June",14.111111111111111

"July",13.111111111111111

"August",12.111111111111111

"September",16.111111111111111

"October",11.111111111111111

"November",5.111111111111111

"December",4.111111111111111

My simple intention is to create line chart, to show months in ascending order for entire year with respected temerature.

So i wrote following code:

df\$month = factor(df\$month, month.name)

ggplot(aes(x = month, y = aveTem), data = df) +

geom_line( ) +

ggtitle("Monthly Temp in ascending order")

This spitted out the error:

geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?

## Solution:

The best way to solve thisis to  make it numeric:

ggplot(aes(x = as.numeric(month), y = aveTemp), data = df) +

geom_line( ) +

ggtitle("Monthly Temp in ascending order")

Will give you following chart:

it'd be a lot more pleasant in the event that we could have the month names along the base.

It turns out we can yet we have to determine a gathering that each point has a place with. ggplot will at that point associates directs which have a place toward a similar gathering.

ggplot(aes(x = month, y = aveTem, group=1), data = df) +

geom_line( ) +

ggtitle("Temperature by month")

### Conclusion:

So finally we got our desired chart.

by (1.6k points)
edited by