views:

74

answers:

1

I'm new to R.

I have a a Data.frame with a column called "Symbol".

   Symbol
1   "IDEA"
2   "PFC"
3   "RPL"
4   "SOBHA"

I need to store its values as a vector(x = c("IDEA","PFC","RPL","SOBHA")). Which is the most concise way of doing this?

Thanks in Advance

+2  A: 
your.data <- data.frame(Symbol = c("IDEA","PFC","RPL","SOBHA"))
new.variable <- as.vector(your.data$Symbol) # this will create a character vector

VitoshKa suggested to use the following code.

new.variable.v <- your.data$Symbol # this will retain the factor nature of the vector

What you want depends on what you need. If you are using this vector for further analysis or plotting, retaining the factor nature of the vector is a sensible solution.

How these two methods differ:

cat(new.variable.v)
#1 2 3 4

cat(new.variable)
#IDEA PFC RPL SOBHA
Roman Luštrik
Worked like a charm. Thanks again!
st0le
no need for conversion there, your.data$Symbol will work.
VitoshKa
Thanks VitoshKa for the suggestion.
Roman Luštrik