2017-09-23 4 views
1

私はGEOMラインと私のグラフを作成するときに、私はここでは、このグラフに水分データにあまりに多くのデータポイント

enter image description here

を取得するには、私のコード

ggplot(Moisture_kurokawa, aes(x = Date))+ geom_line(aes(y = W5, colour = "W5"))+ geom_line(aes(y = W7, colour = "W7"))+ geom_line(aes(y = W9, colour = "W9"))+ geom_line(aes(y = W11, colour = "W11")) 

は、それが滑らか取得する方法上の任意のヘルプですすべてのデータポイントを表示しますか?

My data file link

答えて

2

あなたはそれがあなたのための作業の一部をやらせることができますので、あなたは、データの並べ替えのビットを行う場合は特に、いくつかのggplot2チュートリアルを読むためにいくつかの時間を取る必要があります。

また、適切な日付+時刻オブジェクトが必要です。より良い形で自分のデータで

library(tidyverse) 

Moisture_kurokawa <- read_csv("~/Data/Moisture kurokawa.csv") 

mutate(Moisture_kurokawa, 
     timestamp = lubridate::mdy_hms(sprintf("%s %s", Date, Time))) %>% 
    select(-Date, -Time) %>% 
    gather(W, value, -timestamp) -> moisture_long 

moisture_long 
## # A tibble: 17,645 x 3 
##    timestamp  W value 
##     <dttm> <chr> <dbl> 
## 1 2017-06-24 00:00:00 W5 0.333 
## 2 2017-06-24 00:30:00 W5 0.333 
## 3 2017-06-24 01:00:00 W5 0.334 
## 4 2017-06-24 01:30:00 W5 0.334 
## 5 2017-06-24 02:00:00 W5 0.334 
## 6 2017-06-24 02:30:00 W5 0.334 
## 7 2017-06-24 03:00:00 W5 0.335 
## 8 2017-06-24 03:30:00 W5 0.335 
## 9 2017-06-24 04:00:00 W5 0.335 
## 10 2017-06-24 04:30:00 W5 0.335 
## # ... with 17,635 more rows 

ggplot(moisture_long, aes(timestamp, value, group=W, color=W)) + 
    geom_line() 

enter image description here

、あなたも行うことができます。

ggplot(moisture_long, aes(timestamp, value, group=W, color=W)) + 
    geom_line() + 
    facet_wrap(~W) 

enter image description here

+0

はあなたに非常に多くの先生ありがとうございました。私はいくつかのチュートリアルを通過します –

1
Moisture_kurokawa <- read.table("Moisture kurokawa.csv", header=T, sep=",") 

# Create a datetime object with as.POSIXct 
Moisture_kurokawa$DateTime <- as.POSIXct(
    paste0(Moisture_kurokawa$Date, Moisture_kurokawa$Time), 
    format="%m/%d/%Y %H:%M") 

library(ggplot2)  
ggplot(Moisture_kurokawa, aes(x = DateTime))+ 
    geom_line(aes(y = W5, colour = "W5"))+ 
    geom_line(aes(y = W7, colour = "W7"))+ 
    geom_line(aes(y = W9, colour = "W9"))+ 
    geom_line(aes(y = W11, colour = "W11")) 

enter image description here

関連する問題