Skip to content
Prev 205100 / 398506 Next

need more help.... Re: iterating over a data frame the R way?

Reinstall R but this time choose the Mac version that includes tcl.
You shouldn't have to separately install it.
On Fri, Jan 1, 2010 at 11:20 AM, <donahchoo at me.com> wrote:
For sqldf, unlike other platforms where all versions of R include tcl,
on the Mac there are versions of R with and without tcl so you need to
reinstall R using a version that includes it.

However, in this case since you are dealing specifically with
open/high/low/close series, the xts package already has specific
facilities:

library(xts)
library(chron)

# assume object in attachment to original post is called d.
# Convert it to xts object and set columns to OHLC names it understands.
x <- xts(d[1:4], as.chron(paste(d$day, d$start_time)))
colnames(x) <- c("High", "Open", "Low", "Close")

xday <- to.daily(x)
head(xday)