Skip to content

Commit

Permalink
Added R documentation for as.Date
Browse files Browse the repository at this point in the history
  • Loading branch information
bghill committed Sep 3, 2014
1 parent bd77615 commit 7517187
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions R/h2o-package/man/H2OParsedData-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
\alias{apply,H2OParsedData-method}
\alias{as.data.frame,H2OParsedData-method}
\alias{as.factor,H2OParsedData-method}
\alias{as.Date,H2OParsedData-method}
\alias{ceiling,H2OParsedData-method}
\alias{colMeans,H2OParsedData-method}
\alias{colnames,H2OParsedData-method}
Expand Down
30 changes: 30 additions & 0 deletions R/h2o-package/man/as.Date.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
\name{as.Date}
\alias{as.Date}
\title{Converts a column from factor to date}
\description{

}
\usage{as.Date(x, format = "")}

\arguments{
\item{x}{A factor column in an object of class \code{\linkS4class{H2OParsedData}}, or data frame to be converted.}
\item{format}{A character string.}
}
\details{
Supports all parse tokens specified for \code{\link{strptime}}, except \code{\%u, \%U, \%w, \%W, and \%0Sn}.
Format also supports local variables that evaluate to a string.
}
\value{
Returns a column of dates stored as the number of milliseconds since the start of January 1, 1970. Negative numbers represent the number of seconds before this time, and positive numbers represent the number of seconds afterwards. \code{NA} values are preserved.
}
\note{
Note that resulting values are in milliseconds and not the seconds stored by the \code{"\link{POSIXct}"} class.
}
\examples{
library(h2o)
localH2O = h2o.init(ip = "localhost", port = 54321, startH2O = TRUE)
df = data.frame(c("Fri Jan 10 00:00:00 1969 -0800", "Tue Jan 10 04:00:00 2068 -0800", "Mon Dec 30 01:00:00 2002 -0800", "Wed Jan 1 12:00:00 2003 -0800"))
hdf = as.h2o(localH2O, df, "hdf", TRUE)
hdf[,1] = as.Date(hdf[,1], "%c %z")
hdf[,1]
}
6 changes: 3 additions & 3 deletions src/main/java/water/fvec/ParseTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private static void parseToBuilder(DateTimeFormatterBuilder builder, String patt
break;
case 'g':
case 'G':
break; //accepted and ignored
break; //for output only, accepted and ignored for input
case 'H':
builder.appendHourOfDay(2);
break;
Expand All @@ -342,11 +342,11 @@ private static void parseToBuilder(DateTimeFormatterBuilder builder, String patt
case 'j':
builder.appendDayOfYear(3);
break;
case 'k': //Joda automatically handles preceding blanks
case 'k':
builder.appendOptional(DateTimeFormat.forPattern("' '").getParser());
builder.appendHourOfDay(2);
break;
case 'l': //Joda automatically handles preceding blanks
case 'l':
builder.appendOptional(DateTimeFormat.forPattern("' '").getParser());
builder.appendClockhourOfHalfday(2);
break;
Expand Down

0 comments on commit 7517187

Please sign in to comment.