[Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Sandip Nandi
Hi , I want to know is this behavior expected and why is that ? Need some help gender <- c("F", "M", "M", "F", "F", "M", "F", "F") > age<- c(23, 25, 27, 29, 31, 33, 35, 37) > df<- data.frame(gender,age) > typeof(df[[1]]) [1] "integer" > Why is this integer . *Should not it be

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Joshua Ulrich
On Apr 1, 2014 7:48 PM, "Sandip Nandi" wrote: > > Hi , > > I want to know is this behavior expected and why is that ? Need some help > > gender <- c("F", "M", "M", "F", "F", "M", "F", "F") > > age<- c(23, 25, 27, 29, 31, 33, 35, 37) > > df<- data.frame(gender,age) > > typeof(df[[1]]) > [1] "i

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Sandip Nandi
Hi Jeff , I dont think so , > df[[0]] Error in .subset2(x, i, exact = exact) : attempt to select less than one element > > > df[[1]] [1] F M M F F M F F Levels: F M > df[[2]] [1] 23 25 27 29 31 33 35 37 Thanks On Tue, Apr 1, 2014 at 5:51 PM, Jeff Johnson wrote: > Perhaps because indexes st

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Sandip Nandi
Hi , I am concerned about the return value of typeof in character column in a dataframe. I expect it to be of character ,it returns integer instead . Thanks On Tue, Apr 1, 2014 at 5:56 PM, Joshua Ulrich wrote: > > On Apr 1, 2014 7:48 PM, "Sandip Nandi" wrote: > > > > Hi , > > > > I want to

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Joshua Ulrich
On Apr 1, 2014 8:04 PM, "Sandip Nandi" wrote: > > Hi , > > I am concerned about the return value of typeof in character column in a dataframe. I expect it to be of character ,it returns integer instead . > Of course typeof returns integer; typeof returns the internal storage type of an object. Fac

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Sandip Nandi
Sorry for the wrong interpretation. So how to avoid that ? I mean how to forcefully make it character vector ? This one , the character vector vector column is showing integer. May be I am missing any point. df X1.3 name 11 abc 22 def 33 xyz > typeof(df[[2]]) [1] "integer" > > >

Re: [Rd] Typeof for character vector in dataframe returns integer

2014-04-01 Thread Gregor Kastner
Hi Sandip, > Sorry for the wrong interpretation. So how to avoid that ? I mean how to > forcefully make it character vector ? As indicated by Joshua, ?data.frame will show you the way: df <- data.frame(gender, age, stringsAsFactors = FALSE) Best, /g ___

[Rd] special handling of row.names

2014-04-01 Thread Romain François
Hello, I think there is an inconsistency in the handling of the compact form of the row.names attributes. When n is the number of rows of a data.frame, the compact form is c(NA_integer_,-n), as in: > d <- data.frame(x=1:10) > .Internal(inspect(d)) @104f174a8 19 VECSXP g0c1 [OBJ,NAM(2),ATT]