Useful R tricks Flashcards
To convert coded categorical data
filecall$columnname=
replace( fc$cn, fc$cn==categorycode, ‘varname’)
view all column data of a specific type
ColumnName$ColumnData
Create table of column data of specific variable type
table(ColumnName$ColumnData)
View the proportion of each data type in a column from table t
prop=prop.table(table name)
View the percent of each data type in a column of table t
percent=prop.table(table name)*100
Creating category names for pie charts
for pie(tablename, _____)
paste(c(“category1”,”cat2”,”cat3”), function for percent, “%”, sep=” “)
Combines data
Display graphic output in new window
add x11()
in the console or before the code
build a histogram
hist(columndata, parameters….)
histogram breaks function
hist(actor_age$Age,
breaks=10,
main=”“,….)
Changes the interval reported for data
The following command will show you the five-number summary and the mean value of the data
summary(actor_age$Age)
For the Mean:
mean(actor_age$Age)
For the Standard Deviation:
sd(actor_age$Age)
For the Variance:
var(actor_age$Age)
For the Median:
median(actor_age$Age)