R
What is R
R has a large number of fans not just in the Data Science and IT communities, but also in every discipline and sphere of the world. This is due to the fact that data is now used in almost every sector, and R has a twin benefit in that it is both a programming language and a statistical computing with graphics environment.
R was created by statisticians for the purpose of statistical analysis, and it is still the computer language of choice for most professionals who used to do statistical analysis. With only a few lines of code, R makes it simple to design complicated statistical models. R offers an incredible ecosystem of packages which makes our analysis very easy. These packages are strong, simple to use, and come with excellent documentation.
The following are the reasons why people chose R for data analysis.
-
- R is open source (Available free)
R is an open-source programming language, which means it’s completely free to use. We can install it on your PC for free which was released under the GNU (General Public License).
-
- R is compatible with any operating system (windows, mac, …)
- R has an extensive library for use.
R comes with a large library of built-in packages and functions to meet a variety of applications. Machine Learning, Statistical Modeling, Data Manipulation, Data Visualization, and Imputation are just a few of the unique packages available.
-
- Furthermore, because R is open-source, we can create our own package and contribute to the R community.
- R is extensively good for data visualization
R has some excellent packages for creating detailed visualizations like ggplot2, lattice, leaflet, plotly, and RGL, to name a few. With these packages, we can design high-quality graphs.
After all, R is one of the most versatile and efficient statistical tools, and it has growing its popularity and is used widely in different disciplines because it is capable of meeting any and all of the user’s requirements.
some R codes
http://bijaylalpradhan.com.np/wp-content/uploads/2022/05/cor_in_col.txt
Ratio Estimation code Ratio estimation code
hrs_std=c(2,9,5,5,3,7,1,8,6,2)
grd_exam=c(69,98,82,77,71,84,55,94,84,64)
fcm <- function(cormat, pmat) {
ut <- upper.tri(cormat)
data.frame(
row = rownames(cormat)[row(cormat)[ut]],
column = rownames(cormat)[col(cormat)[ut]],
cor =(cormat)[ut],
p = pmat[ut]
)}
keeping 4 graphics in one
attach(kidney)
par(mfrow=c(2,2))
barplot(Age)
pie(Sex)
hist(Height)
plot(Age,Height)
install.packages(“gridExtra”)
library(“gridExtra”)
plot11<-ggplot(kidney, aes(x=Age))+ geom_histogram(fill=”red”, color=”black”, binwidth = 10)
plot12<-ggplot(kidney, aes(Age,Height))+
geom_violin(col=”blue”, fill=”green”)+ ggtitle(“violine plot”)
plot13<-ggplot(data=kidney, aes( Height))+
geom_boxplot(color=”dark red”, fill=”light green”, alpha=0.5)
plot14<-ggplot(kidney, aes(x=Age))+ geom_density(fill=”blue”,alpha=0.5)
grid.arrange(plot11,plot12,plot13,plot14, ncol=2, nrow=2)