0
votes

i'm quite new to R and don't quite understand how to fix this problem.

plot(masterfilea$Lake, masterfilea$Average)
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

my data is a large set of 299 observations, of which i've shown the first few.
Hope this makes sense!

Name    Date    Month   Lake                Location    Average  
V1A1303 13-Mar  March   Vlietland           V1          2.66666667  
V2A1303 13-Mar  March   Vlietland           V2          0.143333333  
V3A1303 13-Mar  March   Vlietland           V3          1.036666667  
V4A1303 13-Mar  March   Vlietland           V4          1.133333333  
V5A1303 13-Mar  March   Vlietland           V5          1.4  
V1B1303 13-Mar  March   Vlietland           V1          2  
V2B1303 13-Mar  March   Vlietland           V2          0.723333333  
V3B1303 13-Mar  March   Vlietland           V3          0.94  
V4B1303 13-Mar  March   Vlietland           V4          6.1  
V5B1303 13-Mar  March   Vlietland           V5          1.803333333  
Z1A1403 14-Mar  March   Zoetermeerse Plas   Z1          2.433333333  
Z2A1403 14-Mar  March   Zoetermeerse Plas   Z2          0.933333333  
Z3A1403 14-Mar  March   Zoetermeerse Plas   Z3          0.966666667  
Z4A1403 14-Mar  March   Zoetermeerse Plas   Z4          1.533333333  
Z5A1403 14-Mar  March   Zoetermeerse Plas   Z5          0.61  
Z1B1403 14-Mar  March   Zoetermeerse Plas   Z1          1  
Z2B1403 14-Mar  March   Zoetermeerse Plas   Z2          0.53  
Z3B1403 14-Mar  March   Zoetermeerse Plas   Z3          0.53333333  
Z4B1403 14-Mar  March   Zoetermeerse Plas   Z4          1.5  
Z5B1403 14-Mar  March   Zoetermeerse Plas   Z5          1.04  
J1A1503 15-Mar  March   T'Joppe             J1          3.233333333  
J2A1503 15-Mar  March   T'Joppe             J2          0.433333333  
2
Please provide your sample data.Aleksandr
just added it to the original post, hope i'm doing it right!Elise Baas
Maybe you're looking for a dotplot: lattice::dotplot(Average ~ Lake, data = masterfilea)bouncyball
yeah that gets me something I can use, but at some point i need to have a line graph with lake vs average, or the month vs average etc. Thank you though!Elise Baas
The basic problem in your case is that Lake is not a numeric value. Not sure I understand why a line graph would be useful for character valuesbouncyball

2 Answers

1
votes

Since you're trying to plot a numeric variable against a character variable, I would suggest the dotplot from the lattice package:

lattice::dotplot(Average ~ Lake, data = dat)

enter image description here

Of course, we could also use ggplot2:

library(ggplot2)
theme_set(theme_bw())
ggplot(dat, aes(x = Lake, y = Average))+
    geom_point()

enter image description here

Data

dat <- structure(list(Name = c("V1A1303", "V2A1303", "V3A1303", "V4A1303", 
"V5A1303", "V1B1303", "V2B1303", "V3B1303", "V4B1303", "V5B1303", 
"Z1A1403", "Z2A1403", "Z3A1403", "Z4A1403", "Z5A1403", "Z1B1403", 
"Z2B1403", "Z3B1403", "Z4B1403", "Z5B1403", "J1A1503", "J2A1503"
), Date = c("13-Mar", "13-Mar", "13-Mar", "13-Mar", "13-Mar", 
"13-Mar", "13-Mar", "13-Mar", "13-Mar", "13-Mar", "14-Mar", "14-Mar", 
"14-Mar", "14-Mar", "14-Mar", "14-Mar", "14-Mar", "14-Mar", "14-Mar", 
"14-Mar", "15-Mar", "15-Mar"), Month = c("March", "March", "March", 
"March", "March", "March", "March", "March", "March", "March", 
"March", "March", "March", "March", "March", "March", "March", 
"March", "March", "March", "March", "March"), Lake = c("Vlietland", 
"Vlietland", "Vlietland", "Vlietland", "Vlietland", "Vlietland", 
"Vlietland", "Vlietland", "Vlietland", "Vlietland", "ZoetermeersePlas", 
"ZoetermeersePlas", "ZoetermeersePlas", "ZoetermeersePlas", "ZoetermeersePlas", 
"ZoetermeersePlas", "ZoetermeersePlas", "ZoetermeersePlas", "ZoetermeersePlas", 
"ZoetermeersePlas", "TJoppe", "TJoppe"), Location = c("V1", "V2", 
"V3", "V4", "V5", "V1", "V2", "V3", "V4", "V5", "Z1", "Z2", "Z3", 
"Z4", "Z5", "Z1", "Z2", "Z3", "Z4", "Z5", "J1", "J2"), Average = c(2.66666667, 
0.143333333, 1.036666667, 1.133333333, 1.4, 2, 0.723333333, 0.94, 
6.1, 1.803333333, 2.433333333, 0.933333333, 0.966666667, 1.533333333, 
0.61, 1, 0.53, 0.53333333, 1.5, 1.04, 3.233333333, 0.433333333
)), .Names = c("Name", "Date", "Month", "Lake", "Location", "Average"
), class = "data.frame", row.names = c(NA, -22L))
0
votes

I can suggest you to do it, this way (a boxplot in this case will be drawn)

plot(Average~Lake, 'name of your data frame')