Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to convert a Kotlin source file to a Java source file?

Soumak De
Soumak De
Updated on 23-Nov-2021 924 Views

Kotlin is a statistically typed language that runs on JVM. Once a Kotlin file is compiled, it creates a .class file that can be executed on the JVM. In this article, we will see how we can convert a Kotlin source file to a Java source file. In this process, we will be taking help from different online Decompilers available on the Internet.Open VS Code.Go to the "extension" section and install "Kotlin language support for VS Code" and "Code Runner". We need these two extensions to run Kotlin in VS code environment.Install Kotlin compiler in your system as per the ...

Read More

How to display fraction in a plot title using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 1K+ Views

To display fraction in a plot title using ggplot2 in R, we can use frac function inside ggtitle function of ggplot2 package. Generally, fraction is displayed as X/Y but frac function helps to create the fraction in over form.Check out the below example to understand how over form of fraction can be displayed in a plot title using ggplot2.ExampleFollowing snippet creates a sample data frame −x

Read More

How to find the sequence of correlation between variables in an R data frame or matrix?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 403 Views

To find the sequence of correlation between variables in an R data frame or matrix, we can use correlate and stretch function from corrr package.For example, if we have a data frame called df then we can find the sequence of correlation between variables in df by using the below given command −df%>% correlate() %>% stretch() %>% arrange(r)Example 1Following snippet creates a sample data frame −x1% + arrange(r) Correlation method: 'pearson' Missing treated using: 'pairwise.complete.obs' # A tibble: 25 x 3OutputIf you execute all the above given snippets as a single program, it generates the following output −  ...

Read More

How to create a matrix with vectors as elements in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 864 Views

To create a matrix with vectors as elements in R, we can create arrays because an array contains matrices with vectors as elements.Check out the below given examples of arrays and vectors extracted by the arrays to understand how matrices stored in an array represent vectors as elements.Example 1Following snippet creates arrays consisting of matrices −Array

Read More

How to create a vertical line in a time series plot in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 1K+ Views

To create a time series plot, we can use simply apply plot function on time series object and if we want to create a vertical line on that plot then abline function will be used with v argument.For example, if we have a time series object called T and we want to create a time series plot of T with vertical line at point 5 then we can use the below given command after creating the plot −abline(v=5)ExampleTo create a vertical line in a time series plot in base R, use the following code −x

Read More

How to convert matrices stored in a list into vectors in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 318 Views

A list may contain vectors, data frames, matrices, lists etc. If a list contains matrices and we want to convert those matrices into vectors then lapply function can be used along with as.vector function.For example, if we have a list called LIST that contains matrices then we can convert those matrices into data frames by using the below given command − lapply(LIST,function(x) as.vector(x))ExampleFollowing snippet creates the matrices −M1

Read More

How to create a column with ratio of two columns in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 3K+ Views

To create a new column with ratio of two columns in an R data frame, we can use division sign.For example, if we have a data frame called df that contains two columns say X and Y and we want to create a new column with ratio of X and Y then we can use the below given command −df$Ratio_X_Y

Read More

How to find the number of times a variable changes its sign in an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 23-Nov-2021 577 Views

To find the number of times a variable changes its sign in an R data frame column, we can use sign function with diff and sum function.For example, if we have a data frame called df that contains a column say C then, we can find the number of times C changes its sign by using the following command −sum(diff(sign(df$C))!=0)Example 1Following snippet creates a sample data frame −x

Read More

Convert Kotlin Array to Java varargs

Soumak De
Soumak De
Updated on 23-Nov-2021 390 Views

Varargs, also known as "variable arguments" is a new mechanism in Java by which methods in Java can accept zero or multiple number of arguments. Before this mechanism, the only option available to achieve this type of functionality was "method overloading", but that also required multiple lines of boilerplate code.In this article, we will see how we can use Varags in Kotlin to call a function multiple times based on different types of arguments. The following example demonstrates how we can use this Varags keyword.Examplefun main() {    // calling the function with 4 arguments and    // passing 3 ...

Read More

Accessing Kotlin extension functions from Java

Soumak De
Soumak De
Updated on 23-Nov-2021 2K+ Views

In Kotlin, you can easily call another function by just importing the same in the current Kotlin file where your main function is running. Whatever the function we are declaring in a Kotlin file will be compiled into a static method by default, and it will be placed under the same package. The name of the newly created file will be renamed as the First letter capitalized and ".kt" extension replaced with the "Kt" suffix.In this article, we will try to get an insight into how you can use Kotlin extension methods from a Java file.ExampleLet's create a Kotlin file ...

Read More
Showing 47101–47110 of 61,298 articles
Advertisements