невозможно построить линейный график в R с помощью plot (), другие типы графиков будут работать - PullRequest
1 голос
/ 10 марта 2020

Я пытаюсь построить линейный график в R с помощью функции plot (), однако область печати остается пустой. Когда я пытаюсь построить график, это точка, столбец, гистограмма и т. Д. c график можно увидеть на панели графиков. Я также не смог добавить какую-либо информацию с помощью команды line (). Любые идеи?

Это не работает:

plot(GPSPlayerZ$GPSTime, GPSPlayerZ$SpeedDoppler, type = "l")
lines(GPSPlayerZ$GPSTime, GPSPlayerZ$SpeedDopplerSmooth, col = "blue")

Это делает:

plot(GPSPlayerZ$GPSTime, GPSPlayerZ$SpeedDoppler, type = "h")

Любая помощь будет высоко ценится!

Спасибо !

РЕДАКТИРОВАТЬ

structure(list(GPSTime = c(43498.69211, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 43498.69211, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
43498.69211, NA, NA, NA, NA, NA, NA, NA, NA, NA, 43498.69211, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 43498.69211, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 43498.69211, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 43498.69211, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
43498.69211, NA, NA, NA, NA, NA, NA, NA, NA, NA, 43498.69211, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 43498.69212, NA, NA, NA, 
NA, NA, NA, NA, NA, NA), Latitude = c(53.33522783, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 53.33522783, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 53.33522783, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
53.33522783, NA, NA, NA, NA, NA, NA, NA, NA, NA, 53.33522783, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 53.33522783, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 53.335228, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 53.33522817, NA, NA, NA, NA, NA, NA, NA, NA, NA, 53.33522833, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 53.3352285, NA, NA, NA, NA, 
NA, NA, NA, NA, NA), Longitude = c(-6.22882633, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, -6.228826, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, -6.22882583, NA, NA, NA, NA, NA, NA, NA, NA, NA, -6.22882567, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, -6.22882517, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, -6.228825, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, -6.22882483, NA, NA, NA, NA, NA, NA, NA, NA, NA, -6.22882467, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, -6.2288245, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, -6.2288245, NA, NA, NA, NA, NA, NA, NA, NA, 
NA), SpeedDoppler = c(0, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
0, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
0, NA, NA, NA, NA, NA, NA, NA, NA, NA), HeartRate = c(45, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 45, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 45, NA, NA, NA, NA, NA, NA, NA, NA, NA, 45, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 45, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
45, NA, NA, NA, NA, NA, NA, NA, NA, NA, 45, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 45, NA, NA, NA, NA, NA, NA, NA, NA, NA, 45, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 45, NA, NA, NA, NA, NA, NA, NA, 
NA, NA), LateralAccelerometry = c(0, -0.0125, -0.0125, -0.0125, 
-0.025, -0.025, -0.025, -0.0375, -0.0375, -0.025, -0.0125, 0, 
0, -0.0125, -0.025, -0.025, -0.0125, -0.0125, -0.0125, 0, 0, 
0, 0.0125, 0.0125, 0.025, 0.025, 0.025, 0.0375, 0.0375, 0.05, 
0.05, 0.0375, 0.0375, 0.0375, 0.0375, 0.025, 0.025, 0.025, 0.025, 
0.025, 0, 0, -0.0125, 0, 0, 0, -0.0125, -0.0125, -0.0125, -0.025, 
-0.05, -0.0625, -0.0625, -0.05, -0.05, -0.0375, -0.025, -0.025, 
-0.025, -0.025, -0.0625, -0.0875, -0.1125, -0.1375, -0.1375, 
-0.125, -0.125, -0.1125, -0.1125, -0.1125, -0.1, -0.0875, -0.075, 
-0.075, -0.1, -0.1125, -0.1125, -0.1125, -0.1125, -0.125, -0.1125, 
-0.1125, -0.1, -0.0875, -0.0875, -0.0875, -0.075, -0.075, -0.0625, 
-0.075, -0.0625, -0.0625, -0.075, -0.075, -0.0625, -0.0625, -0.05, 
-0.0375, -0.05, -0.0375), ForwardAccelerometry = c(0.5125, 0.5125, 
0.5125, 0.5125, 0.5125, 0.5125, 0.5125, 0.5125, 0.5125, 0.5125, 
0.525, 0.5125, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 
0.525, 0.5375, 0.5375, 0.55, 0.55, 0.55, 0.55, 0.5375, 0.5375, 
0.5375, 0.5375, 0.5125, 0.525, 0.525, 0.525, 0.525, 0.525, 0.525, 
0.525, 0.5375, 0.5375, 0.5375, 0.5375, 0.525, 0.5125, 0.5, 0.5, 
0.5, 0.5125, 0.5125, 0.5, 0.475, 0.475, 0.475, 0.475, 0.475, 
0.4875, 0.5125, 0.5375, 0.5375, 0.5375, 0.4875, 0.475, 0.5, 0.5125, 
0.5375, 0.55, 0.5625, 0.575, 0.5875, 0.575, 0.5625, 0.575, 0.5875, 
0.575, 0.575, 0.575, 0.5875, 0.6, 0.6, 0.575, 0.5625, 0.575, 
0.5625, 0.575, 0.5875, 0.5875, 0.6, 0.6, 0.6, 0.6125, 0.6375, 
0.6375, 0.625, 0.625, 0.625, 0.625, 0.625, 0.625, 0.625, 0.625
), UpAccelerometry = c(0.975, 0.9625, 0.9625, 0.975, 0.975, 0.9625, 
0.9625, 0.9625, 0.95, 0.9625, 0.9625, 0.975, 0.975, 0.975, 0.9625, 
0.9625, 0.9625, 0.9625, 0.95, 0.9625, 0.9625, 0.9625, 0.9625, 
0.9625, 0.9625, 0.9625, 0.9625, 0.9625, 0.9625, 0.9625, 0.95, 
0.95, 0.95, 0.95, 0.95, 0.95, 0.9375, 0.95, 0.95, 0.95, 0.9625, 
0.9625, 0.975, 0.975, 0.9875, 0.975, 0.9875, 0.9875, 1, 1, 0.9875, 
0.9875, 0.975, 0.975, 0.9875, 1, 1.0125, 1.0125, 1, 1, 0.975, 
0.975, 0.9875, 0.975, 0.9625, 0.95, 0.9625, 0.95, 0.95, 0.95, 
0.9125, 0.9125, 0.9, 0.9, 0.9125, 0.925, 0.925, 0.9375, 0.925, 
0.9125, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.8875, 0.8875, 0.8875, 
0.8875, 0.8875, 0.8875, 0.8875, 0.9, 0.9, 0.9125, 0.9125, 0.9125, 
0.925, 0.925), SpeedDopplerSmooth = c(NA, NA, NA, NA, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0), Accel = c(0, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, 
-100L), class = c("tbl_df", "tbl", "data.frame"))

1 Ответ

0 голосов
/ 10 марта 2020

Проблема в значениях NA в ваших данных. Каждый отрезок линии представляет собой только одну точку, потому что следующая точка - NA. Сегмент линии от заданной точки до NA не может быть нарисован.

Например,

df1 = data.frame(x=c(1,NA,2,NA,3), y=c(1,NA,2,NA,3))

plot(df1)

enter image description here

plot(df1, type='l')

enter image description here

Попробуйте сначала удалить значения NA

plot(df1[complete.cases(df1),], type='l')

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...