-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1486256
commit ef135a3
Showing
14 changed files
with
277 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
\name{NALevel} | ||
\alias{NALevel} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{Replace NAs in a Factor by a Given Level | ||
%% ~~function to do ... ~~ | ||
} | ||
\description{In order to replace the NAs in a factor an additional level has to be defined first. | ||
This function does this and replaces the NAs by the given level. | ||
%% ~~ A concise (1-5 lines) description of what the function does. ~~ | ||
} | ||
\usage{ | ||
NALevel(x, level) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{x}{a vector which will be turned into a factor. | ||
%% ~~Describe \code{x} here~~ | ||
} | ||
\item{level}{the name for the new level | ||
%% ~~Describe \code{level} here~~ | ||
} | ||
} | ||
\value{the vector x with the NAs replaced by level | ||
%% ~Describe the value returned | ||
%% If it is a LIST, use | ||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
\author{Andri Signorell <andri@signorell.net> | ||
%% ~~who you are~~ | ||
} | ||
\seealso{\code{\link{factor}}, \code{\link{levels}} | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
} | ||
\examples{ | ||
x <- c(LETTERS[1:5], NA) | ||
table(NALevel(x, "something else")) | ||
|
||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory (show via RShowDoc("KEYWORDS")): | ||
% \keyword{ ~kwd1 } | ||
% \keyword{ ~kwd2 } | ||
% Use only one keyword per line. | ||
% For non-standard keywords, use \concept instead of \keyword: | ||
% \concept{ ~cpt1 } | ||
% \concept{ ~cpt2 } | ||
% Use only one concept per line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
\name{as.ym} | ||
\alias{as.ym} | ||
\alias{as.Date.ym} | ||
\alias{AddMonths.ym} | ||
|
||
\title{A Class for Dealing with the Yearmonth Format | ||
} | ||
\description{ | ||
The representation of year and month information in YYYYYMM format as an integer is often handy and a useful and efficient data structure. Adding a number of months to such a date is not quite catchy, however, since the date structure is to be retained. For example, 201201 - 2 [months] is expected to result in 201111 instead of 201199. AddMonthsYM does this job. | ||
} | ||
\usage{ | ||
|
||
as.ym(x) | ||
\method{as.Date}{ym}(x, d = 1, ...) | ||
|
||
\method{AddMonths}{ym}(x, n, ...) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{x}{a vector of integers, representing the dates in the format YYYYMM, to which a number of months has to be added. YYYY must lie in the range of 1000-3000, MM in 1-12. | ||
} | ||
\item{d}{the day to be used for converting a yearmonth to a date. Default is 1. | ||
%% ~~Describe \code{n} here~~ | ||
} | ||
\item{n}{the number of months to be added. If n is negative the months will be subtracted. | ||
%% ~~Describe \code{n} here~~ | ||
} | ||
\item{\dots}{further arguments (not used here).} | ||
} | ||
\details{All parameters will be recyled if necessary. The therefore used function \code{\link{mapply}} will display a warning, if the longer argument is not a multiple of the length of the shorter one. | ||
} | ||
\value{a vector of class \code{integer} with the same dimension as x, containing the transformed dates. | ||
} | ||
\author{Andri Signorell <andri@signorell.net>, originally based on code by Roland Rapold | ||
} | ||
|
||
\seealso{\code{\link{AddMonths}}; Date functions, like \code{\link{Year}}, \code{\link{Month}}, etc. | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
} | ||
\examples{ | ||
|
||
Month(as.ym(202408)) | ||
Year(as.ym(202408)) | ||
|
||
Year(as.Date("2024-12-05")) | ||
Year(as.ym(202412)) | ||
|
||
Month(as.Date("2024-12-05"), fmt = "mm") | ||
Month(as.ym(202412), fmt="mm") | ||
|
||
AddMonths(201511, 5) | ||
|
||
AddMonths(c(201511, 201302), c(5, 15)) | ||
AddMonths(c(201511, 201302), c(5, -4)) | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ chron } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.