Questions #Tagged [function]

Questions: 2

How to convert every % value with decimal in R programming?

We can use auxiliary function and mutate_if to achieve this output. Below is the code snippet:<br> <pre><xmp>is.percentage <- function(x) any(grepl("%$", x)) df1 %>% mutate_if(is.percentage, ~as.numeric(sub("%", "", .))/100)</xmp></pre>

 

#r-programming     #function    

How to create website page where content will load automatically after every page scroll?

We can achieve this by using "scroll" event listener where callback function checks if scroll position is near the end of the page then it will load more content. Below is the code snippet:<br> <pre><xmp><html> <style> .container>div { min-height: 40px; } </style> <body> <div class="container"> <div>1</div> <div>2</div> </div> <script> window.addEventListener("scroll", function () { var el = document.querySelector(".container"); if (el.scrollTop + el.offsetHeight > el.scrollHeight - 300) { console.log("Load more...") } }) </script> </body> </html></xmp></pre>

 

#html     #css     #javascript     #function