Functions in R - English
- Questions posted on Forums
- R Tutorials - English
-
related print options
How to print series in a line like 1, 2, 3, 4, 5, 6 instead of 123456
02-03M 20-30SMay 14, 2025, 5:19 p.m. ritumeena_Akapoor
-
related print options
How to print series in a line like 1, 2, 3, 4, 5, 6 instead of 123456
02-03M 20-30SMay 15, 2025, 3:29 p.m. ritumeena_Akapoor
-
how i make function fibonacci (assignment's Q2)
Create a function which takes a natural number as an argument, and prints Fibonacci series. For example, consider fibonacci(5). It should print the first 5 elements of Fibonacci series, i.e. 1, 1, 2, 3, 5??????
09-10M 20-30SMay 9, 2025, 5:05 p.m. tanishagoyal
-
assignment on fibbonacci series
on giving the following input fibbonacci <- function(t1,t2,t3...........tn){ tn <- 0 t1=0 t2=1 t3=t1+t2 for(n in t1:tn){ t(n)=t(n-2)+t(n-1) } return(tn)}fibbonacci(t1,t2,t3.........tn)the following comments appear-fibbonacci <- function(t1,t2,t3...........tn){+ tn <- 0+ t1=0+ t2=1+ t3=t1+t2+ for(n in t1:tn){+ t(n)=t(n-2)+t(n-1)+ }+ return(tn)+ }> fibbonacci(t1,t2,t3.........tn)Error in t(n) <- t(n - 2) + t(n - 1) : could not find function "t<-">
11-12M 20-30SMay 15, 2025, 3:09 a.m. Joohi
-
fibonacci series correct or not
fibonacci <- function(num1,num2){result <- num1+num2for(i in 1){result <- c(num1,num2,result,result+i,result+result+i)}return(result)}fibonacci(1,1)Sir I am getting the result 1,1,2,3,5from the above functionis it correct
11-12M 10-20SMay 15, 2025, 3:34 p.m. manishakdey@gmail.com
-
functions
fib <- function(n){fib[0] <-1fib[1] <- 1for (i in 2:n) { fib[i] <- fib[i - 2] + fib[i - 1]}print(fib)}fib(5)Error in fib[0] <- 1 : object of type 'closure' is not subsettablepls help
02-03M 10-20SMay 15, 2025, 3:36 p.m. suhasini@comp.sce.edu.in
-
Doubt in functtion
n <- as.integer(readline("enter the number "))fibonacci <- function(n) { num1 <-0 num2<-1 for( i in 1:n){ print(num2) num3 <-num2 +num1 num1 <-num2 num2 <-num3 } }fibonacci() output is:Error in fibonacci() : argument "n" is missing, with no default
08-09M 0-10SMay 15, 2025, 3:30 p.m. archana.naware@gmail.com
-
Functions
Create a function to create an employee data frame (Name,Gender,Age,Designation & SSN). Function should return the dataframe employee. In main R script print Name and Age of employees.
03-04M 40-50SMay 15, 2025, 10:59 a.m. SUBHO98
-
Functions
Create a function which computes combination of two numbers
11-12M 0-10SMay 15, 2025, 3:59 p.m. bvs.nnsvidya@gmail.com
-
Create Fibonacci series
How to create a fibonacci series using FUNCTION?
12-13M 50-60SMay 15, 2025, 12:27 a.m. harshal1999
-
1Overview of R and RStudio
-
2Installing R and RStudio on Linux
-
3Installing R and RStudio on Windows
-
4Introduction to basics of R
-
5Introduction to Data Frames in R
-
6Introduction to RStudio
-
7Introduction to R script
-
8Working directories in RStudio
-
9Indexing and Slicing Data Frames
-
10Creating Matrices using Data Frames
-
11Operations on Matrices and Data Frames
-
12Merging and Importing Data
-
13Data types and Factors
-
14Lists and its Operations
-
15Plotting Histograms and Pie Chart
-
16Plotting Bar Charts and Scatter Plot
-
17Introduction to ggplot2
-
18Aesthetic Mapping in ggplot2
-
19Data Manipulation using dplyr Package
-
20More Functions in dplyr Package
-
21Pipe Operator
-
22Conditional Statements
-
Functions in R
Questions posted on ST Forums:
Outline:
Define a function About built-in functions and user-defined functions Need for a user-defined function Syntax of a function Parts of a function Create a user-defined function with arguments Create a user-defined function without arguments About readline function Scope of variables Use of return function