# r - Why does list() return a vector, and not a list?

Possible Duplicate:

why the object is vector?

``> x=function(z){z+1}> y=list(n1=1,n2="qwe",n3=TRUE,n4=x)> is.vector(y)[1] TRUE``

Why is `y` a vector? `n1` is numeric, `n2` is character, `n3` is logical, `n4` is a function.

They are different, so why is `y` a vector? Surely `y` can only be a list?

``> dataname sex age height1 x1 F 18 1622 x2 M 19 1703 x3 M 21 1784 x4 F 22 1665 x5 F 23 165> data[1,]name sex age height1 x1 F 18 162> is.vector(data[1,])[1] FALSE``

i am confused by vector ,why here data[1,] can not be a vectort?

You are using `list` which create a generic vector. Lists can contain different kind of objects, and are themselves vectors.

Thus `is.vector` gives the right answer. See here for further information.

Moreover if you type `fix(y)` you will see the structure:

``````structure(
list(
n1 = 1,
n2 = "qwe",
n3 = TRUE,
n4 = function(z){z+1}
),
.Names = c("n1", "n2", "n3", "n4")
)
``````

`y` is a list:

``````> is.list(y)
[1] TRUE
``````

You're confused because lists are vectors, which is described in the second paragraph of the Details section of `?is.vector`. The same sentence says `is.vector` will also return `TRUE` for expressions:

``````> is.vector(as.expression(y))
[1] TRUE
``````