How To Use Pnorm In R
How to use pnorm function on data frame columns in R?
The pnorm function is used to notice the probability for a ordinarily distributed random variable. Probabilities such as less than mean, greater than mean, or probability betwixt left- and right-manus side of the mean. If nosotros want to utilize pnorm office on information frame columns and then apply office can help united states.
Consider the below data frame −
Example
Live Demo
x1<-rnorm(20,5,0.35) x2<-rnorm(20,5,0.67) x3<-rnorm(20,v,0.04) df1<-data.frame(x1,x2,x3) df1
Output
x1 x2 x3 ane 4.556392 v.973934 5.018973 ii 5.217397 4.932053 4.975870 iii 5.426464 4.932799 4.962231 four four.930645 five.297919 5.017925 5 4.773804 4.768619 four.943131 half-dozen 4.963782 4.569909 iv.950701 7 4.925481 v.329717 4.985630 eight iv.940240 five.871122 5.007031 nine 4.904643 5.270739 five.022102 x 4.652542 five.784937 5.005462 xi 5.089297 4.479673 iv.961000 12 five.619575 4.181733 4.983067 13 4.696906 iv.451156 4.931908 14 5.177524 iv.422826 five.052467 fifteen 5.186783 v.184310 v.015104 xvi 4.497172 5.241887 iv.996715 17 4.689212 5.252937 5.035001 18 five.385772 4.095684 5.035014 19 five.455497 5.142272 v.021073 xx 5.417301 five.025720 v.005374
Applying pnorm on columns in df1 −
Example
apply(df1,2,role(x) pnorm(10,mean=mean(x),sd=sd(x)))
Output
x1 x2 x3 [1,] 0.07616627 0.96450889 0.75138999 [2,] 0.72115750 0.44156102 0.27056837 [iii,] 0.88960525 0.44211276 0.15403922 [four,] 0.38629544 0.70493965 0.74135388 [5,] 0.22132609 0.32516348 0.05581552 [6,] 0.42550072 0.20448316 0.08623025 [7,] 0.38027932 0.72516490 0.37486428 [8,] 0.39754810 0.94661794 0.62607863 [9,] 0.35630529 0.68712704 0.78009609 [10,] 0.12759048 0.92666438 0.60816173 [11,] 0.57741133 0.15991056 0.14545675 [12,] 0.96515143 0.06018775 0.34616630 [13,] 0.15806523 0.14725726 0.02700442 [14,] 0.67888286 0.13536904 0.95364621 [15,] 0.68893707 0.62769115 0.71330952 [16,] 0.05346986 0.66772918 0.50508628 [17,] 0.15246286 0.67521495 0.87668128 [18,] 0.86438253 0.04322155 0.87676402 [19,] 0.90541682 0.59753060 0.77087289 [20,] 0.88424194 0.51137989 0.60714737
Example
Live Demo
y1<-rpois(twenty,five) y2<-rpois(20,2) y3<-rpois(20,two) y4<-rpois(xx,5) y5<-rpois(20,10) df2<-data.frame(y1,y2,y3,y4,y5) df2
Output
y1 y2 y3 y4 y5 1 vii four 3 iii 10 2 vii 2 2 5 6 three 2 i four 4 11 4 v one 2 6 13 five 6 two 3 nine 10 6 vii 4 4 four 7 7 five 3 2 7 fifteen 8 ii i ane 3 15 9 3 1 2 4 9 x 4 3 1 four xv 11 1 4 iv 4 13 12 5 6 4 8 9 xiii iii 0 five 2 fourteen 14 vii 2 one 8 7 xv 6 3 4 five x sixteen three 2 two 6 xix 17 four ane 5 5 eleven 18 7 2 one five 11 19 half dozen i 2 nine nine xx iii 3 4 3 ix
Applying pnorm on columns in df2 −
Instance
use(df2,2,function(x) pnorm(x,hateful=mean(x),sd=sd(x)))
Output
y1 y2 y3 y4 y5 [1,] 0.88543697 0.87874297 0.55840970 0.14362005 0.36298572 [ii,] 0.88543697 0.41829947 0.27834877 0.46146443 0.05825608 [3,] 0.08752759 0.18573275 0.81101173 0.28079874 0.48176830 [4,] 0.57107536 0.18573275 0.27834877 0.65061458 0.71356535 [5,] 0.75517414 0.41829947 0.55840970 0.96698029 0.36298572 [6,] 0.88543697 0.87874297 0.81101173 0.28079874 0.10296979 [vii,] 0.57107536 0.68482707 0.27834877 0.80804251 0.87967779 [viii,] 0.08752759 0.18573275 0.09300983 0.14362005 0.87967779 [9,] 0.19922632 0.18573275 0.27834877 0.28079874 0.25614928 [10,] 0.36970390 0.68482707 0.09300983 0.28079874 0.87967779 [eleven,] 0.03088880 0.87874297 0.81101173 0.28079874 0.71356535 [12,] 0.57107536 0.99451570 0.81101173 0.91220051 0.25614928 [thirteen,] 0.19922632 0.05691416 0.94698775 0.06082067 0.80746817 [fourteen,] 0.88543697 0.41829947 0.09300983 0.91220051 0.10296979 [15,] 0.75517414 0.68482707 0.81101173 0.46146443 0.36298572 [sixteen,] 0.19922632 0.41829947 0.27834877 0.65061458 0.99163233 [17,] 0.36970390 0.18573275 0.94698775 0.46146443 0.48176830 [18,] 0.88543697 0.41829947 0.09300983 0.46146443 0.48176830 [19,] 0.75517414 0.18573275 0.27834877 0.96698029 0.25614928 [twenty,] 0.19922632 0.68482707 0.81101173 0.14362005 0.25614928
Published on 10-Feb-2021 06:21:36
- Related Questions & Answers
- How to select data frame columns based on their class in R?
- How to subset row values based on columns name in R data frame?
- How to standardize columns in an R data frame?
- How to standardize selected columns in R data frame?
- How to add name to information frame columns in R?
- How to reorder the columns in an R data frame?
- How to subset factor columns in an R data frame?
- How to concatenate numerical columns in an R data frame?
- How to create scatterplot using data frame columns in R?
- How to apply a manually created function to two columns in an R data frame?
- How to create a subset of an R data frame based on multiple columns?
- How to standardize columns if some columns are categorical in R data frame?
- How to subset rows based on criterion of multiple numerical columns in R data frame?
- Find the hateful of multiple columns based on multiple grouping columns in R information frame.
- How to employ 1 sample t-test on all columns of an R information frame?
How To Use Pnorm In R,
Source: https://www.tutorialspoint.com/how-to-use-pnorm-function-on-data-frame-columns-in-r
Posted by: hertzogdair1985.blogspot.com
0 Response to "How To Use Pnorm In R"
Post a Comment