I'm trying to declare the following variable as a list of patient ID's to use for further analysis:
id = c("patientID1", "patientID2", ...)
I have a list of about 5000 patient ID's I need to do this for, so I used a comma separated list generator. The minimal working example given in this Stack post works, but when I try it for all of my patient ID's it doesn't seem to work. Importantly, when I tried the minimal working example in the Stack post (it worked), I did type it out manually rather than using the column to list converter.
Any ideas here? Is there another way that I should be making the comma separated list in R from an excel column to make sure that it works? Why is R giving me the + sign anyways? The brackets are closed.
Typically the first row of a CSV is a header and users to name the column that will be made from the following rows beneath it. any read CSV function would support that. Also you can rename columns later.
How do I import the .csv column in a format that would be precisely in the same form as the c() function, as in id <- c("4428814_4428814", "3490518_3490518", "3094358_3094358"), rather than the list that read.csv() gives?
The data_rs146217251 comes from a main dataset called data which has a bunch of different genetic data. The g= information comes from a different file that I loaded from a .bgen file using the rbgen package (it's allele dosage data), but that's unrelated.
I tried id <- read.csv(file.choose(), header=T) using the .csv file with the list of patient ID's, but then as soon as I ran > filtered <- data_rs146217251[id,] it gave me the error Error in data_rs146217251[id, ] : invalid subscript type 'list'.
So that's why I'd prefer a way that I could just load the column from the .csv in a way that replicates the same vectorized form that's given by
> id <- c("4428814_4428814", "3490518_3490518", "3094358_3094358")
> id
[1] "4428814_4428814" "3490518_3490518"
[3] "3094358_3094358"