Re: [R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread David Winsemius
> On Oct 7, 2016, at 10:44 AM, Jorge Cimentada wrote: > > Hi Bert, > > Yes, I'm aware of the difference between a and "a" but in terms of object > classes I don't see the difference between "a" and names(mtcars)[1]. > They're both strings. They are not both "strings". One is a character value

Re: [R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread Duncan Murdoch
On 07/10/2016 1:44 PM, Jorge Cimentada wrote: Hi Bert, Yes, I'm aware of the difference between a and "a" but in terms of object classes I don't see the difference between "a" and names(mtcars)[1]. They're both strings. However, for creating a named character vector, this works: c("a" = "b) Bu

Re: [R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread Jorge Cimentada
Hi Bert, Yes, I'm aware of the difference between a and "a" but in terms of object classes I don't see the difference between "a" and names(mtcars)[1]. They're both strings. However, for creating a named character vector, this works: c("a" = "b) But this doesn't c(names(mtcars)[1] = "b") For e

Re: [R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread Bert Gunter
I think you have R semantics confused. What do you think c("a" = "b") means? Note that: > c("a" = "b") a "b" > a Error: object 'a' not found And of course: class("a") # character class("b") # character but this has *nothing* to do with the line immediately above it. Have you gone through

Re: [R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread Jorge Cimentada
I'm sorry, there was a typo. The result is still the same: c("a" = "b") # named character vector class("a") # character class("b") # character c(names(mtcars)[1] = names(mtcars)[2]) # error class(names(mtcars)[1]) # character class(names(mtcars)[2]) # character Thanks, Jorge Cimentada [

[R] Error creating named character vectors from column names in data frame.

2016-10-07 Thread Jorge Cimentada
Hi everyone, I was hoping someone would explain why this doesn't work. c("a" = "b") # named character vector class("a") # character class("b") # character c(names(mtcars)[1] = names(mtcars[2]) # error class(names(mtcars)[1]) # character class(names(mtcars)[2]) # character Thanks, Jorge Cimenta