Saturday, July 2, 2022

Mean differences using R-script

 R-Programming

drive


Chapter 1: Download

link: https://youtu.be/cX532N_XLIs


Chapter 2:  Vectors
Vectors are the most basic R data objects and there are six types of atomic vectors. They are logical, integer, double, complex, character and raw.


A logical vector is a vector that only contains TRUE and FALSE values. In R, true values are designated with TRUE, and false values with FALSE. When you index a vector with a logical vector, R will return values of the vector for which the indexing vector is TRUE.
Logical : > 10>20
[1] FALSE

Vector manipulation
v1 <- c(3,8,4,5,0,11)
v2 <- c(4,11,0,8,1,2)
v1+v2, v1-v2, v1*v2, v1/v2

v <- c(3,8,4,5,0,11, -9, 304)

# Sort the elements of the vector.
sort.result <- sort(v)
print(sort.result)

# Sort the elements in the reverse order.
revsort.result <- sort(v, decreasing = TRUE)
print(revsort.result)

# Sorting character vectors.
v <- c("Red","Blue","yellow","violet")
sort.result <- sort(v)
print(sort.result)

# Sorting character vectors in reverse order.
revsort.result <- sort(v, decreasing = TRUE) 
print(revsort.result)

 Data frame 

BMI <- 	data.frame(
   gender = c("Male", "Male","Female"), 
   height = c(152, 171.5, 165), 
   weight = c(81,93, 78),
   Age = c(42,38,26)
)
print(BMI)

# Create a matrix.
M = matrix( c('a','a','b','c','b','a'), nrow = 2, ncol = 3, byrow = TRUE)
print(M)
Sequence

> a=seq(1,10, by=0.5)
> a
 [1]  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0  8.5  9.0  9.5 10.0
a=seq(10,1)

a=seq(10,1, by= -0.5)
> a
 [1] 10.0  9.5  9.0  8.5  8.0  7.5  7.0  6.5  6.0  5.5  5.0  4.5  4.0  3.5  3.0  2.5  2.0  1.5  1.0

stacked bar

A stacked bar graph (or stacked bar chart) is a chart that uses bars to show comparisons between categories of data, but with ability to break down and compare parts of a whole. Each bar in the chart represents a whole, and segments in the bar represent different parts or categories of that whole





  • Descriptive statistics summarizes or describes the characteristics of a data set.
  • Descriptive statistics consists of two basic categories of measures: measures of central tendency and measures of variability (or spread).
  • Measures of central tendency describe the center of a data set.
  • Measures of variability or spread describe the dispersion of data within the set.

Types of Descriptive Statistics

All descriptive statistics are either measures of central tendency or measures of variability, also known as measures of dispersion.

Central Tendency

Measures of central tendency focus on the average or middle values of data sets, whereas measures of variability focus on the dispersion of data. These two measures use graphs, tables and general discussions to help people understand the meaning of the analyzed data.

Measures of central tendency describe the center position of a distribution for a data set. A person analyzes the frequency of each data point in the distribution and describes it using the mean, median, or mode, which measures the most common patterns of the analyzed data set.

Measures of Variability

Measures of variability (or the measures of spread) aid in analyzing how dispersed the distribution is for a set of data. For example, while the measures of central tendency may give a person the average of a data set, it does not describe how the data is distributed within the set.

So while the average of the data maybe 65 out of 100, there can still be data points at both 1 and 100. Measures of variability help communicate this by describing the shape and spread of the data set. Range, quartiles, absolute deviation, and variance are all examples of measures of variability.

Consider the following data set: 5, 19, 24, 62, 91, 100. The range of that data set is 95, which is calculated by subtracting the lowest number (5) in the data set from the highest (100).



 provides a wide range of functions for obtaining summary statistics. One method of obtaining descriptive statistics is to use the sapply( ) function with a specified summary statistic.

# get means for variables in data frame mydata
# excluding missing values
sapply(mydata, mean, na.rm=TRUE)

Possible functions used in sapply include mean, sd, var, min, max, median, range, and quantile.


The t.test( ) function produces a variety of t-tests. Unlike most statistical packages, the default assumes unequal variance and applies the Welsh df modification.# independent 2-group t-test
t.test(y~x) # where y is numeric and x is a binary factor

# independent 2-group t-test
t.test(y1,y2) # where y1 and y2 are numeric

# paired t-test
t.test(y1,y2,paired=TRUE) # where y1 & y2 are numeric

# one sample t-test
t.test(y,mu=3) # Ho: mu=3

You can use the var.equal = TRUE option to specify equal variances and a pooled variance estimate. You can use the alternative="less" or alternative="greater" option to specify a one tailed test.



t-test

  • A t-test is a type of inferential statistic used to determine if there is a significant difference between the means of two groups, which may be related in certain features.
  • The t-test is one of many tests used for the purpose of hypothesis testing in statistics.
  • Calculating a t-test requires three key data values. They include the difference between the mean values from each data set (called the mean difference), the standard deviation of each group, and the number of data values of each group.
  • There are several different types of t-test that can be performed depending on the data and type of analysis required.
The Shapiro–Wilk test is a test of normality in frequentist statistics. It was published in 1965 by Samuel Sanford Shapiro and Martin Wilk.

The independent-samples test can take one of three forms, depending on the structure of your data and the equality of their variances. The general form of the test is t. test(y1, y2, paired=FALSE) . By default, R assumes that the variances of y1 and y2 are unequal, thus defaulting to Welch's test.

A Shapiro-Wilk test is the test to check the normality of the data. The null hypothesis for Shapiro-Wilk test is that your data is normal, and if the p-value of the test if less than 0.05, then you reject the null hypothesis at 5% significance and conclude that your data is non-normal.

The Shapiro-Wilk’s test or Shapiro test is a normality test in frequentist statistics. The null hypothesis of Shapiro’s test is that the population is distributed normally. It is among the three tests for normality designed for detecting all kinds of departure from normality. If the value of p is equal to or less than 0.05, then the hypothesis of normality will be rejected by the Shapiro test. On failing, the test can state that the data will not fit the distribution normally with 95% confidence. However, on passing, the test can state that there exists no significant departure from normality. This test can be done very easily in R programming.

shapiro.test(x)
Here, we’ll describe how to create quantile-quantile plots in R. QQ plot (or quantile-quantile plot) draws the correlation between a given sample and the normal distribution. A 45-degree reference line is also plotted. QQ plots are used to visually check the normality of the data.
  • qqnorm(): produces a normal QQ plot of the variable
  • qqline(): adds a reference line
qqnorm(my_data$len, pch = 1, frame = FALSE)
qqline(my_data$len, col = "steelblue", lwd = 2)










A paired t-test is used when you survey one group of people twice with the same survey. This type of t-test can show you whether the mean (average) has changed between the first and second time they took the survey.
Data in two numeric vectors # ++++++++++++++++++++++++++ # Weight of the mice before treatment before <-c(200.1, 190.9, 192.7, 213, 241.4, 196.9, 172.2, 185.5, 205.2, 193.7) # Weight of the mice after treatment after <-c(392.9, 393.2, 345.1, 393, 434, 427.9, 422, 383.9, 392.3, 352.2) # Create a data frame my_data <- data.frame( group = rep(c("before", "after"), each = 10), weight = c(before, after)

>Compute t-test res <- t.test(weight ~ group, data = my_data, paired = TRUE) 
>res

A basic histogram can be created with the hist function. In order to add a normal curve or the density line you will need to create a density histogram setting prob = TRUE as argument.

# Sample data
set.seed(3)
x <- rnorm(200)

# Histogram
hist(x, prob = TRUE)

Basic histogram in R

Histogram with normal curve

Histogram with normal curve in R

If you want to overlay a normal curve over your histogram you will need to calculate it with the dnorm function based on a grid of values and the mean and standard deviation of the data. Then you can add it with lines.

# X-axis grid
x2 <- seq(min(x), max(x), length = 40)

# Normal curve
fun <- dnorm(x2, mean = mean(x), sd = sd(x))

# Histogram
hist(x, prob = TRUE, col = "white",
     ylim = c(0, max(fun)),
     main = "Histogram with normal curve")
lines(x2, fun, col = 2, lwd = 2)

Histogram with density line

If you prefer adding the density curve of the data you can make use of the density function as shown in the example below.

# Sample data
set.seed(3)
x <- rnorm(200)

# Histogram
hist(x, prob = TRUE, ylim = c(0, max(fun)),
     main = "Histogram with density curve")
lines(density(x), col = 4, lwd = 2)

Histogram with density line in R

Sponsor
Better Data Visualizations

A Guide for Scholars, Researchers, and Wonks

BUY ON AMAZON
Data Sketches

A journey of imagination, exploration, and beautiful data visualizations

BUY ON AMAZON
Storytelling with Data

A Data Visualization Guide for Business Professionals

BUY ON AMAZON
Data visualization

A practical introduction

BUY ON AMAZON

See also


Sunday, June 19, 2022

Web content writing

Lecture sessions 

Day 1

Immersive technology is an integration of virtual content with the physical environment in a way that allows the user to engage naturally with the blended reality.  In an immersive experience, the user accepts virtual elements of their environment as part of the whole, potentially becoming less conscious that those elements are not part of physical reality. 

Immersive learning

Immersive learning is a learning method which students being immersed into a virtual dialogue, the feeling of presence is used as an evidence of getting immersed. The virtual dialogue can be created by two ways, the usage of virtual technics, and the narrative like reading a book.

Types

There are two types of immersive experiences: one being when you are actually in a physical environment. The other type of experience is where you are shown around a real or imagined environment via desktop, tablet, mobile or via VR (Virtual Reality) headset.

Problems of traditional learning

Traditional classroom based learning techniques largely rely on auditory and written learning styles. Whether in an educational or work related training space, this has significant and widely recognised limitations. Every learner is unique and this is reflected on how they process and retain information. And for many, providing engaging and interactive content offers a more inclusive and accessible learning experience, especially for those that are predisposed to a visual and kinesthetic style of learning.


Immersive learning is a hugely effective way for many learners to develop their knowledge and skills. It provides artificial, digitally created content and environments that accurately replicates real life scenarios so that new skills and techniques can be learned and perfected. Learners aren’t simply passive spectators; they get to be active participants who directly influence outcomes. And what’s more, it offers a risk-free and safe space where learning can be repeated and success can be accurately measured. It’s practice-based learning where the sky is the limit.

Immersive technologies include:

virtual reality (VR) – a digital environment that replaces the user’s physical surroundings.

     Virtual reality is an artificial environment that is created with software and presented to the user in such a way that the user suspends belief and accepts it as a real environment. On a computer, virtual reality is primarily experienced through two of the five senses: sight and sound.It is a computer-generated simulation of an environment or 3-dimensional image where people can interact in a seemingly real or physical way.

Modern virtual reality headset displays are based on technology developed for smartphones including: gyroscopes and motion sensors for tracking head, body, and hand positions; small HD screens for stereoscopic displays; and small, lightweight and fast computer processors.


Using VR Tech, any learner understands complex scientific concepts with fun and ease, for example, when a student uses Virtual Reality to understand “Respiration System in a human body” the student will understand that while breathing, so many gaseous elements go inside the lungs and how the oxygen is filtered from the other elements and how it will bound with RCB. This RCB containing oxygen penetrates the cell membrane and breaks glucose, to produce water and carbon dioxide. During this process, energy is released, which is captured by the ATP molecule. All these explanations are in 3D & 360° which will help the student to remember it easily and then recall whenever required. The example I have discussed here is just a glimpse of our vast VR content Library.


Virtual Reality is used in education to enhance student engagement with their study. VR creates the real world around us. It can transform the way of education which is provided nowadays. It can be also used in industries, medical, security, military, Anti-terrorism, Traffic accidents awareness, Weather forecasting, etc.


Benefits of Virtual Reality in Education

Increase knowledge area

Active experience rather than just passive information

Helps to understand complex concepts, subjects, or theories

No distractions while the study

Boosts students creativity

Expands learners efficiency to gain knowledge

Increase Interest in boring subjects like science

Improve the understanding level of students

Improve teaching skills in teachers using VR by providing a deep level of knowledge.

Improving memory power by connecting feelings with education.

It takes very little time to understand very complex topics.

Get education as per the book syllabus with its connecting environment and practicals.

Fun, Virtual tour, and existing game-based education.

Improve a Student’s Imagination power.

================================================================


Augmented reality (AR) – digital content that is superimposed over a live stream of the physical environment.


How is augmented reality being used in business?


Today, business and enterprise use cases are the predominant reality applications for AR. Some key examples include:


Design and construction — Arguably the most common and fruitful application for AR today, designers are using augmented reality to see what hypothetical products (or structures) look like in real environments and to make virtual tweaks to existing products without ever laying a hand on them.


How do you design

Recent research has shown that images, colors, music, oversized portions, product novelty, price promotions and celebrities were the most memorable aspects of food advertisements.


Maintenance and repairs — AR technology can guide technicians through the steps of repairing, upgrading, and maintaining a wide range of products, ranging from industrial equipment to entire buildings. AR allows technicians to work on equipment without having to refer to printed manuals or websites, overlaying detailed instructions – often visual – atop the machinery itself.



Training and education — Businesses are using AR technology to provide an immersive experience when training employees, allowing them to more comprehensively visualize new products and concepts. Schools are following suit.

Healthcare — AR technology has made its way into the surgery room, with overlays showing the critical steps of an operation, patients' vital statistics, and more.

Retail — From virtual makeup to virtual changing rooms, businesses are using AR to give retail shoppers a revamped, modernized augmented reality experience when shopping.


Technology — Products like Splunk Augmented Reality bring AR to major utility companies to improve responses during power outages, and gain full visibility into the entirety of their data.


Marketing — AR concepts on packaging, point-of-sale materials, and even billboards give businesses a brand new — and much more memorable — way to interact directly with customers.

What are the components of an augmented reality system?


Augmented reality varies depending on implementation, but the most common components include the following, categorized by hardware and software.


These hardware components comprise the backbone of augmented reality. Some of these components might already be supported if you are engaging in AR with your smartphone (more in the following section):


Processor – Augmented reality requires significant processing power to create the imagery needed and place it in the proper location for it to appear to exist in a real-world environment. Processors may be incorporated in a mobile handset or embedded into a wearable device (more on this below).

Display – In AR, imagery is created and then populated on some form of display. This can take several forms, depending on the specific application. These include:


Mobile handheld device – The smartphone or tablet screen is arguably the most common way in which AR hologram imagery is viewed. A user points his or her phone’s camera at a point of interest, and the live video hologram generated by the camera lens is overlaid with AR information.

Wearable device – Smart glasses such as Google Glass, Vuzix Blade, and Solos Smart Glasses are all designed as standard eyeglasses that also contain a small display only visible to the wearer. The person wearing the augmented reality headset can see the real world by looking straight through the lenses of the goggles, while the embedded display provides an informational overlay. VR headsets are less common in AR environments because they do not allow the wearer to see the real world directly; instead, it has to be recreated in video and displayed on the built-in screen, which is otherwise opaque.

Automotive HUDs – HUDs, or heads-up displays, are systems that use your car’s windshield as a screen. A device projects an image – speed, directions, etc. – from the dashboard upwards onto the windshield. The driver sees the reflection of this imagery as it bounces off the glass like a mirror.

Others — Looking ahead, more futuristic devices like smart contact lenses and systems that can project an image directly onto the retina may become viable.

Camera – As the primary sensor required for AR to function, the camera feeds the live video to the processor, which detects key facets of the environment on which the AR data is overlaid. The camera itself does not process any of the digital information; it merely provides the video feed.

Other sensors – AR is often designed for motion, so additional sensor types are required for operation. These may include spatial sensors, such as accelerometers and digital compasses, which indicate the direction the camera is facing; GPS sensors, which track the user’s location in the world; microphones, which incorporate audio data into the simulation: and LiDaR, which uses lasers to measure exact distance.

Input devices – A user on the move is often not at liberty to type commands into a computer. As such, AR systems have been devised to work with numerous types of input technologies. Foremost is the mobile device touchscreen, providing a natural interaction if a phone or tablet is available. Other options include voice recognition technology, so users can control the system via speech, and gesture recognition systems, which typically translate the motion of the user’s hand into commands.

Several types of software algorithms are needed to enable augmented reality. Broadly, these include:


Image registration – Software that takes a photographic representation of one’s surroundings and uses that information to determine various real-world coordinates and objects within it. Image registration maps the real world and determines what is in the foreground vs. what is in the background, where one object ends and another begins, and points of interest as well as additional information.


3D rendering – With the real world mapped and categorized, the next step is overlaying the augmented reality information on top of it. The 3D renderer creates virtual objects and places them into the appropriate location within the live image. The programming language Augmented Reality Markup Language (ARML) is the current standard for setting the location and appearance of a virtual object.


Content management – Content management is a back-end technology incorporating a system that maintains a database of virtual objects and 3D models.


Interface – Whether it’s a video game or a technical management tool, the interface is the intermediary between the user and the video representation of the augmented reality environment.


Development toolkits – A variety of open source and proprietary technologies are used to give programmers a framework for building AR applications on the platform of their choice.


How does augmented reality work on mobile?


If you encounter an AR application today, it will probably be in the form of a mobile phone app: any smartphone owner has access to hundreds of AR applications on iPhone or Android mobile phones without the need for any additional hardware. All the core software capabilities needed to enable AR are built into the operating system.


In a typical use case, the AR user launches an application on his or her mobile phone or tablet. Most AR apps are fairly simple in design. The user just aims the mobile phone or device at a point of interest and waits for the application to populate the screen with additional context. This could be anything from walking directions to the identity of stars in the sky to dance steps.


=====================================================================


Mixed reality (MR) – an integration of virtual content and the real world environment that enables interaction among elements of both.


Holography – the creation of a 3D image in space that can be explored from all angles.


TelePresence – a form of robotic remote control in which a human operator has a sense of being in another location. The user could, for example, guide the robot through a party or an office, stopping and chatting with people throughout the environment.


Digital twin – a virtual replication of some real-world object that connects to the object for information so that it can display its current status. 


FPV drone flight –  use of an unmanned aerial vehicle (UAV) with a camera that wirelessly transmits video feed to goggles, a headset, a mobile device or another display so that the user has a first-person view (FPV) of the environment where the drone flies. 


================================


A digital learning strategy involves learning by using digital assets such as videos, online courses, blogs, podcasts, articles and so on. In order to stay current in a dynamic workplace, it is important to keep learning all the time. For businesses to survive the digital age, they need to understand why a digital learning strategy is crucial for success.


Having a variety of digital asset types considers all the different ways people prefer to learn. You may like to complete a multi-week online course, while someone else may prefer watching a TED-talk. IBM has found that participants learn 5 times more material in online learning courses using multimedia content than in traditional face to face courses. Online learning caters to the different styles of learners, be they visual, auditory or kinesthetic learners. Adult learners do not like to be lectured to. They want to be engaged with the learning content and even participate in the learning process.


Day 2 Web content writing 

Definition
Types
Tools
Medium

Definition:  Content writing is the process of writing, editing, and publishing content in a digital format. That content can include blog posts, video or podcast scripts, ebooks or whitepapers, press releases, product category descriptions, landing page or social media copy ... and more.

Content writing is the fine-crafted art and structural science of making content for digital media. The different types of content writing examples on the digital front include blogs, scriptwriting for videos, emailers, social media posts, whitepapers, etc. All of these are important for the digital growth of a brand.

What are content writing skills?

Content writing skills are the skills that enable you to write clear, consistent and relevant articles to deliver a captivating experience for the company's target audience. This encourages the audience to visit the company's website for some information. Here are a few content writing skills you may develop to be successful in this field:

Adaptability

Content writers can have their own style and tone for every assignment they write. Depending on the goal of the article, they may format their work to focus on providing relevant information to the audience. For example, if the purpose of the article is to enhance sales, the content may differ from if they were writing for a research blog. The ability to adapt helps writers learn and gain expertise in different styles of writing, which ultimately provides value.

Research

Performing research about the content enables the writers to add credibility to the article and also add value for the reader. You can refer to educational, government and other news outlets to improve the quality of information you share in your content. To maintain your credibility among the readers, it is important to provide relevant, well-researched and truthful content.

Originality

For writers, writing original content is very important regardless of the subject. They can perform their research and then use that knowledge in informative and interesting content for readers. If the websites provide original content, the readers consider it as a reliable and respected source of information.



Search engine optimisation (SEO)

As a writer, if you understand SEO, it can become easy to create content that is easy to find. They may adapt techniques to ensure their article gets a high ranking in the search engines. If the content appears in the top search, there are high chances it may reach the target audience. You can look at the rich snippet and other high-ranked articles on search engines to strengthen the value of your content.

Time management

Having good time-management skills enables you to plan your tasks to ensure articles are delivered in time and with good quality. This includes scheduling time for research, writing and editing. By identifying the hours you require to complete an average project, you can better manage your time to ensure a balanced workload. These skills also include your ability to identify and prioritise projects based on deadlines and their importance. You can speak to your manager about the time you need in order to complete one piece of work and accordingly set the deadlines.

Communication

Communication skills assist you in accurately conveying your message to the intended audience. Delivering clear information to readers is imperative for successful marketing strategies. Whether it is content for storytelling or a call-to-action following a sales pitch, proper communication skills for writers are imperative.

Editing

Effective editing skills are crucial for writers, increasing the value and quality of the content while reducing the number of revisions required. Read your content out loud to find typing errors, grammatical errors, redundancy and overused words. Then make revisions to refine the quality of your content.

Knowledge of social media

By understanding social media platforms, you know where to find story ideas for your content. Studying your company's existing posts helps you determine the content that resonated most with readers. Review your company's social media accounts to gather inspiration for future content to write and predict how well it may perform.

Technical

Having little technical knowledge is important for content writers. They may rely on technical skills such as computer literacy and using word processing and content management systems effectively. The ability to use and implement analytics tools and digital collaboration tools is also helpful to content writers.


What are content writing skills?

Content writing skills are the skills that enable you to write clear, consistent and relevant articles to deliver a captivating experience for the company's target audience. This encourages the audience to visit the company's website for some information. Here are a few content writing skills you may develop to be successful in this field:

Adaptability

Content writers can have their own style and tone for every assignment they write. Depending on the goal of the article, they may format their work to focus on providing relevant information to the audience. For example, if the purpose of the article is to enhance sales, the content may differ from if they were writing for a research blog. The ability to adapt helps writers learn and gain expertise in different styles of writing, which ultimately provides value.

Research

Performing research about the content enables the writers to add credibility to the article and also add value for the reader. You can refer to educational, government and other news outlets to improve the quality of information you share in your content. To maintain your credibility among the readers, it is important to provide relevant, well-researched and truthful content.

Originality

For writers, writing original content is very important regardless of the subject. They can perform their research and then use that knowledge in informative and interesting content for readers. If the websites provide original content, the readers consider it as a reliable and respected source of information.

How to highlight content writing skills

Below are some ways to highlight your writing skills on your resume and during the interview:

1. Include content writing skills on your resume

Make sure your resume talks about relevant content writing skills. You can review the mandatory qualifications mentioned in the job description and understand the content writing skills suitable for this role.

Example: The skills on your resume might look like below:

Technical skills

  • content management software

  • word processing software

  • web data analytics software

  • social media monitoring software

2. Mention content writing skills during the interview

During an interview, discuss your content writing skills similar to the following example:

"In the previous company, I used my organisational and communication skills to deliver high-quality content. In order to write content about the company's social media campaigns of their latest product launch, I collaborated with different teams to understand the idea and goal of the campaigns. This helped me write an appropriate article mentioning details about the purpose of the campaign and its outcome. I also earned praise from the higher management for completing the content in tight timelines and with minimal edits."