Skip to content

SpaceTech

Exploration of Information, Communication and Technology

  • Home
  • Blog
  • Projects
    • Resx Builder
  • About
  • LinkedIn
  • Github

How to increment for loop by two in R

February 23, 2021June 2, 2021 Bjarne

A simple for loop iterating by one can be done by using the range

for (i in 0:10)
   print(i)

To increment by two you can use the seq function

for (i in seq(0, 10, 2))
   print(i)

This will print out every second number, since it is iterating by two here.

Source: https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/seq

Posted in TechnologyTagged R Language

About

Hey! I'm an engineer from Denmark. This is my engineering diary. I enjoy creating things, whether that be websites, plugins, mobile apps. I'm currently playing around in an engineering department where I work on a wide variety of interesting and meaningful projects on a daily basis.


  • Key Takeaways Chapter 3: Working with the Xtend Programming Language of Implementing Domain-Specific Languages with Xtext and Xtend – Second Edition
  • Key Takeaways Chapter 2 of Implementing Domain-Specific Languages with Xtext and Xtend – Second Edition
  • Key Takeaways Chapter 1 of Implementing Domain-Specific Languages with Xtext and Xtend – Second Edition
  • Xtext The rule ‘Primary’ may be consumed without object instantiation
  • VS Code disable blame text and you change x ago

Copyright ©SpaceTech

Clean Theme by WPVKP