Skip to content

Commit

Permalink
Merge pull request #20 from duttashi/develop
Browse files Browse the repository at this point in the history
A user defined function to test the function arguments
  • Loading branch information
duttashi authored Jul 14, 2018
2 parents b7174b3 + 0937cf9 commit 0abb85c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/basic concepts/function-argument_test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# create a function to test the arguments

# clean the workspace
rm(list = ls())
testArgs<- function(data){

if (!is.matrix(data) & !is.data.frame(data)) {
stop("The data must be a matrix or a data frame.")
}
else{
str(data)
print("All ok")
}
}

# create some test data to test the function
# a vector
aa<- c(1:10)
testArgs(aa)

# a data frame
df<- data.frame(x=c(1:10),y=c(11:20))
testArgs(df)

0 comments on commit 0abb85c

Please sign in to comment.