What is the difference between [ ] and [[ ]] in R? -


  > levels(state.region)[2]     [1] "s"     > levels(state.region)[[2]]     [1] "s" 

they return same value, don't know difference between them.

[] = returns object of same class (out of basic object classes), can select more 1 element of object

[[]] = can extract 1 element list or data frame, returned object (out of basic object classes) not list/dataframe


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -