Week 3 Jan 25.pdf - Week 3 Jan 25 Tuesday 1:47 AM if...

Info icon This preview shows pages 1–2. Sign up to view the full content.

plot (data, type="l") # Plot lines only if (length(data) > 100) plot (data, type="b") # Plot lines, plus dots at the points else plot_data <- function (data) { } # Plot data with lines, plus dots if no more than 100 points. To write a T/F if/else function, omit "else" part (automatically TRUE if matches "if" portion, and FALSE if not) else if (school=="secondary") 2 else if (school=="university") 3 else 0 ) > edu_level <- ( if (school=="primary") 1 Can be useful to write "false" as another if expression if function : > a <-12 > 10 > a [1] FALSE > a == 12 # "equals" comparisons - note that it uses ==, not just = (which is equiv of <-) [1] TRUE > a == 9 [1] FALSE > a != 9 # "not equal" comparison [1] TRUE > a <= 11 # "less or equal" comparison [1] FALSE Can also do comparisons with strings (whether string is == or isn't !=, or >/</etc alphabetically) a <-9 places 9 in a
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern