0

Possible Duplicate:
R: How to convert string to variable name?

If I do:

'a' = c(1:10)        
a
[1]  1  2  3  4  5  6  7  8  9 10

here I assign a vector to a string (variable) but i need to a do something like:

a = 'c10'

and then

a = c(1:10)

but the last a must to be c10

How can i do it?

2

1 Answer 1

1

Not sure what you're looking for but your first assignment doesn't need the c() and doesn't need quotes around the a.

a <- 1:10

if you want the last entry to be the string 'c10', you can get there a few different ways.

a <- c(1:9,'c10')

or

a <- 1:10
a[10] <- 'c10'

Or if Ben Bolker is on the right track:

a <- 'c10'
assign(a,1:10)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.