How to determine object type

47 Views Asked by At

Here is how my object displays:

> object
 [1] "string1"
 [2] "string2"                 
 [3] "string3"                  

What is that object type called? How do I change it to a vector like this (without manually typing the whole thing out):

> c("string1","string2","string3")
[1] "string1"    "string2"    "string3"

All the methods I tried just gave me back the same object.

> as.vector(object)
> unlist(object)

Edit: Thanks for your help. I think it was a vector to begin with.

1

There are 1 best solutions below

0
Alexander Sokolovsky On

It is unlikely to be a list of 3 elements which would typically appear like this in the console:

[[1]]
[1] "string1"

[[2]]
[1] "string2"

[[3]]
[1] "string3"

If you can, do str(object) or class(object) as recommended above to find out more. Once you see if there is an internal structure you may be able to do something like object$substructure to get at this. Could you let us know what str() gives you? It will help answer.