Programming Articles - Page 929 of 3363

Node.js – dns.resolveTxt() Method

Mayank Agarwal
Updated on 29-Oct-2021 08:07:24

451 Views

The dns.resolveTxt() method uses the DNS protocol to resolve the text queries (TXT Records) for the hostname. The addresses argument passed to the callback function is a two-dimensional array that contains the array of text records available for the hostname.Syntaxdns.resolveTxt(hostname, callback)Parametershostname – This parameter takes input for hostname to be resolvedcallback – This function will catch errors, if any.records – Returns TXT records for the hostname.Example 1Create a file with the name "resolveTxt.js" and copy the below code snippet. After creating file use the command "node resolveTxt.js" to run this code.// dns.resolveTxt() Demo Example // Importing the dns module ... Read More

Node.js – process.report Property

Mayank Agarwal
Updated on 29-Oct-2021 07:58:52

239 Views

process.report is an object whose methods generate the diagnostic reports for the current process. It is found under the process module.Syntaxprocess.reportExample 1Create a file with the name "report.js" and copy the following code snippet. After creating the file, use the command "node report.js" to run this code.// process.report Demo Example // Importing the process module const process = require('process'); // Getting reports for the below processes const reports = process.report; // Printing out the result console.log(reports)OutputuC:\homeode>> node report.js {    writeReport: [Function: writeReport],    getReport: [Function: getReport],    directory: [Getter/Setter],    filename: [Getter/Setter],    compact: [Getter/Setter],   ... Read More

Node.js – dns.lookup() Method

Mayank Agarwal
Updated on 29-Oct-2021 07:31:40

686 Views

The dns.lookup() method resolves the host name (e.g., tutorialspoint.com) into the first found A IPv4) or AAAA (IPv6) record. The properties available under the options are optional. dns.lookup() does not have anything to do with the DNS protocol. The implementation uses an OS facility that can associate names with addresses and vice versa.Syntaxdns.lookup(hostname, [options], callback)ParametersThe above parameters are defined as below −hostname – This is the website hostname for which you want to look up the DNS values.options – It can have the following optionsfamily – It can have the values 4, 6, or 0 only. The value "0" indicates ... Read More

Node.js – dns.resolveNs() Method

Mayank Agarwal
Updated on 29-Oct-2021 07:27:42

106 Views

The dns.resolveNs() method uses the DNS protocol to resolve the nameserver records (NS Records) for the hostname. The addresses argument passed to the callback function will contain an array of nameserver records for the hostname.Syntaxdns.resolveNs(hostname, callback)ParametersThe above parameters are defined as below −hostname – This parameter takes input for the hostname to be resolved.callback – This function will catch errors, if any.records – Returns the nameserver (NS) records for the hostname.Example 1Create a file "resolveNs.js" and copy the following code snippet. After creating the file, use the command "node resolveNs.js" to run this code:// dns.resolveNs() Demo Example // Importing ... Read More

Create a data.table object of combination of correlation coefficients.

Nizamuddin Siddiqui
Updated on 28-Oct-2021 15:01:09

196 Views

To create a data.table object of combination of correlation coefficients, we first need to find the correlation matrix then the combination of variables for which the correlation matrix is created then data.table will be used to combine the combination of variables and the correlation coefficients.Check out the below Examples to understand how it can be done.Example 1Following snippet creates a sample data frame −x1

Create a graph without background panel using ggplot2 in R.

Nizamuddin Siddiqui
Updated on 12-Nov-2021 03:45:36

187 Views

To create a graph without background panel, we can use theme function of ggplot2 package where we can set panel.background argument to blank.For Example, if we have a data frame called df that contains two columns say x and y then we can create scatterplot between x and y without background panel using ggplot2 by using the below command −ggplot(df,aes(x,y))+geom_point()+theme(panel.background=element_blank())ExampleConsider the below data frame −x

Create a graph using ggplot2 without axes ticks and axes labels.

Nizamuddin Siddiqui
Updated on 12-Nov-2021 03:44:32

210 Views

To create a graph using ggplot2 without axes ticks and axes labels, we can use theme function where we can use set axes ticks and axis labels to blank with the help of arguments corresponding to each axes such as axis.ticks.x, axis.ticks.y, axis.text.x, and axis.text.y.To understand how it works, check out the below Example.ExampleConsider the below data frame −x

How to display a variable with subscript ggplot2 graph in R?

Nizamuddin Siddiqui
Updated on 12-Nov-2021 03:43:22

1K+ Views

Sometimes we have variables that have a subscript associated with them. This subscript is used to define the characteristics of the variable or to differentiate similar variables from each other.In this type of situation, displaying a variable with subscript in a graph created with the help of ggplot2 can be done by using the geom_text function. Check out the below Example to understand how it can be done.ExampleConsider the below data frame −x1

How to display tilde ggplot2 graph in R?

Nizamuddin Siddiqui
Updated on 12-Nov-2021 03:40:50

436 Views

Let’s say we want to display tilde sign at a particular position in histogram using ggplot2 graph. In this situation, we can use geom_text function and pass all the text with label argument inside aes where tilde will be written as %~%.For Example, if we want to display X follows Normal Distribution then we can write it as −geom_text(aes(label="X %~% Normal Distribution",x=0,y=200),parse=TRUE)Here, x=0 and y=200 is the position of the label in the histogram.ExampleConsider the below data frame −x

Select columns of an R data frame and skip if does not exist.

Nizamuddin Siddiqui
Updated on 28-Oct-2021 14:02:39

834 Views

Sometimes we have a large number of columns in the data frame and we know the name of some columns but among known ones some does not exist in the data frame. Now if we want to select the columns that we know and skip the ones that do not exist then we can use the subsetting.For Example, if we have a data frame called df that contains twenty columns and we believe that x, y, z exists in df but z is not there in reality. Now the selection of columns x, y, z that will skip z can ... Read More

Advertisements