2017-09-23 1 views
1

Wenn ich meine Grafik mit geom Linie erstellen erhalte ich diese GrafikZu viele Datenpunkte auf Feuchtigkeitsdaten

enter image description here

Hier mein Code

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")) 

Jede Hilfe, wie es zu bekommen ist zu glätten oder sehen Sie alle Datenpunkte?

My data file link.

Antwort

2

Sie einige Zeit durch einige ggplot2 Tutorials lesen nehmen sollte, so dass Sie kann es für Sie einen Teil der Arbeit tun lassen, vor allem, wenn Sie ein wenig Daten Neuanordnung tun.

Sie müssen auch ein richtiges Datum + Zeit Objekt für die Auflösung, die Sie wollen.

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

Mit Ihrer Daten in einer besseren Form, können Sie auch tun:

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

enter image description here

+0

Sie sehr viel Sir Dank. Ich werde einige Tutorials durchgehen –

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