Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 为什么纵向数据的y轴被包装在xyplot中?_R_Lattice - Fatal编程技术网

R 为什么纵向数据的y轴被包装在xyplot中?

R 为什么纵向数据的y轴被包装在xyplot中?,r,lattice,R,Lattice,我正在做一个关于功能数据分析的项目,我正在尝试绘制高度的意大利面图。我正在使用晶格库中的xyplot。为什么y轴被包裹在xyplot中 这里我只绘制了一个人的数据。如果绘制整个数据集,它看起来像一块粗线 我在R中的代码是: xyplot(height ~ age|sex, p_data, type="l", group=id) 导致: 如果看不到p\u数据很难说,但根据轴标签,我猜高度被视为一个因子变量 运行is.factor(p_data$height),如果答案为TRUE,则重试 p_数据

我正在做一个关于功能数据分析的项目,我正在尝试绘制高度的意大利面图。我正在使用晶格库中的xyplot。为什么y轴被包裹在xyplot中

这里我只绘制了一个人的数据。如果绘制整个数据集,它看起来像一块粗线

我在R中的代码是:

xyplot(height ~ age|sex, p_data, type="l", group=id)
导致:


如果看不到
p\u数据
很难说,但根据轴标签,我猜
高度
被视为一个因子变量

运行
is.factor(p_data$height)
,如果答案为
TRUE
,则重试


p_数据$height看不到
p_数据
很难说,但根据轴标签,我猜
height
被视为一个因子变量

运行
is.factor(p_data$height)
,如果答案为
TRUE
,则重试


p_data$height@乔让你走上了正确的道路。几乎可以肯定的是,
高度
变量被视为一个因子(分类变量),而不是一个连续的数字变量:

例如,我可以通过以下方式复制类似的问题:

p_data <- data.frame(height=c(96,72,100,45),age=1:4,sex=c("m","f","f","m"),id=1)
p_data$height <- factor(p_data$height,levels=p_data$height)

# it's all out of order cap'n!
p_data$height
#[1] 96  72  100 45 
#Levels: 96 72 100 45

# same plot call as you are using    
xyplot(height ~ age|sex, p_data, type="l", group=id)

@乔让你走上了正确的道路。几乎可以肯定的是,
高度
变量被视为一个因子(分类变量),而不是一个连续的数字变量:

例如,我可以通过以下方式复制类似的问题:

p_data <- data.frame(height=c(96,72,100,45),age=1:4,sex=c("m","f","f","m"),id=1)
p_data$height <- factor(p_data$height,levels=p_data$height)

# it's all out of order cap'n!
p_data$height
#[1] 96  72  100 45 
#Levels: 96 72 100 45

# same plot call as you are using    
xyplot(height ~ age|sex, p_data, type="l", group=id)

事实上,这是一个问题,也是一个因素。谢谢你,乔!事实上,这是一个问题,也是一个因素。谢谢你,乔!谢谢身高是一个因素。谢谢!身高是一个因素。
xyplot(height ~ age|sex, p_data, type="l", group=id)