I want to make a function which does the following: Take in a data set Check global variable x if it is 0 or 1 If x is 0 then it should turn x to 1 and return the data set without the first line If x is 1 then it should leave x and return every line.
The data set is
mid counts 1 -2.25 3 2 -1.75 6 3 -1.25 14 4 -0.75 14 5 -0.25 17 6 0.25 19 7 0.75 12 8 1.25 9 9 1.75 4 10 2.25 2 11 2.25 -3 12 2.75 -6 13 3.25 -14 14 3.75 -14 15 4.25 -17 16 4.75 -19 17 5.25 -12 18 5.75 -9 19 6.25 -4 20 6.75 -2
Function I have now
testfunc = function(set){ print(x) for(i in 1:nrow(set)){ ifelse(x == 0, x <<- 1, return(set[i])) } }
This gives as result the print of x and only the counts row of the data set without the first line left out.
Aucun commentaire:
Enregistrer un commentaire