Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bioinfo
datautils
Commits
a4c8132f
Commit
a4c8132f
authored
Apr 12, 2016
by
Holger Brandl
Browse files
cosmetics
parent
941e849e
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/core_commons.R
View file @
a4c8132f
...
...
@@ -178,8 +178,9 @@ print_head <- function(df, desc=NULL){
fac2char
<-
function
(
mydata
,
convert
=
names
(
mydata
)[
sapply
(
mydata
,
is.factor
)]){
if
(
length
(
convert
)
==
0
)
return
(
mydata
)
if
(
length
(
convert
)
==
0
){
return
(
mydata
)
}
inputColOrder
<-
names
(
mydata
)
...
...
@@ -333,26 +334,28 @@ rmLastElement <- function(vec) vec[-length(vec)]
# improved list of objects
lsos
<-
function
(
pos
=
1
,
pattern
,
order.by
,
decreasing
=
FALSE
,
head
=
FALSE
,
n
=
5
)
{
napply
<-
function
(
names
,
fn
)
sapply
(
names
,
function
(
x
)
fn
(
get
(
x
,
pos
=
pos
)))
lsos
<-
function
(
pos
=
1
,
pattern
,
order.by
,
decreasing
=
FALSE
,
head
=
FALSE
,
n
=
5
)
{
napply
<-
function
(
names
,
fn
)
sapply
(
names
,
function
(
x
)
fn
(
get
(
x
,
pos
=
pos
)))
names
<-
ls
(
pos
=
pos
,
pattern
=
pattern
)
obj.class
<-
napply
(
names
,
function
(
x
)
as.character
(
class
(
x
))[
1
])
obj.mode
<-
napply
(
names
,
mode
)
obj.type
<-
ifelse
(
is.na
(
obj.class
),
obj.mode
,
obj.class
)
obj.size
<-
napply
(
names
,
object.size
)
/
1000000
obj.dim
<-
t
(
napply
(
names
,
function
(
x
)
as.numeric
(
dim
(
x
))[
1
:
2
]))
vec
<-
is.na
(
obj.dim
)[,
1
]
&
(
obj.type
!=
"function"
)
obj.dim
[
vec
,
1
]
<-
napply
(
names
,
length
)[
vec
]
out
<-
data.frame
(
obj.type
,
obj.size
,
obj.dim
)
names
(
out
)
<-
c
(
"Type"
,
"Size"
,
"Rows"
,
"Columns"
)
if
(
!
missing
(
order.by
))
out
<-
out
[
order
(
out
[[
order.by
]],
decreasing
=
decreasing
),
]
if
(
head
)
out
<-
head
(
out
,
n
)
# out
if
(
head
)
out
<-
head
(
out
,
n
)
out
<-
transform
(
out
,
var_name
=
rownames
(
out
))
rownames
(
out
)
<-
NULL
arrange
(
out
,
Size
)
...
...
@@ -373,4 +376,4 @@ trim_outliers <- function(values, range=quantile(values, c(0.05, 0.95))) pmax(r
## use trim_outliers instead
#limit_range <- function(values, range) pmax(range[1], pmin(range[2], values))
se
<-
function
(
x
)
sd
(
x
,
na.rm
=
TRUE
)
/
sqrt
(
sum
(
!
is.na
(
x
)))
se
<-
function
(
x
)
sd
(
x
,
na.rm
=
TRUE
)
/
sqrt
(
sum
(
!
is.na
(
x
)))
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