目录Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ问题:解决:
完整问题:
问题:
#两个向量长度不同
#define x and y variablesx <- c(2, 5, 5, 8)y <- c(22, 28, 32, 35, 40, 41)#attempt to create scatterplot of x vs. yplot(x, y) 解决:#数据长度对等,以x为基础
#define x and y variablesx <- c(2, 5, 5, 8)y <- c(22, 28, 32, 35, 40, 41)#create scatterplot of first 4 pairwise values of x vs. yplot(x, y[1:length(x)])#把x序列补齐;
#define x and y variables to have same lengthx <- c(2, 5, 5, 8, 9, 12)y <- c(22, 28, 32, 35, 40, 41)#confirm that x and y are the same lengthlength(x) == length(y)[1] TRUEcreate scatterplot of x vs. yplot(x, y)> #define x and y variables
> x <- c(2, 5, 5, 8)
> y <- c(22, 28, 32, 35, 40, 41)
>
> #attempt to create scatterplot of x vs. y
> plot(x, y)
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ