recurse_fib <- function(n) { if(n <= 1) { return(n) } else { return(recurse_fib(n-1) + recurse_fib(n-2)) } } #type number of terms: nterms =10 # check if the number of terms is valid if(nterms <= 0) { print("Plese enter a positive integer") } else { print("Fibonacci sequence:") for(i in 0:(Read more
recurse_fib <- function(n) {
if(n <= 1) {
return(n)
} else {
return(recurse_fib(n-1) + recurse_fib(n-2))
}
}
#type number of terms:
nterms =10
# check if the number of terms is valid
if(nterms <= 0) {
print("Plese enter a positive integer")
} else {
print("Fibonacci sequence:")
for(i in 0:(nterms-1)) {
print(recurse_fib(i))
}
}
stu_data<-data.frame(name=c("James","harry","Robert","Larry","Rozer"), rollno=c(1:5), stream=c("Science","commerce","Biology","commerce","Science")) stu_data #a) Write R Code to convert all the values in a student dataframe into Matrix. stu_mat<-data.matrix(stu_data) stu_mat #b) Select the subRead more
stu_data<-data.frame(name=c("James","harry","Robert","Larry","Rozer"),
rollno=c(1:5),
stream=c("Science","commerce","Biology","commerce","Science"))
stu_data
#a) Write R Code to convert all the values in a student dataframe into Matrix.
stu_mat<-data.matrix(stu_data)
stu_mat
#b) Select the subset of Dataframe
sub_set<-stu_data[c(1,4:5),c(1:3)]
sub_set
#c) Sort the data within frame
print(stu_data[order(stu_data$rollno, decreasing = TRUE), ] )
#d) Visualize the Dataframe usingplot ()
plot.ts(stu_mat)
Write RScript to create a recursive function to implement Fibonacci series.
recurse_fib <- function(n) { if(n <= 1) { return(n) } else { return(recurse_fib(n-1) + recurse_fib(n-2)) } } #type number of terms: nterms =10 # check if the number of terms is valid if(nterms <= 0) { print("Plese enter a positive integer") } else { print("Fibonacci sequence:") for(i in 0:(Read more
Create a dataframe Student, perform below mentioned operation on a data frame. Explain with proper example. a) Write R Code …
stu_data<-data.frame(name=c("James","harry","Robert","Larry","Rozer"), rollno=c(1:5), stream=c("Science","commerce","Biology","commerce","Science")) stu_data #a) Write R Code to convert all the values in a student dataframe into Matrix. stu_mat<-data.matrix(stu_data) stu_mat #b) Select the subRead more
______ is used to identify whether the provided dataset is a Dataframe.
You can check whether the provided dataset is dataframe or not using is.data.frame(Yourdatasetname) or, class(Yourdatasetname)
You can check whether the provided dataset is dataframe or not using
is.data.frame(Yourdatasetname) or,
class(Yourdatasetname)
See lessWrite code to create vectors, then convert vectors into list and further list to dataframe.
#create a vector v <- c(2,3,6) print(v) #convert vector to list v_list<-as.list(v) v_list #list to dataframe v_df<-as.data.frame(v_list) v_df
Which of the following is not an application of binary search?
ANSWER: d) To search in unordered list
ANSWER: d) To search in unordered list
See lessWhich of the following is not an inherent application of stack? a) Reversing a string b) Evaluation of postfix expression …
ANSWER: d) Job scheduling
ANSWER: d) Job scheduling
See less