Please help my school assignment. Can't subset columns that don't exist.

I am struggling with some issues and I need help. I've been trying to transform a matrix of items into a new matrix where the select polytomous items will be converted into comparable dichotomous items with the same information using the command poly2dich {mirt}. I'm completely have no clue on what I've done wrong but I always get the same error message. Here is what I've done correctly so far;

> load("D:/Downloads/NEO_PIR-1.RData")
> table [1:36] <- NULL
> table [] <- 0
> Neuroticism <- table [,c ('I1', 'I6', 'I11', 'I16', 'I21', 'I26', 'I31', 'I36', 
+                         'I41', 'I46', 'I51', 'I56', 'I61', 'I66', 'I71', 'I76', 
+                         'I81', 'I86', 'I91', 'I96', 'I101', 'I106', 'I111', 'I116', 
+                         'I121', 'I126', 'I131', 'I136', 'I141', 'I146', 'I151', 
+                         'I156', 'I161', 'I166', 'I171', 'I176', 'I181', 'I186', 
+                         'I191', 'I196', 'I201', 'I206', 'I211', 'I216', 'I221', 
+                         'I226', 'I231', 'I236')]
> Extraversion <- table [,c('I2', 'I7', 'I12', 'I17', 'I22', 'I27', 'I32', 'I37', 
+                           'I42', 'I47', 'I52', 'I57', 'I62', 'I67', 'I72', 'I77', 
+                           'I82', 'I87', 'I92', 'I97', 'I102', 'I107', 'I112', 
+                           'I117', 'I122', 'I127', 'I132', 'I137', 'I142', 'I147', 
+                           'I152', 'I157', 'I162', 'I167', 'I172', 'I177', 'I182', 
+                           'I187', 'I192', 'I197', 'I202', 'I207', 'I212', 'I217', 
+                           'I222', 'I227', 'I232', 'I237')]
> Openness <- table [,c('I3', 'I8', 'I13', 'I18', 'I23', 'I28', 'I33', 'I38', 
+                       'I43', 'I48', 'I53', 'I58', 'I63', 'I68', 'I73', 'I78', 
+                       'I83', 'I88', 'I93', 'I98', 'I103', 'I108', 'I113', 'I118', 
+                       'I123', 'I128', 'I133', 'I138', 'I143', 'I148', 'I153', 
+                       'I158', 'I163', 'I168', 'I173', 'I178', 'I183', 'I188', 
+                       'I193', 'I198', 'I203', 'I208', 'I213', 'I218', 'I223', 
+                       'I228', 'I233', 'I238')]
> Agreeableness <- table [,c('I4', 'I9', 'I14', 'I19', 'I24', 'I29', 'I34', 'I39', 
+                            'I44', 'I49', 'I54', 'I59', 'I64', 'I69', 'I74', 'I79', 
+                            'I84', 'I89', 'I94', 'I99', 'I104', 'I109', 'I114', 
+                            'I119', 'I124', 'I129', 'I134', 'I139', 'I144', 'I149', 
+                            'I154', 'I159', 'I164', 'I169', 'I174', 'I179', 'I184', 
+                            'I189', 'I194', 'I196', 'I204', 'I209', 'I214', 'I219', 
+                            'I224', 'I229', 'I234', 'I239')]
> Conscientiousness <- table [,c('I5', 'I10', 'I15', 'I20', 'I25', 'I30', 'I35', 
+                               'I40', 'I45', 'I50', 'I55', 'I60', 'I65', 'I70', 
+                               'I75', 'I80', 'I85', 'I90', 'I95', 'I100', 'I105', 
+                               'I110', 'I115', 'I120', 'I125', 'I130', 'I135', 
+                               'I140', 'I145', 'I150', 'I155', 'I160', 'I165', 
+                               'I170', 'I175', 'I180', 'I185', 'I190', 'I195', 
+                               'I200', 'I205', 'I210', 'I215', 'I220', 'I225', 
+                               'I230', 'I235', 'I240')]

The error shows up after I'm trying to apply this command;

> NewNeuroticism <- poly2dich(Neuroticism)
Error: Can't subset columns that don't exist.
x Locations 4, 2, 5, and 3 don't exist.
i There are only 1 column.

Please help. I'm totally out of my elements. Thank you.

Hi and welcome to the forum!

The error message suggests that there is something wrong with the data you supplying ( Neuroticism) , but since we don't have your project file, we can't really see what might cause the error. Could you post a representative subset of your data, for example the output of dput(head(Neuroticism)), so that we can to reproduce your problem?

Just for completeness, here is a link to the forums homework policy so you can make sure that you are following all the guidelines there . More importantly, they also contain a bunch of links that explain how to ask your questions in the best way.

Thank you for the welcome!

Yesterday I redone everything from scratch and I'm not sure what I did different that time but the problem was gone and now I can continue my assignment :sweat_smile: