Useful R tricks Flashcards

1
Q

To convert coded categorical data

A

filecall$columnname=

replace( fc$cn, fc$cn==categorycode, ‘varname’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

view all column data of a specific type

A

ColumnName$ColumnData

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create table of column data of specific variable type

A

table(ColumnName$ColumnData)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

View the proportion of each data type in a column from table t

A

prop=prop.table(table name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

View the percent of each data type in a column of table t

A

percent=prop.table(table name)*100

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Creating category names for pie charts

A

for pie(tablename, _____)

paste(c(“category1”,”cat2”,”cat3”), function for percent, “%”, sep=” “)

Combines data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Display graphic output in new window

A

add x11()

in the console or before the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

build a histogram

A

hist(columndata, parameters….)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

histogram breaks function

A

hist(actor_age$Age,
breaks=10,

main=”“,….)

Changes the interval reported for data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The following command will show you the five-number summary and the mean value of the data

A

summary(actor_age$Age)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

For the Mean:

A

mean(actor_age$Age)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

For the Standard Deviation:

A

sd(actor_age$Age)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

For the Variance:

A

var(actor_age$Age)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

For the Median:

A

median(actor_age$Age)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

For the Inter-quartile range:

A

IQR(actor_age$Age)

17
Q

For the Minimum:

A

min(actor_age$Age)

18
Q

For the Maximum:

A

max(actor_age$Age)

19
Q

For the Sample Size (n):

A

length(actor_age$Age)

20
Q

For the First Quartile (25th percentile, Q1):

A

quantile(actor_age$Age, 0.25)

21
Q

For the Third Quartile (75th percentile, Q3):

A

quantile(actor_age$Age, 0.75)