nickolakis
nickolakis

Reputation: 621

Matlab function convertion to R

i'm trying to convert a code from MATLAB to R and find a difficulty in a otherwise easy convertion.

function [X1, X2, X3, X4] = example (A, B, C, D, E)

SOME STATEMENTS

END 

cant find how to input in my r code the X1,...,X4. My code is the following

example <- function(A, B, C, D, E){

SOME STATEMENTS

} 

How and where to insert the Xi's?

Also how to convert the MATLAB statement =% in R?

fprintf('A=%D, B=%E, C=%F,', A, B, C)

Upvotes: 0

Views: 29

Answers (1)

ThomasIsCoding
ThomasIsCoding

Reputation: 101024

In R, you can put list(X1, X2, X3, X4) to the end of your function block. When you call the function example(A,B,C,D,D), the output will be in the format of list, i.e., list(X1, X2, X3, X4)

example <- function(A, B, C, D, E){

SOME STATEMENTS

list(X1, X2, X3, X4)
} 

Upvotes: 1

Related Questions