Reputation: 7131
I was trying to add double quotes to a name in R and it did not work out for me.
I have a variable called X, which looks like this
> X
[1] BD Rbo5s SMA. 01m bo.
[6] Lv w8s it 2s ds
[11] J.t r.Dt 2i. J_D 32i.
[16] V tpMin3_Bh.s. T1m R8m o8m
[21] m wM12_AEA.dm. A3i R8m 28s
I have a big matrix (file1) and I was trying to find the columns that has the colnames as in "X" and save them in (file2).
Now I am using this command, and it is not working
file2 = file1[,X]
I thought adding a double quotation would solve this problem (would it?), but i failed typing in the command for this. Help needed! :)
Thanks,
Upvotes: 0
Views: 85
Reputation: 8313
X should be a vector of characters.
R> X = c("BD","Rbo5s", "SMA.", "01m")
R> X
[1] "BD" "Rbo5s" "SMA." "01m"
When you display your X it has the format:
> X
[1] BD Rbo5s SMA. 01m bo.
-- with no quotes, meaning that this isn't a character vector. Fix that and the indexing should work.
Upvotes: 2