![]() ![]() To generate random samples from a variety of distributions #experiment with the magic code from Paul Murrell to do fancy graphic location Layout(mat) #specify where multiple graphs go on the page Pdf(height=6, width=6) #create a pdf file for outputĭev.of() #close the pdf file created with pdf X= recordPlot() #save the current plot device output in the object xĭev.control #various control functions for printing/saving graphic files Plot(table(x)) #plot the frequencies of levels in x #not standard R, but in the psych package Pairs.panels () #SPLOM on lower off diagonal, histograms on diagonal, correlations on diagonal ![]() Identify(eatar,eanta,labels=labels(energysR) ) #dynamically puts names on the plots ![]() Points(mPA,mNA,pch=symb,cex=4.5,col=colors,bg=colors) Plot(PA,NAF,pch=symb,col=colors,bg=colors,cex=1.5,main="Postive vs. Par(mfrow=c(1,1)) #change the graph window back to one figure Title( "some title") #add a title to the first graph Mtext("some global title",3,outer=TRUE,line=1,cex=1.5) #note that we seem to need to add the global title lastīoxplot(x,main="title") #boxplot (box and whiskers) Par(omi=c(0,0,1,0) ) #set the size of the outer margins Par(ask=TRUE) #ask for user input before drawing a new graph Par(mfrow=c(nrow,mcol)) #number of rows and columns to graph Z=apply(x,1,which.min) #tells the row with the minimum value for every column ) #applies the function (FUN) to either rows (1) or columns (2) on object XĪpply(x,1,min) #finds the minimum for each rowĪpply(x,2,max) #finds the maximum for each columnĬol.max(x) #another way to find which column has the maximum value for each row ) #finds row sums for each level of a grouping variableĪpply(X, MARGIN, FUN. Princomp() (see principal in the psych package) Solve(A,B) #inverse of A * B (may be used for linear regression)įactanal() (see also fa in the psych package) More statistics: Regression, the linear model, factor analysis and principal components analysis (PCA) Power = NULL, type = c("two.sample", "one.sample", "paired"),Īlternative = c("two.sided", "one.sided"),strict = FALSE) Power.t.test(n = NULL, delta = NULL, sd = 1, sig.level = 0.05, Within.var = NULL, sig.level = 0.05, power = NULL) (groups = NULL, n = NULL, between.var = NULL, Lm(x~y,data=dataset) #basic linear model where x and y can be matrices (see plot.lm for plotting options) Print(model.tables(aov.ex1,"means"),digits=3) #report the means and the number of subjects/cellīoxplot(DV~IV,data=data.ex1) #graphical summary appears in graphics window Scale(data,scale=FALSE) #centers around the mean but does not scale by the sd)Ĭumsum(x,na=rm=TRUE) #cumulative sum, etc.Ĭor(x,y,use="pair") #correlation matrix for pairwise complete data, use="complete" for complete casesĪov(x~y,data=datafile) #where x and y can be matricesĪov.ex1 = aov(DV~IV,data=data.ex1) #do the analysis of variance orĪov.ex2 = aov(DV~IV1*IV21,data=data.ex2) #do a two way analysis of variance Table(x) #frequency counts of entries, ideally the entries are factors(although it works with integers or even reals) Mad(x, na.rm=TRUE) #(median absolute deviation)įivenum(x, na.rm=TRUE) #Tukey fivenumbers min, lowerhinge, median, upper hinge, max Var(x, na.rm=TRUE) #produces the variance covariance matrix Max(x, na.rm=TRUE) #Find the maximum value in the vector x, exclude missing values Y%in%x #tests each element of y for membership in xĪll(x%in%y) #true if x is a proper subset of yĪll(x) # for a vector of logical values, are they all true?Īny(x) #for a vector of logical values, is at least one true? X%in%y #tests each element of x for membership in y Transform(data.df,variable names = some operation) #can be part of a set up for a data set ![]() Read.table(filename,header=TRUE,sep=',') #read csv filesįloor(x) #vector x of largest interger < xĪs.integer(x) #truncates real x to integers (compare to round(x,0)Īs.integer(x < cutpoint) #vector x of 0 if less than cutpoint, 1 if greater than cutpoint)įactor(ifelse(a < cutpoint, "Neg", "Pos")) #is another way to dichotomize and to make a factor for analysis Read.table(filename,header=TRUE) #read a tab or space delimited file See the R-reference card by Tom Short for a much more complete list. Unfortunately, knowing what to ask for help about is the hardest problem. For all of these commands, using the help(function) or ? function is the most useful source of information. See the relevant part of the guide for better examples. A short list of the most useful R commandsĪ summary of the most important commands with minimal examples. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |