Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8246cad

Browse files
committed
suppressed not needed messages and added message form to custom messages from my function. Then removed print to avoid printing numeric into console which was not needed
1 parenta085cce commit8246cad

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

‎R/vms_clean.R‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ vms_clean <- function(path_to_data) {
4949
"speed",
5050
"direction"
5151
)
52-
52+
empty_coordinates<-x|>
53+
dplyr::filter(is.na(.data$latitude))|>
54+
dplyr::filter(is.na(.data$longitude))
5355
res<-x|>
5456
dplyr::mutate(date= as.POSIXct(date,format="%d/%m/%Y %H:%M",tz="UTC"))|>
5557
dplyr::mutate(year=lubridate::year(date))|>
@@ -64,11 +66,9 @@ vms_clean <- function(path_to_data) {
6466
dplyr::filter(!is.na(.data$speed))|>
6567
dplyr::mutate(file_name=stringr::str_remove(path_to_data,"data/VMS-data/raw//"))
6668

67-
empty_coordinates<-x|>
68-
dplyr::filter(is.na(.data$latitude))|>
69-
dplyr::filter(is.na(.data$longitude))
70-
message(paste0("Cleaned:", print(nrow(empty_coordinates))," empty rows from data!\n"))
71-
res
69+
70+
message(paste0("Cleaned:", (nrow(empty_coordinates))," empty rows from data!\n"))
71+
7272
}elseif (is.data.frame(path_to_data)==TRUE) {
7373
x<-path_to_data
7474

@@ -83,6 +83,13 @@ vms_clean <- function(path_to_data) {
8383
"speed",
8484
"direction"
8585
)
86+
empty_coordinates<-x|>
87+
dplyr::mutate(
88+
latitude= as.numeric(.data$latitude),
89+
longitude= as.numeric(.data$longitude)
90+
)|>
91+
dplyr::filter(is.na(.data$latitude))|>
92+
dplyr::filter(is.na(.data$longitude))
8693

8794
res<-x|>
8895
dplyr::mutate(date= as.POSIXct(date,format="%d/%m/%Y %H:%M",tz="UTC"))|>
@@ -100,15 +107,9 @@ vms_clean <- function(path_to_data) {
100107
dplyr::mutate(direction= as.numeric(.data$direction))|>
101108
dplyr::mutate(speed= as.numeric(.data$speed))
102109

103-
empty_coordinates<-x|>
104-
dplyr::mutate(
105-
latitude= as.numeric(.data$latitude),
106-
longitude= as.numeric(.data$longitude)
107-
)|>
108-
dplyr::filter(is.na(.data$latitude))|>
109-
dplyr::filter(is.na(.data$longitude))
110-
message(paste0("Cleaned:", print(nrow(empty_coordinates))," empty rows from data!\n"))
111-
res
110+
message(paste0("Cleaned:", (nrow(empty_coordinates))," empty rows from data!\n"))
111+
112+
112113
}else {
113114
stop("Data must be a path to folder or data.frame object\n")
114115
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp