N X P matriced data; N row and P colum, N observations with P variables
Char and String and Numerical variable
if you type
c("something","Hello")
it generates the Char values
Subset Function
Just like logical function of MATLAB, it can substract the subset from the dataset and make it into specific(another) dataset
subset
Capital Letters
R specifies the capital letters different from the lower letters
Read and Load
Getwd()
get working directory file that we are using
setwd()
set the directory addresses
Intro to practically use the R for analysis
Assigning variables
"<-" and "=" are a little different, "<-" is preferred since the "=" has multiple meanings.(e.g. maybe logical equations?)
Packages
To use the package, firstly,install it by using command
install.packages(_"psych"_)
And load the package into working environment by
library(psych)
Load the data file
".csv" files are commonly used. It's short for "comma seperated values" files.
e.g. spreadsheets, Google Sheets, Microsoft Excel etc....
Give the data frames a useul name e.g. data1, RegDat1 ...
in here, the header means whether you want to take the very first row to the variable names(True, T) or not (False, F)
Also, if you want to treat the categorical variables(e.g. Gender(female, male)) as the binomial, you can set it by
stringsAsFactors = True(or T)
Indexing and modifying the data elements from file
d[10,23]
It indexes the date element in 10th column and 23rd row
() specifies dataset and [] specifies which column you want to change it to a specific variable name
Various useful functions
summary(dat1)
: getting the basic descriptives from data file "dat1"
View(dat1)
it makes able to read data file "dat1" in FANCY data frame on console. ( if you just type dat1 in console, it literally will Print dat1 on console
colnames(dat1)[1] or dat1$State, you can index the the 1st column of data file dat1 or Varialbe named State in data file dat1
Manipulating Data
If we want to deselect, get rid of certain variables from dat1, we can use variable methods. Two are basics.
Hierarchical regression(: Adding new predictors in model to see if "Do XX factors predicting XX beyond XX factor?"/this is a technique to see if a variable adds incremental variance for predicting an outcome)
use the variables from the interaction of interest
high E and N is associated with high unemployment; high E and low N is associated with low unemployment
N is not related to unemployment when E is low
we can plot it with Neuroticism as the moderator too. Theory must lead the way here
Basic
Questions&Help
type
Data composition
N X P matriced data; N row and P colum, N observations with P variables
Char and String and Numerical variable
if you type
it generates the Char values
Subset Function
Just like logical function of MATLAB, it can substract the subset from the dataset and make it into specific(another) dataset
Capital Letters
R specifies the capital letters different from the lower letters
Read and Load
get working directory file that we are using
set the directory addresses
Intro to practically use the R for analysis
Assigning variables
"<-" and "=" are a little different, "<-" is preferred since the "=" has multiple meanings.(e.g. maybe logical equations?)
Packages
To use the package, firstly,install it by using command
And load the package into working environment by
Load the data file
".csv" files are commonly used. It's short for "comma seperated values" files. e.g. spreadsheets, Google Sheets, Microsoft Excel etc.... Give the data frames a useul name e.g. data1, RegDat1 ...
in here, the header means whether you want to take the very first row to the variable names(True, T) or not (False, F) Also, if you want to treat the categorical variables(e.g. Gender(female, male)) as the binomial, you can set it by
Indexing and modifying the data elements from file
It indexes the date element in 10th column and 23rd row
() specifies dataset and [] specifies which column you want to change it to a specific variable name
Various useful functions
: getting the basic descriptives from data file "dat1"
it makes able to read data file "dat1" in FANCY data frame on console. ( if you just type dat1 in console, it literally will Print dat1 on console colnames(dat1)[1] or dat1$State, you can index the the 1st column of data file dat1 or Varialbe named State in data file dat1
Manipulating Data
If we want to deselect, get rid of certain variables from dat1, we can use variable methods. Two are basics.
OR Use codes like belows,
Plotting and Test Analysis
Correlation
: If you type it you can see what you've done to the corr_matrix and track the changes or variables you are using
Standardization
scale(datafile[
T-test
Usually it require datasets to be kind of in line to each other(maybe dimensions?) OR Other ways to do it with using variables neames
ANOVA
you can put even models in X and Y
Regression
Plotting Interaction
use the variables from the interaction of interest high E and N is associated with high unemployment; high E and low N is associated with low unemployment N is not related to unemployment when E is low we can plot it with Neuroticism as the moderator too. Theory must lead the way here