Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1434 of 3366
1K+ Views
The String[] list(FilenameFilter filter) method of a File class returns a String array containing the names of all the files and directories in the path represented by the current (File) object. But the retuned array contains the filenames which are filtered based on the specified filter. The FilenameFilter is an interface in Java with a single method.accept(File dir, String name)To get the file names based on extensions implement this interface as such and pass its object to the above specified list() method of the file class.Assume we have a folder named ExampleDirectory in the directory D with 7 files and 2 directories ... Read More
393 Views
Since Java 7 the File.02s class was introduced this contains (static) methods that operate on files, directories, or other types of files.The createDirectory() method of the Files class accepts the path of the required directory and creates a new directory.ExampleFollowing Java example reads the path and name of the directory to be created, from the user, and creates it.Live Demoimport java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Scanner; public class Test { public static void main(String args[]) throws IOException { System.out.println("Enter the path to create a directory: "); Scanner sc = new Scanner(System.in); ... Read More
582 Views
When we create a plot using ggplot2, the axes labels are automatically generated for both the axes. We might want to use those axes labels for report writing or some other purpose, therefore, extraction of those labels for a plot created by using ggplot2 package can be found by using the ggplot_build function as shown in the below example but we need to save the plot in an object.Consider the below data frame −Example Live Demox
266 Views
To change the defaults for ggplot2 geoms, we need to use update_geom_defaults function. If we want to change the shape of points for scatterplot, we can use the below syntax −update_geom_defaults("point",list(shape=”point_shape_number”))The point shape number ranges from 0 to 25. We can change that according to our need.Consider the below data frame −Example Live Demox
730 Views
If list elements are of equal size having numerical values then the boxplot for each element can be created by using ggplot2 but before creating the boxplot we would need to convert the list to a data frame. The conversion of list elements to a data frame will be done by unlisting of elements and creating two columns, one for categories and one for response variable. Check out the below example to understand how it works.Consider the below list −Example Live DemoList
1K+ Views
A list object can contain multiple elements of data, also the size of the data may vary. If a list object has numerical vectors then the boxplot for each of the elements can be created simply by using boxplot function. For example, if we have a list object called LIST that contains five numerical vectors then the boxplot for each of the vectors can be created by using the command boxplot(LIST)Example Live DemoList
732 Views
To change the first value for each group in data.table object, we can use single square brackets for accessing and changing the value to desired value. For example, if we have a data.table object called DT that contains a group column defined by Class and a numerical column defined by Response then the first value of Response for each Class can be set to say 5 by using the command DT[,Response:=c(2,Response[-]),by=Class]Consider the below data.table object −Examplelibrary(data.table) Group
2K+ Views
To display text in base R plot with 180 degrees rotation, we can use text function. We would need to define both the axes values for the position where we need the text to be rotated inside the plot. For the rotation of the text, srt argument will be used and set to the value equals to 270. Check out the below example to understand how it works.Examplex
2K+ Views
A binomial distribution is based on the distribution of success and failure, the other two parameters of binomial distribution are the sample size and the probability of success. To create a plot of binomial distribution, we first need to define the density of the binomial distribution using dbinom function. The plotting can be done by using plot function with success and the density as shown in the below examples.Examplex
1K+ Views
If two values are repeated in a column that means there are many same values in that column but if those values are repeated in column as well as rows then they are called duplicated rows in two columns. To remove duplicate rows in an R data frame if exists in two columns, we can use duplicated function as shown in the below examples.Consider the below data frame −Example Live Demox1