Hello everyone,
I have a R code which I run it once, the second time I want to run it, I receive the error which one column could not be found.
This is the code:
dat <- read.csv2("donnees/donneesOdeurs_400180_202310013.csv") %>%
dplyr::select(Traitement:P5)
and this is the error:
rlang::last_trace()
<error/vctrs_error_subscript_oob>
Error in dplyr::select()
:
! Can't select columns that don't exist.
Column Traitement
doesn't exist.
is there anyone could help me?
startz
March 21, 2024, 3:13pm
2
Could you show us
glimpse(read.csv2("donnees/donneesOdeurs_400180_202310013.csv"))
Hi @azinzand , this said that the Traitement
doesn't exist in the data frame dat
. So, you need to check the correct names of the data frame.
names(dat) # You get col names and next try your script.
but it does really exist as you can see in the image below:
but it does really exist as you can see in the image below:
prubin
March 21, 2024, 4:31pm
6
But column P5 does not exist. Are you sure this is the file it loads on the first run? Does the code change the file?
I changed P5 to P4, but still received the same error
startz
March 21, 2024, 6:40pm
8
I can see why you're puzzled. Maybe post a few rows of the csv file here, as text not as a picture.
startz
March 21, 2024, 7:51pm
10
Works perfectly for me...which I realize is not very helpful.
M_AcostaCH:
names(dat)
Hello everyone, it seems I found the problem with this code. it can only read up to P2 in a line and shift the rest of columns in another line. do you have any idea to modify it in my csv file or in R studio?
startz
March 26, 2024, 2:31pm
12
This suggests that there is something funky with the file, like an end-of-line where it doesn't belong. What happens if you read it into Excel? If it reads in properly, you might save a copy from Excel and try to load that copy into R.
Could I ask how many rows the table has? And are the contents publicly shareable, or are they private or proprietary in nature?
system
Closed
April 16, 2024, 8:45pm
15
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.