1) Create a vector (4,6,3,4,6,3,…..,4,6,3) Where there are 10 occurrences of 4 Using repeat function ANS=> > v1 <- c(4,6,3,4,6,3,4,6,3) > v1 > rep(v1,time=2) [1] 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 4 6 3 > -------------------------------------------------------------- 2) Use the function paste to create the following character vectors of length 30: ("fn1", "fn2", ..., "fn30"). In this case, there is no space between fn and the number following. ANS=> > paste("fn",v3,sep = "") [1] "fn1" "fn2" "fn3" "fn4" "fn5" "fn6" "fn7" "fn8" "fn9" "fn10" "fn11" "fn12" [13] "fn13" "fn14" "fn15" "fn16" "fn17" "fn18" "fn19" "fn20" "fn21" "fn22" "fn23" "fn24" [25] "fn25" "fn26" "fn27" "fn28" "fn29" "fn30" > > paste(collapse ="fn",v3) [1] "1fn2fn3fn4fn5fn6fn7fn8fn9fn10fn11fn12fn13fn14fn15fn16fn17fn18fn19fn20fn21fn22fn23fn24fn25fn26fn27fn28fn29fn30" 4) Create a character vector like "Android", "Java", "R" , "C" , "PHP" and print length of each vector element output is like 7 4 1 1 3,. ANS=> > v4 <- c("Android", "Java", "R" , "C" , "PHP") > v4 > v4 [1] "Android" "Java" "R" "C" "PHP" > nchar(v4) [1] 7 4 1 1 3 > 5) create the function to do the sum of inputted number Example: no=235 then the output will be 2+3+5 = 10. ANS=> > sum(2+3+5) [1] 10 3) Matrix A = 1 1 3 5 2 6 -2 -1 -3 Q.3 Read “Rainfall.csv” and generate following charts. 1) Generate scatter plot of rainfall for Tokyo city with red color and double line thickness. Provide lines for New York ,London and Berlin city on the same plot with three different colors. 2) Generate a Barchart of matrix of rainfall for all cities Provide colors to bars and month name as legend ANS=>

No comments:

Post a Comment

Unleashing B2B Success: Mastering Event and Conversion Tracking with GA4

Tracking events and conversions is vital for B2B businesses using GA4 (Google Analytics 4) to optimize their marketing efforts. Here is a re...