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
8109eb7d
Commit
8109eb7d
authored
Sep 04, 2017
by
Holger Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make unification optional in pretty_names
parent
38225134
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
R/core_commons.R
R/core_commons.R
+10
-5
No files found.
R/core_commons.R
View file @
8109eb7d
...
...
@@ -223,8 +223,8 @@ set_names <- function(df, ...){
# devtools::source_url("https://www.dropbox.com/s/r6kim8kb8ohmptx/core_commons.R?dl=1")
pretty_names
=
function
(
some_names
){
some_names
%>%
pretty_names
=
function
(
some_names
,
make_unique
=
FALSE
){
new_names
=
some_names
%>%
str_replace_all
(
"[#=.,()/*: -]+"
,
"_"
)
%>%
str_replace
(
fixed
(
"["
),
""
)
%>%
str_replace
(
fixed
(
"]"
),
""
)
%>%
...
...
@@ -233,13 +233,18 @@ pretty_names = function(some_names){
str_replace
(
"^[_]+"
,
""
)
%>%
## remove unicode characters
iconv
(
to
=
'ASCII'
,
sub
=
''
)
%>%
## http://stackoverflow.com/questions/24807147/removing-unicode-symbols-from-column-names
tolower
%>%
tolower
if
(
make_unique
){
## make duplicates unqiue
make.unique
(
sep
=
"_"
)
new_names
%<>%
make.unique
(
sep
=
"_"
)
}
new_names
}
pretty_columns
=
function
(
df
){
names
(
df
)
<-
names
(
df
)
%>%
pretty_names
()
names
(
df
)
<-
names
(
df
)
%>%
pretty_names
(
make_unique
=
TRUE
)
df
}
...
...
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