For loops in R can lose class information

Win-Vector Blog 2016-03-25

Summary:

Did you know R‘s for() loop control structure drops class annotations from vectors? Consider the following code R code demonstrating three uses of a for-loop that one would expect to behave very similarly. dates <- c(as.Date('2015-01-01'),as.Date('2015-01-02')) for(ii in seq_along(dates)) { di <- dates[ii] print(di) } ## [1] "2015-01-01" ## [1] "2015-01-02" for(di in as.list(dates)) { … Continue reading For loops in R can lose class information

Link:

http://www.win-vector.com/blog/2016/03/for-loops-in-r-can-lose-class-information/

From feeds:

Statistics and Visualization » Win-Vector Blog

Tags:

r

Authors:

John Mount

Date tagged:

03/25/2016, 02:32

Date published:

03/24/2016, 23:55