To change the name of a data frame, we can set the original name to the new name. Now both of the names can be used. Most of the times the purpose behind changing the name of the data frame is that, the original name does not seem to be a valid name based on the characteristics of the data. For example, if we have normally distributed columns in the data frame then we can name it as normal_distribution. This will help everyone to understand the data belongs to normal distribution.Example1 Live Demoset.seed(24) x
The variables in an R data frame are referred to as the columns of the data frame. Sometimes we have a threshold value for a particular column and we need to check whether all the values in that column are greater than or less than the threshold. For this purpose, we can make use of ifelse function as shown in the below examples.Example1 Live DemoConsider the below data frame −set.seed(24) x
To create a vector of weekdays we can use the command weekdays(Sys.Date()+0:6) and if we want to create a random sample of week days then sample function can be used along with the weekdays command. For example, if we want to create a random sample of 20 days then it can be done as sample(weekdays(Sys.Date()+0:6),20,replace=TRUE).Examples Live DemoExample1
If we have similar characteristics in each column of an R data frame then we can replace the missing values with row means. To replace the missing values with row means we can use the na.aggregate function of zoo package but we would need to use the transposed version of the data frame as na.aggregate works for column means.Example1Consider the below data frame − Live Demox1
Using the of() methodThe of() method of the java.time.LocalDate class accepts the values of the year, month, and day of month as parameters, creates and returns an object of the LocalDate.ExampleLive Demoimport java.time.LocalDate; public class Test { public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 9, 11); System.out.println("Date Value: "+date); } }OutputDate Value: 2014-09-11Using the GregorianCalendar classOne of the constructors of the java.util.GregorianCalendar class accepts the values of year, month and day of month as values and creates a Calendar object representing it.Exampleimport java.util.*; class Test { public static void main(String args[]){ ... Read More
If the data frame contains a factor column and some numerical columns then we might want to find the sum of numerical columns for the factor levels. For this purpose, we can use aggregate function. For example, if we have a data frame df that contains a factor column defined by Group and some numerical columns then the sum by distinct column for factor levels can be calculated by using aggregate(.~Group,data=df,sum)Example1 Live DemoConsider the below data frame −Group
The java.text.SimpleDateFormat class is used to format and parse a string to date and date to string.Parsing a date stringOne of the constructors of this class accepts a String value representing the desired date format and creates SimpleDateFormat object. To parse/convert a string as a Date objectInstantiate this class by passing desired format string.Parse the date string using the parse() method.ExampleLive Demoimport java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Sample { public static void main(String args[]) throws ParseException { String date_string = "2007-25-06"; //Instantiating the SimpleDateFormat class SimpleDateFormat formatter = ... Read More
Using the ConstructorThe java.sql.Date represents the date value in JDBC. The constructor of this class accepts a long value representing the desired date and creates respective Date object.Date(long date)You can create this object using this constructor.ExampleLive Demoimport java.text.ParseException; import java.text.SimpleDateFormat; public class Demo { public static void main(String args[]) throws ParseException { String str = "26-09-1989"; SimpleDateFormat obj = new SimpleDateFormat("dd-MM-yyyy"); long epoch = obj.parse(str).getTime(); System.out.println("Date value: "+epoch); //Creating java.util.Date object java.util.Date date = ... Read More
To create a dotchart using ggplot2 in R, we can use geom_dotplot function but the default gridlines will be in the output. If we want to remove the gridlines from the plot then theme function can be added in the rest of the command as theme(panel.grid=element_blank()).Example Live DemoConsider the below data frame −set.seed(214) x
JSE (Java Standard Edition)By using JavaSE you can develop stand-alone application ex: adobe reader, anti-virus, media players, etc. Java SE is also known as core java.lang: Language basics.util: Collection framework, events, data structure and other utility classes such as date.io: File operations, and other input and output operations.math: Multi precision arithmetics.nio: Non-blocking I/O framework for Java.net: Classes an API’s related to networking.security: This package provides classes and interfaces such as key generation, encryption, and decryption which belongs to the security framework.sql: Classes and interfaces for accessing/manipulating the data stored in databases and data sources.awt: Classes and interfaces to create GUI ... Read More