I don't know if the method of loading csv files has to do with the issues that I'm encountering, but it's my only lead. The thing is that I have been successfully using a great package by @Max Conway (here), but today I got stuck generating some exploratory plots as illustrated below:
install.packages('gsheet')
library(gsheet)
data <- gsheet2tbl(("https://docs.google.com/spreadsheets/d/1TagYu-g8C1EA-RBNtWewgDUeG0Uq-lfPKn1EHebeNmE/edit?usp=sharing"))
head(data)
Source: local data frame [6 x 3]
yield nitrogen phosphorus
1 0.8274156 no no
2 3.6126275 no no
3 2.6192581 no no
4 1.7412190 no no
5 0.6590589 no no
6 0.4891107 no no
attach(data)
plot(nitrogen,yield)
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
So I ran a str to see how the data had been imported:
str(data)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 40 obs. of 3 variables:
$ yield : num 0.827 3.613 2.619 1.741 0.659 ...
$ nitrogen : chr "no" "no" "no" "no" ...
$ phosphorus: chr "no" "no" "no" "no" ...
OK... Didn't look like a data.frame, but I figured that had an easy fix:
data <- data.frame(data)
> str(data)
'data.frame': 40 obs. of 3 variables:
$ yield : num 0.827 3.613 2.619 1.741 0.659 ...
$ nitrogen : chr "no" "no" "no" "no" ...
$ phosphorus: chr "no" "no" "no" "no" ..
At this point (and after visually examining the df), it seemed like the problem had to be fixed. As a precaution, I didn't attach the data:
plot(data$nitrogen,data$yield)
plot(data$nitrogen,data$yield)
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
Same problem...
What is R trying to say? What am I doing wrong?