Skip to contents

Displaying a grid

Whenever the name of the variable containing a grid object is typed to the console it is printed. Several datasets are already included in the OpenRepGrid package and are available once the package is loaded. Two of them are bell2010 and fbb2003. Type one of these variable names to the console andthe grid will be printed.

bell2010
# 
# RATINGS:
#              A teacher you respected - 5 6 - Mother (or the person who fill     
#     A person of the opposite sex t - 4 | | 7 - A person of the opposite sex t   
#   the unhappiest person you know - 3 | | | | 8 - The most confident person you  
# closest friend of the same sex - 2 | | | | | | 9 - A person you work well with (
#                         self - 1 | | | | | | | | 10 - A teacher you did not resp
#                                | | | | | | | | | |                              
#                  relaxed (1)   4 4 6 5 3 6 5 2 2 6   (1) worried & tense        
#  so smart (academically) (2)   6 7 6 5 7 4 6 7 4 7   (2) smart (academically)   
#          dislikes sports (3)   6 3 7 6 4 4 2 3 6 3   (3) loves sports           
#          not interactive (4)   6 7 5 6 6 5 6 7 7 4   (4) loves people           
#          not transparent (5)   6 4 5 7 3 7 6 5 6 3   (5) transparent            
#              insensitive (6)   4 6 5 4 4 6 5 3 4 2   (6) sensitive              
#            fearful&timid (7)   5 4 4 6 5 3 5 6 5 5   (7) fearless               
#                    rough (8)   5 6 6 4 5 7 7 3 5 6   (8) gentle                 
#          accept as it is (9)   5 5 6 7 4 4 6 7 5 5   (9) loves to argue      

Usually it is convenient to name an object the way you like to. You can save the grids in any variable you like. To save the grid in the variable x type

x <- bell2010

If you now type x to the console the same grid will be printed.

x
# 
# RATINGS:
#              A teacher you respected - 5 6 - Mother (or the person who fill     
#     A person of the opposite sex t - 4 | | 7 - A person of the opposite sex t   
#   the unhappiest person you know - 3 | | | | 8 - The most confident person you  
# closest friend of the same sex - 2 | | | | | | 9 - A person you work well with (
#                         self - 1 | | | | | | | | 10 - A teacher you did not resp
#                                | | | | | | | | | |                              
#                  relaxed (1)   4 4 6 5 3 6 5 2 2 6   (1) worried & tense        
#  so smart (academically) (2)   6 7 6 5 7 4 6 7 4 7   (2) smart (academically)   
#          dislikes sports (3)   6 3 7 6 4 4 2 3 6 3   (3) loves sports           
#          not interactive (4)   6 7 5 6 6 5 6 7 7 4   (4) loves people           
#          not transparent (5)   6 4 5 7 3 7 6 5 6 3   (5) transparent            
#              insensitive (6)   4 6 5 4 4 6 5 3 4 2   (6) sensitive              
#            fearful&timid (7)   5 4 4 6 5 3 5 6 5 5   (7) fearless               
#                    rough (8)   5 6 6 4 5 7 7 3 5 6   (8) gentle                 
#          accept as it is (9)   5 5 6 7 4 4 6 7 5 5   (9) loves to argue      

Extract a subset of the grid

One of the most powerful operators for repgrid objects is the [ (extract) function. It can be used to access parts of the data and reorder rows and columns. It is applied in the same way as for other R objects (cf. R docu, or type ?Extract to the console). Within the squared brackets the index of the rows (constructs) and/or columns (elements) is supplied determining the order or subset of a grid. E.g. in order to extract the first three rows and first four elements of the bell2010 data use. This will produce a 3x4 subset of the grid you may save to a new object.

bell2010[1:3, 1:4]
# 
# RATINGS:
# closest friend of the same sex - 2 3 - the unhappiest person you kno
#                         self - 1 | | 4 - A person of the opposite se
#                                | | | |                              
#                  relaxed (1)   4 4 6 5   (1) worried & tense        
#  so smart (academically) (2)   6 7 6 5   (2) smart (academically)   
#          dislikes sports (3)   6 3 7 6   (3) loves sports        

Delete elements and/or constructs

Negative indexes indicate that a row and/or column is to be deleted. In order to delete the first construct row (line 1) and the first two elements (line 2) respectively type

bell2010[-1, ]
bell2010[, -c(1, 2)]

Reorder a grid

The brackets function can also be used to reorder a grid. To reverse the order of the constructs type

bell2010[9:1, ]
# 
# RATINGS:
#              A teacher you respected - 5 6 - Mother (or the person who fill     
#     A person of the opposite sex t - 4 | | 7 - A person of the opposite sex t   
#   the unhappiest person you know - 3 | | | | 8 - The most confident person you  
# closest friend of the same sex - 2 | | | | | | 9 - A person you work well with (
#                         self - 1 | | | | | | | | 10 - A teacher you did not resp
#                                | | | | | | | | | |                              
#          accept as it is (1)   5 5 6 7 4 4 6 7 5 5   (1) loves to argue         
#                    rough (2)   5 6 6 4 5 7 7 3 5 6   (2) gentle                 
#            fearful&timid (3)   5 4 4 6 5 3 5 6 5 5   (3) fearless               
#              insensitive (4)   4 6 5 4 4 6 5 3 4 2   (4) sensitive              
#          not transparent (5)   6 4 5 7 3 7 6 5 6 3   (5) transparent            
#          not interactive (6)   6 7 5 6 6 5 6 7 7 4   (6) loves people           
#          dislikes sports (7)   6 3 7 6 4 4 2 3 6 3   (7) loves sports           
#  so smart (academically) (8)   6 7 6 5 7 4 6 7 4 7   (8) smart (academically)   
#                  relaxed (9)   4 4 6 5 3 6 5 2 2 6   (9) worried & tense     

Likewise we can rearrange the order of the elements. In order to facilitate a comparison between the elements self, unhappiest person you know and mother (elements 1, 3 and 6) we may want to rearrange them next to each other.

bell2010[, c(1, 3, 6, 2, 4, 5, 7:10)]
# 
# RATINGS:
#       A person of the opposite sex t - 5 6 - A teacher you respected            
#     closest friend of the same sex - 4 | | 7 - A person of the opposite sex t   
#   Mother (or the person who fill - 3 | | | | 8 - The most confident person you  
# the unhappiest person you know - 2 | | | | | | 9 - A person you work well with (
#                         self - 1 | | | | | | | | 10 - A teacher you did not resp
#                                | | | | | | | | | |                              
#                  relaxed (1)   4 6 6 4 5 3 5 2 2 6   (1) worried & tense        
#  so smart (academically) (2)   6 6 4 7 5 7 6 7 4 7   (2) smart (academically)   
#          dislikes sports (3)   6 7 4 3 6 4 2 3 6 3   (3) loves sports           
#          not interactive (4)   6 5 5 7 6 6 6 7 7 4   (4) loves people           
#          not transparent (5)   6 5 7 4 7 3 6 5 6 3   (5) transparent            
#              insensitive (6)   4 5 6 6 4 4 5 3 4 2   (6) sensitive              
#            fearful&timid (7)   5 4 3 4 6 5 5 6 5 5   (7) fearless               
#                    rough (8)   5 6 7 6 4 5 7 3 5 6   (8) gentle                 
#          accept as it is (9)   5 6 4 5 7 4 6 7 5 5   (9) loves to argue      

Moving elements and constructs

Several tasks concerning reordering will be used repeatedly, like e. g. moving a construct upwards. While the extract function can fulfill this task, the code quickly becomes tedious. Hence, specialized functions are available for standard actions. E.g. to move construct 2 upwards the following two lines of code are equivalent.

bell2010[c(2, 1, 3:9), ]
up(bell2010, 2)

The following table lists several functions that provide a shortcut for standard operations.

Function Description
up() Move construct upwards
down() Move construct downwards
left() Move element to the left
right() Move element to the right
swapConstructs() Swap two constructs
swapElements() Swap two elements
shift() Move all constructs (elements) a number of rows (columns)

Swapping poles

Due to the bipolar nature of constructs the direction of a construct is arbitrary. Hence, the poles can also be swapped without affecting the grid information itself. To reflect one or more constructs the function swapPoles can be used. The following code will reflect the constructs one to three.

swapPoles(bell2010, 1:3)

Change Ratings

To change single ratings of elements on constructs also the extract function can be used. In this context, the square brackets are used to determine the part of the grid that is assigned new scores. To change the rating in cell (1,1) of the dataset bell2010 to 1 type

bell2010[1, 1] <- 1

Likewise, new scores can be assigned to a number of cells in the grid, to whole rows, to whole columns or to the entire grid. The following code gives some examples.

x <- bell2010[1:4, 1:5] # subset of the Bell2010 data set with four rows and five columns
x[1:3, 1] <- c(1, 4, 3) # rows 1 to 3 in column 1
x[1, c(1, 4)] <- c(2, 2) # columns 1 and 4 in row 1
x[1, ] <- c(2, 2, 1, 4, 3) # all columns in row one
x[, 1] <- c(2, 2, 1, 4) # all rows in column one
x[, ] <- c(
  1, 2, 3, 4, # whole grid column wise
  1, 2, 3, 4,
  1, 2, 3, 4,
  1, 2, 3, 4,
  1, 2, 3, 4
)

Modify element and construct names

A grid object contains information about the element and construct labels, their abbreviations, their status (e.g. ideal element or preferred pole). All the information contained in a grid object can be manipulated via the functions setConstructAttr and setElelemntAttr. To e.g. change the construct labels provide the row and the new pole labels to the function.

setConstructAttr(boeker, 1, "new left pole", "new right pole")
# 
# RATINGS:
#                                          8 - martin                          
#                               george - 7 | 9 - elizabeth                     
#                               karl - 6 | | | 10 - therapist                  
#                             kurt - 5 | | | | | 11 - irene                    
#                         father - 4 | | | | | | | 12 - childhood self         
#                       mother - 3 | | | | | | | | | 13 - self before illness  
#                 ideal self - 2 | | | | | | | | | | | 14 - self with delusion 
#                     self - 1 | | | | | | | | | | | | | 15 - self as dreamer  
#                            | | | | | | | | | | | | | | |                     
#        new left pole (1)   1 4 2 2 3 5 2 5 4 2 6 2 2 3 3   (1) new right pole
#             isolated (2)   3 6 3 5 5 4 5 4 5 4 4 4 2 2 3   (2) sociable      
#   closely integrated (3)   2 2 2 3 5 3 2 3 2 3 3 4 4 5 3   (3) excluded      
#           discursive (4)   4 1 3 1 2 4 2 3 3 2 3 3 3 5 4   (4) passive       
#          open minded (5)   2 1 2 1 2 4 4 2 4 2 6 3 2 2 3   (5) indifferent   
#               dreamy (6)   4 5 3 5 4 5 4 5 4 4 6 3 3 3 2   (6) dispassionate 
# practically oriented (7)   2 1 3 2 3 3 3 2 2 3 2 3 3 3 3   (7) depressed     
#              playful (8)   4 5 4 3 4 3 2 3 4 4 5 3 2 4 3   (8) serious       
#      socially minded (9)   2 1 3 2 4 5 4 1 3 2 6 3 3 3 3   (9) selfish       
#         quarrelsome (10)   5 5 5 5 5 2 5 2 4 4 1 6 5 5 5   (10) peaceful     
#            artistic (11)   5 1 2 4 3 5 3 2 4 3 3 4 4 4 4   (11) technical    
#          scientific (12)   2 1 5 3 4 4 5 3 4 1 6 4 2 3 3   (12) emotional    
#           introvert (13)   4 5 4 6 5 3 5 3 5 2 5 2 2 2 3   (13) extrovert    
#          wanderlust (14)   1 1 4 2 4 5 2 5 5 3 6 1 1 2 1   (14) home oriented

To change element the label of the first element, proceed likewise.

setElementAttr(boeker, 1, "new name")
# 
# RATINGS:
#                                          8 - martin                                   
#                               george - 7 | 9 - elizabeth                              
#                               karl - 6 | | | 10 - therapist                           
#                             kurt - 5 | | | | | 11 - irene                             
#                         father - 4 | | | | | | | 12 - childhood self                  
#                       mother - 3 | | | | | | | | | 13 - self before illness           
#                 ideal self - 2 | | | | | | | | | | | 14 - self with delusion          
#                 new name - 1 | | | | | | | | | | | | | 15 - self as dreamer           
#                            | | | | | | | | | | | | | | |                              
#             balanced (1)   1 4 2 2 3 5 2 5 4 2 6 2 2 3 3   (1) get along with conflict
#             isolated (2)   3 6 3 5 5 4 5 4 5 4 4 4 2 2 3   (2) sociable               
#   closely integrated (3)   2 2 2 3 5 3 2 3 2 3 3 4 4 5 3   (3) excluded               
#           discursive (4)   4 1 3 1 2 4 2 3 3 2 3 3 3 5 4   (4) passive                
#          open minded (5)   2 1 2 1 2 4 4 2 4 2 6 3 2 2 3   (5) indifferent            
#               dreamy (6)   4 5 3 5 4 5 4 5 4 4 6 3 3 3 2   (6) dispassionate          
# practically oriented (7)   2 1 3 2 3 3 3 2 2 3 2 3 3 3 3   (7) depressed              
#              playful (8)   4 5 4 3 4 3 2 3 4 4 5 3 2 4 3   (8) serious                
#      socially minded (9)   2 1 3 2 4 5 4 1 3 2 6 3 3 3 3   (9) selfish                
#         quarrelsome (10)   5 5 5 5 5 2 5 2 4 4 1 6 5 5 5   (10) peaceful              
#            artistic (11)   5 1 2 4 3 5 3 2 4 3 3 4 4 4 4   (11) technical             
#          scientific (12)   2 1 5 3 4 4 5 3 4 1 6 4 2 3 3   (12) emotional             
#           introvert (13)   4 5 4 6 5 3 5 3 5 2 5 2 2 2 3   (13) extrovert             
#          wanderlust (14)   1 1 4 2 4 5 2 5 5 3 6 1 1 2 1   (14) home oriented         

Add elements and constructs

Sometimes it is necessary to add an element or a construct. This can be achieved by modifying the input file itself. Another option is to use the functions addConstruct and addElement. The following call will add a construct and the corresponding ratings to the bell2010 dataset. The left and right pole are labeled “left pole” and “right pole” respectively.

addConstruct(bell2010, "left pole", "pole right", c(3, 1, 3, 2, 5, 4, 6, 3, 7, 1))
# 
# RATINGS:
#              A teacher you respected - 5 6 - Mother (or the person who fill     
#     A person of the opposite sex t - 4 | | 7 - A person of the opposite sex t   
#   the unhappiest person you know - 3 | | | | 8 - The most confident person you  
# closest friend of the same sex - 2 | | | | | | 9 - A person you work well with (
#                         self - 1 | | | | | | | | 10 - A teacher you did not resp
#                                | | | | | | | | | |                              
#                  relaxed (1)   1 4 6 5 3 6 5 2 2 6   (1) worried & tense        
#  so smart (academically) (2)   6 7 6 5 7 4 6 7 4 7   (2) smart (academically)   
#          dislikes sports (3)   6 3 7 6 4 4 2 3 6 3   (3) loves sports           
#          not interactive (4)   6 7 5 6 6 5 6 7 7 4   (4) loves people           
#          not transparent (5)   6 4 5 7 3 7 6 5 6 3   (5) transparent            
#              insensitive (6)   4 6 5 4 4 6 5 3 4 2   (6) sensitive              
#            fearful&timid (7)   5 4 4 6 5 3 5 6 5 5   (7) fearless               
#                    rough (8)   5 6 6 4 5 7 7 3 5 6   (8) gentle                 
#          accept as it is (9)   5 5 6 7 4 4 6 7 5 5   (9) loves to argue         
#               left pole (10)   3 1 3 2 5 4 6 3 7 1   (10) pole right         

The following code will add an element with the label “new element” to the dataset.

addElement(bell2010, "new element", c(1, 2, 5, 4, 3, 6, 5, 2, 7))
# 
# RATINGS:
#                                          6 - Mother (or the person who fill       
#              A teacher you respected - 5 | 7 - A person of the opposite sex t     
#     A person of the opposite sex t - 4 | | | 8 - The most confident person you    
#   the unhappiest person you know - 3 | | | | | 9 - A person you work well with (a 
# closest friend of the same sex - 2 | | | | | | | 10 - A teacher you did not respec
#                         self - 1 | | | | | | | | | 11 - new element               
#                                | | | | | | | | | | |                              
#                  relaxed (1)   1 4 6 5 3 6 5 2 2 6 1   (1) worried & tense        
#  so smart (academically) (2)   6 7 6 5 7 4 6 7 4 7 2   (2) smart (academically)   
#          dislikes sports (3)   6 3 7 6 4 4 2 3 6 3 5   (3) loves sports           
#          not interactive (4)   6 7 5 6 6 5 6 7 7 4 4   (4) loves people           
#          not transparent (5)   6 4 5 7 3 7 6 5 6 3 3   (5) transparent            
#              insensitive (6)   4 6 5 4 4 6 5 3 4 2 6   (6) sensitive              
#            fearful&timid (7)   5 4 4 6 5 3 5 6 5 5 5   (7) fearless               
#                    rough (8)   5 6 6 4 5 7 7 3 5 6 2   (8) gentle                 
#          accept as it is (9)   5 5 6 7 4 4 6 7 5 5 7   (9) loves to argue      

Defining a grid manually

The import functions make use of internal functions to construct a grid from scratch using the imported data. It is also possible to call these functions manually, an option advanced users may consider. The most convenient way is to use the function makeRepGrid. First a list of arguments (args) containing the elements and constructs names and the rating scores is created. This list is supplied to the function makeRepGrid. Note that the scale range has to be set using setScale, in order to draw the grid properly. Usually it will be more convenient to create a grid via the .txt import function.

args <- list(
  name = c("element 1", "element 2", "element 3", "element 4", "element 5"),
  l.name = c("left pole 1", "left pole 2", "left pole 3", "left pole 4"),
  r.name = c("right pole 1", "right pole 2", "right pole3 ", "right pole 4"),
  scores = c(
    4, 4, 6, 5, 1,
    2, 7, 6, 5, 2,
    6, 3, 1, 6, 4,
    6, 7, 5, 6, 3
  )
)
newGrid <- makeRepgrid(args)
newGrid <- setScale(newGrid, 1, 7)
newGrid
# 
# RATINGS:
#                       3 - element 3           
#         element 2 - 2 | 4 - element 4         
#       element 1 - 1 | | | 5 - element 5       
#                   | | | | |                   
# left pole 1 (1)   4 4 6 5 1   (1) right pole 1
# left pole 2 (2)   2 7 6 5 2   (2) right pole 2
# left pole 3 (3)   6 3 1 6 4   (3) right pole3 
# left pole 4 (4)   6 7 5 6 3   (4) right pole 4