Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
datautils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bioinfo
datautils
Commits
2ab5a283
Commit
2ab5a283
authored
Mar 04, 2015
by
Holger Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed concat
parent
2fbf46c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
R/core_commons.R
R/core_commons.R
+3
-4
R/ggplot_commons.R
R/ggplot_commons.R
+4
-6
No files found.
R/core_commons.R
View file @
2ab5a283
...
...
@@ -166,14 +166,12 @@ replaceNA <- function(x, withValue) { x[is.na(x)] <- withValue; x }
## related: http://cran.r-project.org/web/packages/R.cache/R.cache.pdf
cache_it
<-
function
(
expr
,
cacheName
){
cache_it
<-
function
(
expr
,
cacheName
=
paste0
(
"cache_"
,
substr
(
digest
(
expr
),
1
,
6
))
){
cacheFile
<-
paste0
(
"."
,
cacheName
,
".RData"
)
if
(
file.exists
(
cacheFile
)){
# print("using cache")
local
(
get
(
load
(
cacheFile
)))
}
else
{
# print("evaluating expression")
result
<-
eval
(
expr
)
save
(
result
,
file
=
cacheFile
)
result
...
...
@@ -182,7 +180,8 @@ cache_it <- function(expr, cacheName){
## Examples
#mydata <- quote(iris %>% filter(Species=="setosa")) %>% cache_it("tt")
#mydata <- quote( { print("evaluation expr"); iris %>% filter(Species=="setosa") } ) %>% cache_it("tt")
#mydata <- quote(iris %>% filter(Species=="setosa")) %>% cache_it()
#mydata <- quote( { print("evaluate expr"); iris %>% filter(Species=="setosa") } ) %>% cache_it()
########################################################################################################################
#### File System
...
...
R/ggplot_commons.R
View file @
2ab5a283
require.auto
(
ggplot2
)
require.auto
(
scales
)
require
(
grid
)
require.auto
(
grid
)
scale_fill_redgreed
<-
function
()
scale_fill_manual
(
values
=
c
(
"red"
,
"darkgreen"
))
...
...
@@ -10,7 +9,6 @@ rotXlab <- function() theme(axis.text.x = element_text(angle = 90, hjust = 1))
# Multiple plot function
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
...
...
@@ -85,12 +83,12 @@ ggsave2 <- function(gplot=last_plot(), width=8, height=6, prefix="", saveData=FA
}
fileBaseName
<-
ifelse
(
nchar
(
prefix
)
>
0
,
concat
(
prefix
,
" - "
,
title
),
title
)
fileBaseName
<-
ifelse
(
nchar
(
prefix
)
>
0
,
paste0
(
prefix
,
" - "
,
title
),
title
)
## clean up weired characters
fileBaseName
<-
str_replace_all
(
fileBaseName
,
"[$%/?]"
,
"_"
)
fileName
=
concat
(
fileBaseName
,
concat
(
"."
,
outputFormat
))
fileName
=
paste0
(
fileBaseName
,
paste0
(
"."
,
outputFormat
))
## remove line-breaks and trim spaces
fileName
=
str_replace_all
(
str_replace_all
(
fileName
,
"\\n"
,
""
),
"[ ]{2,}"
,
" "
)
...
...
@@ -98,7 +96,7 @@ ggsave2 <- function(gplot=last_plot(), width=8, height=6, prefix="", saveData=FA
ggsave
(
fileName
,
width
=
width
,
height
=
height
,
...
)
if
(
saveData
){
write.delim
(
gplot
$
data
,
file
=
concat
(
fileBaseName
,
".txt"
))
write.delim
(
gplot
$
data
,
file
=
paste0
(
fileBaseName
,
".txt"
))
}
return
(
fileName
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment