Can you nest for loops in R?
- Yes, for loops can be nested
- No, for loops cannot be nested
- Depends on the version of R
- Depends on the operating system
Yes, for loops can be nested in R. This means you can have one for loop inside another for loop, allowing you to iterate over multiple dimensions or levels of data structures. However, nesting loops should be used with caution, as it can lead to complex and potentially slower code.
How would you extract a substring from a string in R?
- Use the extract() function
- Use the slice() function
- Use the sub() function
- Use the substring() function
The substring() function in R is used to extract a substring from a string. For example, substring("Hello", 2, 3) would return "el".
Which R function returns the absolute value of a number?
- abs()
- absolute()
- fabs()
- modulus()
The abs() function in R is used to return the absolute value of a number. For example, abs(-5) would return 5.
How do you represent a newline character in R?
- n
- r
- t
- b
In R, a newline character is represented using the escape sequence n. For example, "HellonWorld" would result in two lines: "Hello" and "World".
The ______ function in R can be used to find the maximum value in each row of a matrix.
- apply()
- max.row()
- rowMax()
- max()
The rowMax() function in R can be used to find the maximum value in each row of a matrix. The rowMax() function returns a vector of maximum values corresponding to each row of the matrix.
To customize the axis labels in an R bar chart, you would use the ______ parameter.
- col
- names.arg
- horiz
- labels
To customize the axis labels in an R bar chart, you would use the names.arg parameter. By providing a vector of labels corresponding to each bar, you can specify custom labels for the bars on the axis.
In R, a vector is created using the ______ function.
- c()
- vector()
- list()
- array()
In R, a vector is created using the c() function, which stands for "combine." The c() function allows you to combine elements into a vector by separating them with commas. You can also use the c() function to combine existing vectors into a new vector.
The ________ function in R is used to convert a variable to numeric.
- as.character()
- as.factor()
- as.logical()
- as.numeric()
The as.numeric() function in R is used to convert a variable to numeric. It is important to ensure that the variable is indeed convertible to numeric, otherwise NA's might be introduced.
Describe the approach Bootstrap takes to create mobile-first designs.
- Mobile-up design
- Desktop-first design
- Hybrid design
- Responsive design
Bootstrap adopts a mobile-up approach, prioritizing styles for smaller screens and progressively enhancing for larger ones. This ensures a better mobile experience.
How can you trigger an alert to close automatically in Bootstrap?
- Using JavaScript/jQuery
- Adding the "alert-dismissible" class
- Setting a timer with the "data-dismiss" attribute
- Pressing the "ESC" key
To make an alert close automatically in Bootstrap, you can set a timer using the "data-dismiss" attribute. This attribute specifies the duration (in milliseconds) for which the alert will be visible before closing.