Skip to content

Commit 4bd7d54

Browse files
committed
Initial commit after the meetup
0 parents  commit 4bd7d54

File tree

11 files changed

+147
-0
lines changed

11 files changed

+147
-0
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
^.*\.Rproj$
2+
^\.Rproj\.user$

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData

DESCRIPTION

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: xavamess
2+
Type: Package
3+
Title: Various useful functions
4+
Version: 0.1
5+
Date: 2015-02-05
6+
Author: Xavier Robin
7+
Maintainer: Xavier Robin <[email protected]>
8+
Description: This package contains one useful function
9+
License: GPL-3
10+
Imports: stringr

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by roxygen2 (4.1.0): do not edit by hand
2+
3+
export(elongate)
4+
importFrom(stringr,str_split)

R/elongate.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#' @title Elongates a pseudo-wide column
2+
#' @description Takes a pseudo-wide column and tranform it into a long format
3+
#' @param id a column that will not be splitted
4+
#' @param wide the column to split
5+
#' @param pattern the character or regex used to split up the wide column (see \link{str_split})
6+
#' @examples
7+
#' data(pseudo.wide)
8+
#' elongated.score <- elongate(pseudo.wide$Protein, pseudo.wide$Score)
9+
#' elongated.sequence <- elongate(pseudo.wide$Protein, pseudo.wide$Sequence)
10+
#' # The following works only if the Score and Sequence have the same pattern
11+
#' # (ie same number of splits per ID)
12+
#' elongated <- data.frame(Protein = elongated.score$id,
13+
#' Score = elongated.score$wide,
14+
#' Sequence = elongated.sequence$wide)
15+
#' \dontshow{
16+
#' stopifnot(identical(dim(elongated.score), dim(elongated.sequence)))
17+
#' }
18+
#' @importFrom stringr str_split
19+
#' @export
20+
elongate <- function(id, wide, pattern = ";") {
21+
splitted <- str_split(wide, pattern)
22+
long <- data.frame(id = rep.int(id, sapply(splitted, length)), wide = unlist(splitted))
23+
return(long)
24+
}
25+
26+
27+

R/pseudo.wide.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#' A dummy data set in pseudo-wide format
2+
#' @docType data
3+
#' @name pseudo.wide
4+
#' @description This data set list proteins with two pseudo-wide columns
5+
#' containing the identified sequence and associate score
6+
#' @format a \code{data.frame} with 3 columns.
7+
NULL

data/pseudo.wide.RData

332 Bytes
Binary file not shown.

man/elongate.Rd

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
% Generated by roxygen2 (4.1.0): do not edit by hand
2+
% Please edit documentation in R/elongate.R
3+
\name{elongate}
4+
\alias{elongate}
5+
\title{Elongates a pseudo-wide column}
6+
\usage{
7+
elongate(id, wide, pattern = ";")
8+
}
9+
\arguments{
10+
\item{id}{a column that will not be splitted}
11+
12+
\item{wide}{the column to split}
13+
14+
\item{pattern}{the character or regex used to split up the wide column (see \link{str_split})}
15+
}
16+
\description{
17+
Takes a pseudo-wide column and tranform it into a long format
18+
}
19+
\examples{
20+
data(pseudo.wide)
21+
elongated.score <- elongate(pseudo.wide$Protein, pseudo.wide$Score)
22+
elongated.sequence <- elongate(pseudo.wide$Protein, pseudo.wide$Sequence)
23+
# The following works only if the Score and Sequence have the same pattern
24+
# (ie same number of splits per ID)
25+
elongated <- data.frame(Protein = elongated.score$id,
26+
Score = elongated.score$wide,
27+
Sequence = elongated.sequence$wide)
28+
\dontshow{
29+
stopifnot(identical(dim(elongated.score), dim(elongated.sequence)))
30+
}
31+
}
32+

man/pseudo.wide.Rd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
% Generated by roxygen2 (4.1.0): do not edit by hand
2+
% Please edit documentation in R/pseudo.wide.R
3+
\docType{data}
4+
\name{pseudo.wide}
5+
\alias{pseudo.wide}
6+
\title{A dummy data set in pseudo-wide format}
7+
\format{a \code{data.frame} with 3 columns.}
8+
\description{
9+
This data set list proteins with two pseudo-wide columns
10+
containing the identified sequence and associate score
11+
}
12+

man/xavamess-package.Rd

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
\name{xavamess-package}
2+
\alias{xavamess-package}
3+
\alias{xavamess}
4+
\docType{package}
5+
\title{
6+
Various useful functions
7+
}
8+
\description{
9+
This package contains one useful function
10+
}
11+
\details{
12+
\tabular{ll}{
13+
Package: \tab xavamess\cr
14+
Type: \tab Package\cr
15+
Version: \tab 0.1\cr
16+
Date: \tab 2015-02-05\cr
17+
License: \tab GPL-3\cr
18+
}
19+
}
20+
\author{
21+
Xavier Robin
22+
23+
Maintainer: Xavier Robin <xavier.robin@bric.ku.dk>
24+
}
25+
%\references{
26+
%~~ Literature or other references for background information ~~
27+
%}
28+
\keyword{ package }
29+
%\seealso{
30+
%~~ Optional links to other man pages, e.g. ~~
31+
%~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
32+
%}

0 commit comments

Comments
 (0)