R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

getwd()
## [1] "C:/Users/tmazza/Documents"
setwd( "C:/Users/tmazza/Documents")
mydata <-read.csv("customer_segmentation.csv")
str(mydata) 
## 'data.frame':    22 obs. of  15 variables:
##  $ ID            : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ CS_helpful    : int  2 1 2 3 2 1 2 1 1 1 ...
##  $ Recommend     : int  2 2 1 3 1 1 1 1 1 1 ...
##  $ Come_again    : int  2 1 1 2 3 3 1 1 1 1 ...
##  $ All_Products  : int  2 1 1 4 5 2 2 2 2 1 ...
##  $ Profesionalism: int  2 1 1 1 2 1 2 1 2 1 ...
##  $ Limitation    : int  2 1 2 2 1 1 1 2 1 1 ...
##  $ Online_grocery: int  2 2 3 3 2 1 2 1 2 3 ...
##  $ delivery      : int  3 3 3 3 3 2 2 1 1 2 ...
##  $ Pick_up       : int  4 3 2 2 1 1 2 2 3 2 ...
##  $ Find_items    : int  1 1 1 2 2 1 1 2 1 1 ...
##  $ other_shops   : int  2 2 3 2 3 4 1 4 1 1 ...
##  $ Gender        : int  1 1 1 1 2 1 1 1 2 2 ...
##  $ Age           : int  2 2 2 3 4 2 2 2 2 2 ...
##  $ Education     : int  2 2 2 5 2 5 3 2 1 2 ...
summary(lm( CS_helpful ~Recommend + factor(Gender), data=mydata))
## 
## Call:
## lm(formula = CS_helpful ~ Recommend + factor(Gender), data = mydata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.9430 -0.3896 -0.3896  0.5873  1.5178 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)      0.83610    0.34202   2.445   0.0244 *
## Recommend        0.55344    0.22696   2.438   0.0247 *
## factor(Gender)2  0.09264    0.32181   0.288   0.7766  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6722 on 19 degrees of freedom
## Multiple R-squared:  0.2415, Adjusted R-squared:  0.1617 
## F-statistic: 3.025 on 2 and 19 DF,  p-value: 0.07233
summary(lm(Come_again ~All_Products + factor(Gender) + Education + Age, data=mydata))
## 
## Call:
## lm(formula = Come_again ~ All_Products + factor(Gender) + Education + 
##     Age, data = mydata)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.94705 -0.36457 -0.09811  0.11407  1.52052 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)      0.78986    0.58475   1.351    0.194
## All_Products     0.23378    0.15512   1.507    0.150
## factor(Gender)2  0.54960    0.37342   1.472    0.159
## Education        0.08345    0.10871   0.768    0.453
## Age             -0.09759    0.24310  -0.401    0.693
## 
## Residual standard error: 0.7171 on 17 degrees of freedom
## Multiple R-squared:  0.2369, Adjusted R-squared:  0.0573 
## F-statistic: 1.319 on 4 and 17 DF,  p-value: 0.3028

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.