Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views3 pages

R Programming QA Full

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

R Programming QA Full

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Explain open source nature of R?

R is open-source software, meaning it is free to use, modify, and distribute. Its source code is
available under the GNU General Public License (GPL). This encourages collaboration, community
contributions, and development of new packages by statisticians and programmers worldwide.

2. What is R programming?
R is a programming language and environment specifically designed for statistical computing, data
analysis, and graphical visualization.

3. Write any two uses of R programming?


1) Statistical analysis (e.g., regression, hypothesis testing). 2) Data visualization (e.g., plots,
graphs, dashboards).

4. Why is R important for statistical computing?


R provides a wide range of statistical techniques, built-in functions, and specialized packages. It
also supports data handling, graphical representation, and reproducibility of research.

5. List any three data types in R programming?


1) Numeric 2) Character 3) Logical

6. How do you install the R studio?


1) Download R (from CRAN: https://cran.r-project.org). 2) Download RStudio (from
https://posit.co/download/rstudio/). 3) Install R first, then install RStudio.

7. What is the difference between R and R studio?


R: The actual programming language and computing engine. RStudio: An Integrated Development
Environment (IDE) that makes using R easier with a user-friendly interface, editor, console, and
tools.

8. Describe the interface of R studio?


RStudio has four main panels: - Source/Script Editor (top-left) - Console (bottom-left) -
Environment/History (top-right) - Files/Plots/Packages/Help (bottom-right)

9. Define Variables in R?
A variable is a named storage that holds data or values. Example: x <- 10

10. Explain the use of R as calculator?


R can directly perform arithmetic operations in the console: 2 + 3 (Addition) 5 * 4 (Multiplication) 10 /
2 (Division)

11. Explain numeric and character Data type?


Numeric: Represents numbers (e.g., x <- 10.5). Character: Represents text/strings (e.g., name <- 'R
Language').
12. Describe how variables are assigned in R?
Variables are assigned using: x <- 5 y = 10 z <<- 15 (Global assignment)

13. What are the steps to install R in Windows?


1) Go to CRAN website. 2) Select 'Download R for Windows.' 3) Choose 'base' → Download latest
version. 4) Run installer and follow setup wizard.

14. Differentiate between x <- 5 and x = 5?


x <- 5: Recommended assignment operator in R. x = 5: Also works but mostly used for function
arguments.

15. Explain how to use R for simple arithmetic operations.


a <- 10, b <- 4 - a + b (Addition) - a - b (Subtraction) - a * b (Multiplication) - a / b (Division) - a ^ b
(Power)

16. What is vector in R?


A vector is a one-dimensional collection of elements of the same data type.

17. Write the syntax to create a vector in R?


v <- c(1, 2, 3, 4, 5)

18. What are the types of Vectors in R?


1) Numeric vectors 2) Character vectors 3) Logical vectors

19. Explain how to access elements of a vector in R?


v <- c(10, 20, 30, 40) v[1] → First element v[2:3] → Second to third element v[-1] → All except first
element

20. List operations you can perform over the vector.


Arithmetic (+, -, *, /) Logical (>, <, ==) Statistical functions (sum(), mean(), length())

21. How do you check the length of a vector in R?


v <- c(5, 10, 15, 20) length(v)

22. Describe vector coercion with an example.


When combining different data types in a vector, R converts them to a common type. v <- c(1, 'R',
TRUE) Result: '1' 'R' 'TRUE' (all converted to character)

23. Explain recycle rule in vector arithmetic.


If vectors of unequal length are operated on, the shorter one is recycled (repeated) to match the
length. x <- c(1,2,3,4) y <- c(10,20) x + y → (11,22,13,24)

24. What happens if you try to mix data types in a vector?


R coerces to the most flexible type: Logical → Integer → Numeric → Complex → Character.
Example: v <- c(TRUE, 5L, 3.2, 4+1i, 'R') → all become character.

25. Install the package in R using code.


install.packages('ggplot2') library(ggplot2)

26. Analyze what happens if you assign a character to a numeric vector.


The entire vector becomes character. Example: c(1, 2, 'three') → '1' '2' 'three'

27. Write an R script to calculate area of circle.


radius <- 7 area <- pi * radius^2 print(area)

28. Assign values to three variables and print them.


a <- 10; b <- 20; c <- 30 print(a); print(b); print(c)

29. Create a variable and change its data type using as.numeric().
x <- '123' y <- as.numeric(x) class(y) → 'numeric'

30. Evaluate which data type is written by class(c(1,2.0,'3')).


Output: 'character' (due to coercion).

31. Create a vector of numeric and print its mean and median.
v <- c(5,15,25,35,45) mean(v) → 25 median(v) → 25

32. Write a program to add two vectors (recycling rule).


x <- c(1,2,3,4) y <- c(10,20) x+y → 11 22 13 24

33. Create a character vector and convert it into a factor.


colors <- c('red','blue','green','red') factor(colors) → Levels: blue green red

34. Write R code to slice first 5 elements of a vector.


v <- c(1,2,3,4,5,6,7,8,9) v[1:5] → 1 2 3 4 5

35. Identify the output of a vector with unequal length in arithmetic (Recycling Rule).
x <- c(1,2,3,4,5) y <- c(10,20) x+y → 11 22 13 24 15 Warning: longer object length is not a multiple
of shorter object length

You might also like