Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
H
Harmonize_Scripts
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Uncover
Harmonize_Scripts
Commits
841190e3
Commit
841190e3
authored
Mar 03, 2023
by
GNajeral
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated valid_variables_script2
parent
e2324ef7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
valid_variables_script2.R
valid_variables_script2.R
+33
-6
No files found.
valid_variables_script2.R
View file @
841190e3
...
@@ -132,8 +132,8 @@ is_number <- function(x){
...
@@ -132,8 +132,8 @@ is_number <- function(x){
check_values_format
<-
function
(
valid_columns
,
codebook_param
){
check_values_format
<-
function
(
valid_columns
,
codebook_param
){
res
<-
""
res
<-
""
variables_out_of_range
=
"Variables out of range:"
variables_out_of_range
=
"Variables out of range:"
for
(
i
in
1
:
length
(
valid_columns
[[
1
]])){
#
for(i in 1:length(valid_columns[[1]])){
for
(
i
in
1
:
9
){
current_column
<-
valid_columns
[[
1
]][[
i
]]
current_column
<-
valid_columns
[[
1
]][[
i
]]
print
(
current_column
)
print
(
current_column
)
variable_type
<-
codebook_param
$
Variable.type
[
codebook
$
Harmonised.variable.name
==
current_column
]
variable_type
<-
codebook_param
$
Variable.type
[
codebook
$
Harmonised.variable.name
==
current_column
]
...
@@ -141,6 +141,8 @@ check_values_format <- function(valid_columns, codebook_param){
...
@@ -141,6 +141,8 @@ check_values_format <- function(valid_columns, codebook_param){
if
(
is.na
(
variable_type
)){
if
(
is.na
(
variable_type
)){
next
next
}
}
print
(
variable_type
)
if
(
variable_type
==
"Continuous"
){
if
(
variable_type
==
"Continuous"
){
...
@@ -149,8 +151,12 @@ check_values_format <- function(valid_columns, codebook_param){
...
@@ -149,8 +151,12 @@ check_values_format <- function(valid_columns, codebook_param){
### parse del formato de una variable continua ##
### parse del formato de una variable continua ##
## esta sentencia funciona codebook$Possible.values.format[codebook$Harmonised.variable.name == "CMXDE"] pruebala en el interprete.
## esta sentencia funciona codebook$Possible.values.format[codebook$Harmonised.variable.name == "CMXDE"] pruebala en el interprete.
value_format
<-
strsplit
(
codebook_param
$
Possible.values.format
[
codebook_param
$
Harmonised.variable.name
==
current_column
],
" / "
)[[
1
]]
value_format
<-
strsplit
(
codebook_param
$
Possible.values.format
[
codebook_param
$
Harmonised.variable.name
==
current_column
],
" / "
)[[
1
]]
high_limit
<-
gsub
(
","
,
"."
,
(
sub
(
"-.*"
,
""
,
value_format
[
1
])))
high_limit
<-
str_trim
(
gsub
(
","
,
"."
,
(
sub
(
"-.*"
,
""
,
value_format
[
1
]))))
low_limit
<-
gsub
(
","
,
"."
,
(
sub
(
".*-"
,
""
,
value_format
[
1
])))
low_limit
<-
str_trim
(
gsub
(
","
,
"."
,
(
sub
(
".*-"
,
""
,
value_format
[
1
]))))
if
(
low_limit
==
""
){
high_limit
<-
str_trim
(
sub
(
",.*"
,
""
,
value_format
[
1
]))
low_limit
<-
str_trim
(
strtrimsub
(
".*,"
,
""
,
value_format
[
1
]))
}
### parse del formato de una variable continua ##
### parse del formato de una variable continua ##
tryCatch
(
tryCatch
(
...
@@ -190,8 +196,29 @@ check_values_format <- function(valid_columns, codebook_param){
...
@@ -190,8 +196,29 @@ check_values_format <- function(valid_columns, codebook_param){
################## FIN ESTO PODRÍA IR EN UNA FUNC DIFERENTE #############
################## FIN ESTO PODRÍA IR EN UNA FUNC DIFERENTE #############
}
else
if
(
variable_type
==
"Categorical"
||
variable_type
==
"Binary"
){
}
else
if
(
variable_type
==
"Categorical"
||
variable_type
==
"Binary"
){
contingency_table
<-
ds.table
(
paste
(
"data$"
,
current_column
))
value_format
<-
lapply
(
strsplit
(
mierda
,
"/"
)
,
str_trim
)[[
1
]]
counts
<-
contingency_table
[[
1
]][[
3
]]
tryCatch
(
error
=
function
(
cnd
)
{
if
(
grepl
(
"list them with datashield.errors()"
,
cnd
))
error
<-
paste
(
"Unable to analyse data"
,
datashield.errors
()
,
sep
=
" "
)
else
error
<-
paste
(
"Unable to analyse data"
,
cnd
,
sep
=
" "
)
print
(
error
)
res
<-
c
(
res
,
error
)
},
{
contingency_table
<-
ds.table
(
paste
(
"data$"
,
current_column
,
sep
=
""
))
row_names
<-
rownames
(
contingency_table
[[
1
]][[
3
]])
for
(
i
in
1
:
length
(
row_names
))
{
if
(
row_names
[
i
]
==
"NA"
)
next
if
(
!
row_names
[
i
]
%in%
value_format
){
variables_out_of_range
<-
paste
(
variables_out_of_range
,
current_column
,
sep
=
" "
)
print
(
paste
(
current_column
,
"does not follow the established format"
,
sep
=
" "
))
}
}
}
)
}
}
}
}
return
(
variables_out_of_range
)
return
(
variables_out_of_range
)
...
...
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