Too many values in one argument case_when? - r

I am not sure why this code doesnt run. But if it breaks it into 2 smaller chunks then it works. Is there anyway i can run this whole chunk at once?
When I run this code it appears the plus sign in the console and I couldnt click run in R markdown
dataT4<- dataT4 %>% mutate (coupleID=case_when(id==10011~1, id==10021~2,
id==10032~3, id==10041~4,id==10062~5, id==10071~6,id==10082~7, id==10092~8,
id==10112~9, id==10121~10,id== 10131~11, id==10142~12, id==10151~13,
id==10162~14,id==10171~15, id==10181~16, id==10202~17, id==10212~18, id==10221~19,
id==10232~20, id==10242~21, id==10251~22, id==10262~23, id==10271~24, id==10292~25,
id==10311~26, id==10332~27, id==10342~28, id==10351~29, id==10361~30, id==10372~31,
id==10382~32, id==10391~33, id==10401~34, id==10412~35, id==10421~36, id==10432~37,
id==10442~38, id==10452~39, id==10461~40, id==10471~41, id==10481~42, id==10492~43,
id==10501~44, id==10511~45, id==10521~46, id==10532~47, id==10542~48, id==10562~49,
id==10581~50, id==10592~51, id==10602~52, id==10611~53, id==10642~54, id==10651~55,
id==10662~56, id==10672~57, id==10681~58, id==10702~59, id==10761~60, id==10782~61,
id==10791~62, id==10802~63, id==10812~64, id==10822~65, id==10831~66, id==10852~67,
id==10862~68, id==10881~69, id==10912~70, id==10942~71, id==10951~72, id==10962~73,
id==10972~74, id==10982~75, id==10992~76, id==11001~77, id==11031~78, id==11052~79,
id==11061~80, id==11072~81, id==11092~82, id==11101~83, id==11112~84, id==11171~85,
id==11192~86, id==11202~87, id==11221~88, id==11231~89, id==11252~90, id==11261~91,
id==11281~92, id==11292~93, id==11322~94, id==11332~95, id==11372~96, id==11382~97,
id==11391~98, id==11411~99, id==11422~100, id==11441~101, id==11461~102,
id==11471~103, id==11492~104, id==11501~105, id==11512~106,
id==11521~107,id==11562~108,id==11591~109, id==11601~110, id==11611~111,
id==11621~112, id==11632~113, id==11641~114, id==11651~115, id==11662~116,
id==11682~117,id==11691~118,id==11712~119, id==11771~120, id==11782~121,
id==11811~122, id==11821~123, id==11831~124, id==11841~125, id==11852~126,
id==11861~127,id==11872~128,id==11882~129, id==11892~130, id==11902~131,
id==11911~132, id==11922~133, id==11961~134, id==11972~135,
id==11992~136,id==12011~137, id==12041~138, id==12052~139, id==12061~140,
id==12081~141, id==12101~142, id==12111~143, id==12122~144, id==12131~145,
id==12142~146, id==12151~147, id==12161~148, id==12182~149, id==12191~150,
id==12201~151, id==12232~152, id==12261~153, id==12272~154, id==12322~155,
id==12332~156, id==12342~157, id==12352~158, id==12382~159, id==12392~160,
id==12401~161, id==12411~162, id==12421~163, id==12432~164, id==12441~165,
id==12451~166, id==12461~167, id==12471~168, id==12492~169, id==12501~170,
id==12512~171, id==12521~172, id==12542~173, id==12552~174, id==12562~175,
id==12572~176, id==12581~177, id==12612~178, id==12622~179, id==12652~180,
id==12662~181, id==12682~182, id==12701~183, id==12712~184, id==12731~185,
id==12741~186, id==12762~187, id==12792~188, id==12802~189, id==12811~190,
id==12822~191, id==12832~192, id==12841~193, id==12862~194, id==12882~195,
id==12891~196, id==12911~197, id==12931~198, id==12942~199, id==12952~200,
id==12961~201, id==12972~202, id==13011~203, id==13021~204, id==13032~205,
id==13042~206, id==13061~207, id==13082~208, id==13102~209, id==13111~210,
id==13132~211, id==13142~212, id==13151~213, id==13162~214, id==13191~215,
id==13202~216, id==13212~217, id==13262~218, id==13271~219, id==13281~220,
id==13311~221, id==13322~222, id==13331~223, id==13351~224, id==13361~225,
id==13372~226, id==13422~227, id==13432~228, id==13452~229, id==13462~230,
id==13472~231, id==13481~232, id==13501~233, id==13511~234, id==13521~235,
id==13561~236, id==13571~237, id==13601~238, id==13612~239, id==13632~240,
id==13642~241, id==13652~242, id==13662~243, id==13671~244, id==13681~245,
id==13691~246, id==13701~247, id==13711~248, id==13732~249, id==13742~250,
id==13752~251, id==13782~252, id==13842~253, id==13802~254, id==13822~255,
id==13851~256, id==13872~257, id==13882~258, id==13892~259, id==13912~260,
id==13921~261, id==13932~262, id==13941~263, id==13952~264, id==13971~265,
id==13981~266, id==13992~267, id==14011~268, id==14021~269, id==14031~270,
id==14041~271, id==14052~272, id==14072~273, id==14111~274, id==14131~275,
id==14162~276, id==14172~277, id==14182~278, id==14191~279, id==14212~280,
id==14222~281, id==14241~282, id==14261~283, id==14291~284, id==14302~285,
id==14312~286, id==14321~287, id==14342~288, id==14352~289, id==14362~290,
id==14371~291, id==14392~292, id==14402~293, id==14432~294, id==14451~295,
id==14472~296, id==14482~297, id==14491~298, id==14511~299, id==14521~300,
id==14531~301, id==14541~302, id==14552~303, id==14562~304, id==14572~305,
id==14581~306, id==14592~307, id==14602~308, id==14621~309, id==14632~310,
id==14641~311, id==14651~312, id==14671~313, id==14681~314, id==14692~315,
id==14712~316, id==14722~317, id==14732~318, id==14741~319, id==14751~320,
id==14781~321, id==14792~322, id==14812~323, id==14842~324, id==14852~325,
id==14862~326, id==14882~327, id==14892~328, id==14901~329, id==11012~330))

As a single line it is just too long to be parsed. You may be better served putting all of these values into a separate data.frame and merging it into your data instead of using a giant case_when.
Usually when I want to do something like this I'll open Excel or something similar, put column names in the first row (here that would be id and couple_id) and enter all of the values, save it as a CSV, then read the CSV into R as a data.frame, and then merge it.

You can use rank:
dataT4 <- data.frame(id=c(10011, 10021, 10382, 11012))
dataT4 <- dataT4 %>% mutate (coupleID=rank(id))
dataT4
id coupleID
1 10011 1
2 10021 2
3 10382 3
4 11012 4
Data:
dataT4 <- data.frame(id=c(10011, 10021, 10382, 11012))

Related

R Conditional Filling of Value based on Test of Existing Value

In brief, I have a large dataframe (~750,000 rows) most of which have a NA value in the "Age" field. I want to assign the values held in the "AcutalAge" and "InterpAge" field where the "Age" field is empty (prioritizing the "ActualAge" field first). The code snippet below is not working. Any thoughts? All of the fields are ints ranging from 0 to 150 or so.
for (r in seq_len(nrow(TreeData))){
if (is.na(TreeData[r,"Age"])){
TreeData[r,"Age"] <- TreeData[r,"ActualAge"]
}
# use InterpAge field if not a sample age tree or ActualAge tree
if (is.na(TreeData[r,"Age"])){
TreeData[r,"Age"] <- TreeData[r,"InterpAge"]
}
}
Sample Data:
"","Stand_ID","Plot_ID","StandPlot_ID","Tree_ID","District","PlotNumber","DBH","Ht","TreeStatus","Remeasurement","CrRatio","Species","Abbrev","b1","b2","b3","b4","b5","Age","Elevation","Slope","Latitude","Longitude","InterpAge","ActualSpec","ActualCD","ActualSite","ActualAge","DomSpec","Inv_Year","Disturbance","Treatment"
"1","D10P112103","R0","D10P112103R0",59,10,112103,0.551181390613437,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"2","D10P112103","R0","D10P112103R0",58,10,112103,0.472441218773127,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"3","D10P112103","R0","D10P112103R0",30,10,112103,0.433071109386563,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"4","D10P112103","R0","D10P112103R0",7,10,112103,0.748031890613437,7.54593184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"5","D10P112103","R0","D10P112103R0",41,10,112103,0.5905515,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"6","D10P112103","R0","D10P112103R0",17,10,112103,0.472441218773127,5.24934407822132,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"7","D10P112103","R0","D10P112103R0",20,10,112103,0.157480402346641,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"8","D10P112103","R0","D10P112103R0",67,10,112103,0.354330890613437,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"9","D10P112103","R0","D10P112103R0",47,10,112103,0.393701,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"10","D10P112103","R0","D10P112103R0",16,10,112103,0.472441218773127,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"11","D10P112103","R0","D10P112103R0",57,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"12","D10P112103","R0","D10P112103R0",49,10,112103,0.669291718773127,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"13","D10P112103","R0","D10P112103R0",62,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"14","D10P112103","R0","D10P112103R0",36,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"15","D10P112103","R0","D10P112103R0",53,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"16","D10P112103","R0","D10P112103R0",15,10,112103,0.354330890613437,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"17","D10P112103","R0","D10P112103R0",63,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"18","D10P112103","R0","D10P112103R0",43,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"19","D10P112103","R0","D10P112103R0",4,10,112103,0.472441218773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"20","D10P112103","R0","D10P112103R0",79,10,112103,0.433071109386563,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"21","D10P112103","R0","D10P112103R0",66,10,112103,0.236220609386563,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"22","D10P112103","R0","D10P112103R0",28,10,112103,0.472441218773127,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"23","D10P112103","R0","D10P112103R0",34,10,112103,0.118110304693282,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"24","D10P112103","R0","D10P112103R0",46,10,112103,0.236220609386563,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"25","D10P112103","R0","D10P112103R0",21,10,112103,0.669291718773127,6.23359592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"26","D10P112103","R0","D10P112103R0",81,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"27","D10P112103","R0","D10P112103R0",77,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"28","D10P112103","R0","D10P112103R0",64,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"29","D10P112103","R0","D10P112103R0",72,10,112103,0.472441218773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"30","D10P112103","R0","D10P112103R0",73,10,112103,0.354330890613437,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"31","D10P112103","R0","D10P112103R0",55,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"32","D10P112103","R0","D10P112103R0",32,10,112103,1.181103,8.53018368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"33","D10P112103","R0","D10P112103R0",13,10,112103,0.236220609386563,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"34","D10P112103","R0","D10P112103R0",12,10,112103,0.354330890613437,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"35","D10P112103","R0","D10P112103R0",70,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"36","D10P112103","R0","D10P112103R0",75,10,112103,0.708661781226873,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"37","D10P112103","R0","D10P112103R0",82,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"38","D10P112103","R0","D10P112103R0",40,10,112103,0.787402,7.54593184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"39","D10P112103","R0","D10P112103R0",52,10,112103,0.551181390613437,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"40","D10P112103","R0","D10P112103R0",23,10,112103,0.748031890613437,6.23359592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"41","D10P112103","R0","D10P112103R0",6,10,112103,0.314960804693282,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"42","D10P112103","R0","D10P112103R0",31,10,112103,0.314960804693282,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"43","D10P112103","R0","D10P112103R0",45,10,112103,0.393701,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"44","D10P112103","R0","D10P112103R0",35,10,112103,0.354330890613437,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"45","D10P112103","R0","D10P112103R0",38,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"46","D10P112103","R0","D10P112103R0",80,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"47","D10P112103","R0","D10P112103R0",5,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"48","D10P112103","R0","D10P112103R0",60,10,112103,0.472441218773127,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"49","D10P112103","R0","D10P112103R0",19,10,112103,0.748031890613437,6.88976368711472,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"50","D10P112103","R0","D10P112103R0",22,10,112103,0.866142218773127,7.87401631288528,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"51","D10P112103","R0","D10P112103R0",61,10,112103,0.354330890613437,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"52","D10P112103","R0","D10P112103R0",68,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"53","D10P112103","R0","D10P112103R0",33,10,112103,0.236220609386563,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"54","D10P112103","R0","D10P112103R0",76,10,112103,0.551181390613437,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"55","D10P112103","R0","D10P112103R0",3,10,112103,0.9842525,7.54593184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"56","D10P112103","R0","D10P112103R0",51,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"57","D10P112103","R0","D10P112103R0",27,10,112103,0.393701,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"58","D10P112103","R0","D10P112103R0",48,10,112103,0.511811281226873,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"59","D10P112103","R0","D10P112103R0",18,10,112103,0.275590695306718,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"60","D10P112103","R0","D10P112103R0",65,10,112103,0.905512281226873,7.21784815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"61","D10P112103","R0","D10P112103R0",14,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"62","D10P112103","R0","D10P112103R0",10,10,112103,0.669291718773127,7.21784815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"63","D10P112103","R0","D10P112103R0",25,10,112103,0.118110304693282,4.26509184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"64","D10P112103","R0","D10P112103R0",24,10,112103,0.393701,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"65","D10P112103","R0","D10P112103R0",74,10,112103,0.629921609386563,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"66","D10P112103","R0","D10P112103R0",42,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"67","D10P112103","R0","D10P112103R0",1,10,112103,2.755907,10.4986881564426,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"68","D10P112103","R0","D10P112103R0",39,10,112103,0.511811281226873,6.56168,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"69","D10P112103","R0","D10P112103R0",26,10,112103,0.433071109386563,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"70","D10P112103","R0","D10P112103R0",83,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"71","D10P112103","R0","D10P112103R0",56,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"72","D10P112103","R0","D10P112103R0",54,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"73","D10P112103","R0","D10P112103R0",71,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"74","D10P112103","R0","D10P112103R0",9,10,112103,0.433071109386563,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"75","D10P112103","R0","D10P112103R0",84,10,112103,0.669291718773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"76","D10P112103","R0","D10P112103R0",8,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"77","D10P112103","R0","D10P112103R0",11,10,112103,0.433071109386563,59.05512,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"78","D10P112103","R0","D10P112103R0",69,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"79","D10P112103","R0","D10P112103R0",50,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"80","D10P112103","R0","D10P112103R0",44,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"81","D10P112103","R0","D10P112103R0",2,10,112103,0.354330890613437,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"82","D10P112103","R0","D10P112103R0",78,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"83","D10P112103","R0","D10P112103R0",29,10,112103,0.0787402011733204,4.26509184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"84","D10P112103","R0","D10P112103R0",37,10,112103,0.393701,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"85","D10P112103","R1","D10P112103R1",33,10,112103,0.708661781226873,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"86","D10P112103","R1","D10P112103R1",48,10,112103,1.02362256245375,8.2021,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"87","D10P112103","R1","D10P112103R1",70,10,112103,0.748031890613437,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"88","D10P112103","R1","D10P112103R1",76,10,112103,1.06299271877313,7.87401631288528,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"89","D10P112103","R1","D10P112103R1",71,10,112103,0.629921609386563,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"90","D10P112103","R1","D10P112103R1",72,10,112103,0.826772062453747,7.87401631288528,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"91","D10P112103","R1","D10P112103R1",7,10,112103,1.61417406245375,11.48294,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"92","D10P112103","R1","D10P112103R1",111,10,112103,0.551181390613437,6.23359592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"93","D10P112103","R1","D10P112103R1",114,10,112103,0.236220609386563,4.59317592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"94","D10P112103","R1","D10P112103R1",34,10,112103,0.629921609386563,6.23359592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"95","D10P112103","R1","D10P112103R1",74,10,112103,1.25984321877313,9.18635184355736,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"96","D10P112103","R1","D10P112103R1",42,10,112103,0.511811281226873,5.57742815644264,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"97","D10P112103","R1","D10P112103R1",102,10,112103,0.393701,5.57742815644264,0,1,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"98","D10P112103","R1","D10P112103R1",110,10,112103,0.472441218773127,5.57742815644264,0,1,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"99","D10P112103","R1","D10P112103R1",5,10,112103,0.629921609386563,8.2021,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"100","D10P112103","R1","D10P112103R1",10,10,112103,1.49606378122687,10.8267718435574,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,14,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
This worked like a charm (thanks #DennyChen):
setDT(TreeData)[is.na(Age), Age:= ActualAge]
setDT(TreeData)[is.na(Age), Age:= InterpAge]
According to the answer post by #UnsoughtNine :
After setDT(), the table TreeData had been changed to a data.table object.
There is no need to setDT() again in the secong line of code.
It can also work with combining %>% pipe operator in magrittr package :
setDT(TreeData)[is.na(Age), Age:= ActualAge] %>%
.[is.na(Age), Age:= InterpAge]

Error in R - more columns than column names

I am trying to read in a file that has 5 column headers, however in column 5 I have list of genes separated commas.
EC2 <- read.table("david.txt", header=TRUE)
Whenever I run the code below, I get the message
"more columns than column names."
I feel like the answer is probably simple. Any idea?
These are the first 3 lines:
Category ID Term PValue Genes
BP GO: 0006412 translation 2.711930356491234E-10 P0A7U3, P0A7K6, P68191, P0A7Q1, P0A7U7, P02359, P02358, P60438, P0A7L0, P0A7L3, P0A7L8, P0A7T3, P0A8A8, P69441, P0A8N5, P0A8N3, P02413, P0A7T7, P0AG63, P0A7D1, P0AA10 , P0ADY3, P0AG67, P0A7M2, P0A898, P0A9W3, P0A7M6, P0A7X3, P0AAR3, P0A7S3, P0A7S9, P0ADY7, P62399, P60624, P32132, P0ADZ4, P60723, P0C0U4, P0AG51, P0ADZ0, P0A7N9, P0A7J3, P0A7W7, P0AG59, P68679, P0C018 , P0A7R1, P0A7N4, P0A7R5, P0A7R9, P0AG44, P68919, P61175, P0A6K3, P0A7V0, P0A7M9, P0A7K2, P0A7V3, P0AG48
BP GO: 0051301 cell division 1.4011247561051483E-7 P0AC30, P17952, P75949, P0A6H1, P06966, P0A9R7, P64612, P36548, P60472, P45955, P0A855, P06136, P0A850, P6246, P0246, P024 P22523, P08373, P11880, P0AFB1, P60293, P18196, P0ABG4, P07026, P0A749, P29131, P0A6S5, P26648, P17443, P0ADS2, P0A8P6, P0A8P8, P0A6, P0A6A7, P0A8P8, P0A6, P0A6A7, P0A6, P0A6A7 P46889, P0A6F9, P0AE60, P0AD68, P19934, P0ABU9, P37773

Interpolating using approxm function goes wrong for one column

I have a data frame which contains three columns.
A|B|c
10|0|0
10|5|0
10|10|0
15|0|0
15|5|0
15|10|0
When I interpolate the above data frame:
df<-approxm(df,206,method="linear")
Here is the output:
A|B|c
10|0|0
10|1|0
10|2|0
10|3|0
10|4|0
10|5|0
10|6|0
10|7|0
10|8|0
10|9|0
10|10|0
11|8|0
12|6|0
13|4|0
14|2|0
15|0|0
15|1|0
15|2|0
15|3|0
15|4|0
15|5|0
15|6|0
15|7|0
15|8|0
15|9|0
15|10|0
Here in this output Column A with values 11,12,13 and 14 are not interpolated properly.
My Expected output is:
A|B|c
10|0|0
10|1|0
10|2|0
10|3|0
10|4|0
10|5|0
10|6|0
10|7|0
10|8|0
10|9|0
10|10|0
11|0|0
11|1|0
11|2|0
11|3|0
11|4|0
11|5|0
11|6|0
11|7|0
11|8|0
11|9|0
11|10|0
12|0|0
12|1|0
12|2|0
12|3|0
12|4|0
12|5|0
12|6|0
12|7|0
12|8|0
12|9|0
12|10|0
13|0|0
13|1|0
13|2|0
13|3|0
13|4|0
13|5|0
13|6|0
13|7|0
13|8|0
13|9|0
13|10|0
14|0|0
14|1|0
14|2|0
14|3|0
14|4|0
14|5|0
14|6|0
14|7|0
14|8|0
14|9|0
14|10|0
15|0|0
15|1|0
15|2|0
15|3|0
15|4|0
15|5|0
15|6|0
15|7|0
15|8|0
15|9|0
15|10|0
This is my expected output.
But I'm not getting this expected output.
I don't know where my code gets wrong.
Can someone help me out?
Complete function worked out.
tidyr::complete(df,A=full_seq(A,1),nesting(B=full_seq(B,1)),fill=list(c=0))

Combining many files with matching fields in particular column to a single file

So I have 128 files with two columns.
I want to match them by the values in the first column and add the values in the second column from each file to a single file.
I was able to kinda of find a solution here:
From: https://unix.stackexchange.com/questions/159961/merging-2-files-with-based-on-field-match
awk 'FNR==NR{a[$1]=$2;next} ($1 in a) {print $1,a[$1],$2}' file2 file1
It does what I want, however I need for this to go through every file in the folder.
Is there away to make this command loop through all the files in the folder or is there a better method all together?
Example:
Input
File 1:
gene_id normalized_count
A1BG|1 42.3332
A1CF|29974 165.6696
A2BP1|54715 0.0000
A2LD1|87769 138.1270
A2ML1|144568 2.7612
A2M|2 7310.6121
A4GALT|53947 348.3663
A4GNT|51146 0.0000
File 2:
gene_id normalized_count
A1BG|1 18.2019
A1CF|29974 129.6194
A2BP1|54715 2.2063
A2LD1|87769 65.3116
A2ML1|144568 0.0000
A2M|2 3415.8632
A4GALT|53947 83.2874
A4GNT|51146 0.0000
File 3:
gene_id normalized_count
A1BG|1 8.6285
A1CF|29974 97.6385
A2BP1|54715 0.0000
A2LD1|87769 200.5540
A2ML1|144568 0.0000
A2M|2 984.0736
A4GALT|53947 24.0690
A4GNT|51146 0.4541
Desired output
gene_id normalized_count
A1BG|1 42.3332 18.2019 8.6285
A1CF|29974 165.6696 129.6194 97.6385
A2BP1|54715 0 2.2063 0
A2LD1|87769 138.127 65.3116 200.554
A2ML1|144568 2.7612 0 0
A2M|2 7310.6121 3415.8632 984.0736
A4GALT|53947 348.3663 83.2874 24.069
A4GNT|51146 0 0 0.4541
For the desired output I don't care how the column labels end up looking.
Again my problem is that I have to do this for hundreds of files at once to produce one file.
Here are some other similar problems with solutions
https://unix.stackexchange.com/questions/122919/merge-2-files-based-on-all-values-of-the-first-column-of-the-first-file
https://unix.stackexchange.com/questions/113879/how-to-merge-two-files-with-different-number-of-rows-in-shell
But they only had to do this for a few files.
Edit: both Nathan's and joepd worked and produced similar output
Thank you!
Nathan's solution will produce output space delimited
joepd's will produce output that had the header (with original tab separated), and the first column separated by two spaces and the rest space delimited.
You will need gawk for this:
gawk '{a[$1]+=$2}; END{ for (i in a) print i, a[i]}' files*
If this does not work for you, please specify input and output.
EDIT
After your specification it becomes clear that you want to concatenate the strings. How about this?
awk '
NR==1 {title=$0}
FNR!=1 {a[$1] = a[$1]" "$2}
END {
print title
for (i in a)
print i, a[i]
}
' files*
This should produce the output you want with one more column in the output for each file in the input:
awk 'FNR>2{a[$1]=a[$1] " " $2}; END{ for (i in a) print i a[i]}' File*
It's structured like #joepd's answer which numerically sums the inputs instead of string concatenating them.
FNR>2 is used to ignore the header lines in each file.

Import data into R - argument is empty

I am trying to use a R package called GOSemSim, it requires to import a lot of data into variables with a specific format like this:
data1 = c("one", "two", "three")
data2 = c("A", "B", "C")
When the list of data that I try to import into a variable is longer than 293 then I get the following error message:
argument 293 is empty
THere are no error with the "" or comma, I computed it with linux, it does not matter what data it is.
This is really weird basically, I tried on two computers with no luck. I tried to import it as a CSV file but the R package won't allow it.
Anyone knows why you cannot import more than 293 data?
Update:
Here is the code and my data at the same time, it is a one liner in R which has never been a problem for me!
OQ = c("GO:0000003", "GO:0000070", "GO:0000077", "GO:0000079", "GO:0000082", "GO:0000086", "GO:0000122", "GO:0000212", "GO:0000226", "GO:0000278", "GO:0000279", "GO:0000280", "GO:0000724", "GO:0000725", "GO:0000819", "GO:0000910", "GO:0001932", "GO:0002118", "GO:0002121", "GO:0002165", "GO:0003002", "GO:0003006", "GO:0006022", "GO:0006030", "GO:0006040", "GO:0006139", "GO:0006259", "GO:0006260", "GO:0006261", "GO:0006267", "GO:0006270", "GO:0006275", "GO:0006277", "GO:0006281", "GO:0006302", "GO:0006304", "GO:0006305", "GO:0006306", "GO:0006310", "GO:0006323", "GO:0006325", "GO:0006342", "GO:0006351", "GO:0006355", "GO:0006357", "GO:0006366", "GO:0006464", "GO:0006468", "GO:0006479", "GO:0006725", "GO:0006807", "GO:0006928", "GO:0006950", "GO:0006974", "GO:0006996", "GO:0007010", "GO:0007017", "GO:0007018", "GO:0007049", "GO:0007051", "GO:0007059", "GO:0007062", "GO:0007067", "GO:0007076", "GO:0007088", "GO:0007093", "GO:0007095", "GO:0007098", "GO:0007126", "GO:0007127", "GO:0007131", "GO:0007140", "GO:0007141", "GO:0007143", "GO:0007154", "GO:0007155", "GO:0007156", "GO:0007259", "GO:0007266", "GO:0007275", "GO:0007276", "GO:0007281", "GO:0007282", "GO:0007292", "GO:0007304", "GO:0007307", "GO:0007346", "GO:0007350", "GO:0007365", "GO:0007367", "GO:0007379", "GO:0007389", "GO:0007399", "GO:0007400", "GO:0007417", "GO:0007420", "GO:0007423", "GO:0007444", "GO:0007472", "GO:0007476", "GO:0007552", "GO:0007560", "GO:0008104", "GO:0008213", "GO:0008283", "GO:0008284", "GO:0008315", "GO:0008356", "GO:0009059", "GO:0009611", "GO:0009653", "GO:0009790", "GO:0009791", "GO:0009880", "GO:0009886", "GO:0009887", "GO:0009888", "GO:0009889", "GO:0009890", "GO:0009892", "GO:0009893", "GO:0009896", "GO:0009968", "GO:0009987", "GO:0010032", "GO:0010033", "GO:0010092", "GO:0010389", "GO:0010468", "GO:0010498", "GO:0010556", "GO:0010558", "GO:0010564", "GO:0010604", "GO:0010605", "GO:0010608", "GO:0010629", "GO:0010648", "GO:0010948", "GO:0014016", "GO:0014017", "GO:0014070", "GO:0016043", "GO:0016055", "GO:0016070", "GO:0016310", "GO:0016319", "GO:0016321", "GO:0016441", "GO:0016458", "GO:0016568", "GO:0016569", "GO:0016570", "GO:0016571", "GO:0016572", "GO:0017145", "GO:0018130", "GO:0019219", "GO:0019222", "GO:0019438", "GO:0019827", "GO:0019953", "GO:0022402", "GO:0022403", "GO:0022404", "GO:0022412", "GO:0022414", "GO:0022610", "GO:0023052", "GO:0023057", "GO:0030111", "GO:0030154", "GO:0030178", "GO:0030182", "GO:0030261", "GO:0030422", "GO:0030703", "GO:0030727", "GO:0031023", "GO:0031047", "GO:0031050", "GO:0031056", "GO:0031060", "GO:0031123", "GO:0031145", "GO:0031175", "GO:0031323", "GO:0031324", "GO:0031325", "GO:0031326", "GO:0031327", "GO:0031331", "GO:0031398", "GO:0031399", "GO:0031401", "GO:0031570", "GO:0031572", "GO:0031935", "GO:0032268", "GO:0032270", "GO:0032501", "GO:0032502", "GO:0032504", "GO:0032507", "GO:0032774", "GO:0032776", "GO:0032886", "GO:0033043", "GO:0033044", "GO:0033260", "GO:0033301", "GO:0033554", "GO:0034622", "GO:0034641", "GO:0034645", "GO:0034654", "GO:0034754", "GO:0034968", "GO:0035023", "GO:0035107", "GO:0035114", "GO:0035120", "GO:0035186", "GO:0035194", "GO:0035195", "GO:0035220", "GO:0035282", "GO:0035295", "GO:0035825", "GO:0036211", "GO:0036388", "GO:0040029", "GO:0042060", "GO:0042221", "GO:0042445", "GO:0043009", "GO:0043066", "GO:0043069", "GO:0043161", "GO:0043170", "GO:0043331", "GO:0043412", "GO:0043414", "GO:0043549", "GO:0043631", "GO:0043933", "GO:0044237", "GO:0044249", "GO:0044260", "GO:0044271", "GO:0044419", "GO:0044700", "GO:0044702", "GO:0044703", "GO:0044707", "GO:0044728", "GO:0044763", "GO:0044767", "GO:0044770", "GO:0044771", "GO:0044772", "GO:0044773", "GO:0044774", "GO:0044786", "GO:0044818", "GO:0044839", "GO:0044843", "GO:0044848", "GO:0045132", "GO:0045165", "GO:0045168", "GO:0045185", "GO:0045448", "GO:0045455", "GO:0045787", "GO:0045814", "GO:0045859", "GO:0045892", "GO:0045931", "GO:0045934", "GO:0046331", "GO:0046425", "GO:0046483", "GO:0046580", "GO:0046605", "GO:0046777", "GO:0048070", "GO:0048134", "GO:0048135", "GO:0048285", "GO:0048311", "GO:0048468", "GO:0048477", "GO:0048513", "GO:0048518", "GO:0048519", "GO:0048522", "GO:0048523", "GO:0048563", "GO:0048569", "GO:0048583", "GO:0048585", "GO:0048609", "GO:0048646", "GO:0048666", "GO:0048699", "GO:0048704", "GO:0048705", "GO:0048706", "GO:0048707", "GO:0048731", "GO:0048736", "GO:0048737", "GO:0048754", "GO:0048856", "GO:0048863", "GO:0048865", "GO:0048867", "GO:0048869", "GO:0050789", "GO:0050793", "GO:0050794", "GO:0050896", "GO:0051052", "GO:0051058", "GO:0051128", "GO:0051171", "GO:0051172", "GO:0051225", "GO:0051235", "GO:0051246", "GO:0051247", "GO:0051252", "GO:0051253", "GO:0051276", "GO:0051297", "GO:0051299", "GO:0051301", "GO:0051302", "GO:0051321", "GO:0051325", "GO:0051329", "GO:0051338", "GO:0051351", "GO:0051443", "GO:0051445", "GO:0051641", "GO:0051646", "GO:0051651", "GO:0051704", "GO:0051716", "GO:0051726", "GO:0051783", "GO:0051785", "GO:0060255", "GO:0060429", "GO:0060548", "GO:0060688", "GO:0060966", "GO:0060968", "GO:0060993", "GO:0061138", "GO:0065003", "GO:0065004", "GO:0065007", "GO:0070192", "GO:0070507", "GO:0070887", "GO:0070918", "GO:0071103", "GO:0071359", "GO:0071822", "GO:0071824", "GO:0071840", "GO:0071897", "GO:0071900", "GO:0072028", "GO:0072078", "GO:0072079", "GO:0072088", "GO:0080090", "GO:0090068", "GO:0090304", "GO:0090306", "GO:0098609", "GO:1901071", "GO:1901360", "GO:1901362", "GO:1901576", "GO:1901987", "GO:1901988", "GO:1901990", "GO:1901991", "GO:1902275", "GO:1902299", "GO:1902589", "GO:1902679", "GO:1902749", "GO:1903046", "GO:1903047", "GO:1903308", "GO:1903322", "GO:2000026", "GO:2000112", "GO:2000113", "GO:2001141")
The error message in itself is informative. If one tries to make it reproducible, it's best to work with small subsets. It usually helps to have a dead stare at your data before trying to reproduce the behavior. For example,
OQ = c("GO:0000003", "GO:2001141", )
Notice that there are two elements of this character vector. Or are they?
Error in c("GO:0000003", "GO:2001141", ) : argument 3 is empty
Number 3 is the key. R is expecting three elements. Notice the comma after the second element. Once you remove it, you'll be able to create the QQ variable. Scan your real example. I'm sure there's a , , somewhere.
EDIT
I tried copy/pasting your code into a script in Rstudio and it produced the error you describe. If you scroll right, you'll notice that syntax coloring is not working at around position 5000. I have folded the code so that it fits on screen and it runs fine.
This is how I folded the vector and it worked.
OQ = c("GO:0000003", "GO:0000070", "GO:0000077", "GO:0000079", "GO:0000082", "GO:0000086", "GO:0000122",
"GO:0000212", "GO:0000226", "GO:0000278", "GO:0000279", "GO:0000280", "GO:0000724", "GO:0000725",
"GO:0000819", "GO:0000910", "GO:0001932", "GO:0002118", "GO:0002121", "GO:0002165", "GO:0003002",
"GO:0003006", "GO:0006022", "GO:0006030", "GO:0006040", "GO:0006139", "GO:0006259", "GO:0006260",
"GO:0006261", "GO:0006267", "GO:0006270", "GO:0006275", "GO:0006277", "GO:0006281", "GO:0006302",
"GO:0006304", "GO:0006305", "GO:0006306", "GO:0006310", "GO:0006323", "GO:0006325", "GO:0006342",
"GO:0006351", "GO:0006355", "GO:0006357", "GO:0006366", "GO:0006464", "GO:0006468", "GO:0006479",
"GO:0006725", "GO:0006807", "GO:0006928", "GO:0006950", "GO:0006974", "GO:0006996", "GO:0007010",
"GO:0007017", "GO:0007018", "GO:0007049", "GO:0007051", "GO:0007059", "GO:0007062", "GO:0007067",
"GO:0007076", "GO:0007088", "GO:0007093", "GO:0007095", "GO:0007098", "GO:0007126", "GO:0007127",
"GO:0007131", "GO:0007140", "GO:0007141", "GO:0007143", "GO:0007154", "GO:0007155", "GO:0007156",
"GO:0007259", "GO:0007266", "GO:0007275", "GO:0007276", "GO:0007281", "GO:0007282", "GO:0007292",
"GO:0007304", "GO:0007307", "GO:0007346", "GO:0007350", "GO:0007365", "GO:0007367", "GO:0007379",
"GO:0007389", "GO:0007399", "GO:0007400", "GO:0007417", "GO:0007420", "GO:0007423", "GO:0007444",
"GO:0007472", "GO:0007476", "GO:0007552", "GO:0007560", "GO:0008104", "GO:0008213", "GO:0008283",
"GO:0008284", "GO:0008315", "GO:0008356", "GO:0009059", "GO:0009611", "GO:0009653", "GO:0009790",
"GO:0009791", "GO:0009880", "GO:0009886", "GO:0009887", "GO:0009888", "GO:0009889", "GO:0009890",
"GO:0009892", "GO:0009893", "GO:0009896", "GO:0009968", "GO:0009987", "GO:0010032", "GO:0010033",
"GO:0010092", "GO:0010389", "GO:0010468", "GO:0010498", "GO:0010556", "GO:0010558", "GO:0010564",
"GO:0010604", "GO:0010605", "GO:0010608", "GO:0010629", "GO:0010648", "GO:0010948", "GO:0014016",
"GO:0014017", "GO:0014070", "GO:0016043", "GO:0016055", "GO:0016070", "GO:0016310", "GO:0016319",
"GO:0016321", "GO:0016441", "GO:0016458", "GO:0016568", "GO:0016569", "GO:0016570", "GO:0016571",
"GO:0016572", "GO:0017145", "GO:0018130", "GO:0019219", "GO:0019222", "GO:0019438", "GO:0019827",
"GO:0019953", "GO:0022402", "GO:0022403", "GO:0022404", "GO:0022412", "GO:0022414", "GO:0022610",
"GO:0023052", "GO:0023057", "GO:0030111", "GO:0030154", "GO:0030178", "GO:0030182", "GO:0030261",
"GO:0030422", "GO:0030703", "GO:0030727", "GO:0031023", "GO:0031047", "GO:0031050", "GO:0031056",
"GO:0031060", "GO:0031123", "GO:0031145", "GO:0031175", "GO:0031323", "GO:0031324", "GO:0031325",
"GO:0031326", "GO:0031327", "GO:0031331", "GO:0031398", "GO:0031399", "GO:0031401", "GO:0031570",
"GO:0031572", "GO:0031935", "GO:0032268", "GO:0032270", "GO:0032501", "GO:0032502", "GO:0032504",
"GO:0032507", "GO:0032774", "GO:0032776", "GO:0032886", "GO:0033043", "GO:0033044", "GO:0033260",
"GO:0033301", "GO:0033554", "GO:0034622", "GO:0034641", "GO:0034645", "GO:0034654", "GO:0034754",
"GO:0034968", "GO:0035023", "GO:0035107", "GO:0035114", "GO:0035120", "GO:0035186", "GO:0035194",
"GO:0035195", "GO:0035220", "GO:0035282", "GO:0035295", "GO:0035825", "GO:0036211", "GO:0036388",
"GO:0040029", "GO:0042060", "GO:0042221", "GO:0042445", "GO:0043009", "GO:0043066", "GO:0043069",
"GO:0043161", "GO:0043170", "GO:0043331", "GO:0043412", "GO:0043414", "GO:0043549", "GO:0043631",
"GO:0043933", "GO:0044237", "GO:0044249", "GO:0044260", "GO:0044271", "GO:0044419", "GO:0044700",
"GO:0044702", "GO:0044703", "GO:0044707", "GO:0044728", "GO:0044763", "GO:0044767", "GO:0044770",
"GO:0044771", "GO:0044772", "GO:0044773", "GO:0044774", "GO:0044786", "GO:0044818", "GO:0044839",
"GO:0044843", "GO:0044848", "GO:0045132", "GO:0045165", "GO:0045168", "GO:0045185", "GO:0045448",
"GO:0045455", "GO:0045787", "GO:0045814", "GO:0045859", "GO:0045892", "GO:0045931", "GO:0045934",
"GO:0046331", "GO:0046425", "GO:0046483", "GO:0046580", "GO:0046605", "GO:0046777", "GO:0048070",
"GO:0048134", "GO:0048135", "GO:0048285", "GO:0048311", "GO:0048468", "GO:0048477", "GO:0048513",
"GO:0048518", "GO:0048519", "GO:0048522", "GO:0048523", "GO:0048563", "GO:0048569", "GO:0048583",
"GO:0048585", "GO:0048609", "GO:0048646", "GO:0048666", "GO:0048699", "GO:0048704", "GO:0048705",
"GO:0048706", "GO:0048707", "GO:0048731", "GO:0048736", "GO:0048737", "GO:0048754", "GO:0048856",
"GO:0048863", "GO:0048865", "GO:0048867", "GO:0048869", "GO:0050789", "GO:0050793", "GO:0050794",
"GO:0050896", "GO:0051052", "GO:0051058", "GO:0051128", "GO:0051171", "GO:0051172", "GO:0051225",
"GO:0051235", "GO:0051246", "GO:0051247", "GO:0051252", "GO:0051253", "GO:0051276", "GO:0051297",
"GO:0051299", "GO:0051301", "GO:0051302", "GO:0051321", "GO:0051325", "GO:0051329", "GO:0051338",
"GO:0051351", "GO:0051443", "GO:0051445", "GO:0051641", "GO:0051646", "GO:0051651", "GO:0051704",
"GO:0051716", "GO:0051726", "GO:0051783", "GO:0051785", "GO:0060255", "GO:0060429", "GO:0060548",
"GO:0060688", "GO:0060966", "GO:0060968", "GO:0060993", "GO:0061138", "GO:0065003", "GO:0065004",
"GO:0065007", "GO:0070192", "GO:0070507", "GO:0070887", "GO:0070918", "GO:0071103", "GO:0071359",
"GO:0071822", "GO:0071824", "GO:0071840", "GO:0071897", "GO:0071900", "GO:0072028", "GO:0072078",
"GO:0072079", "GO:0072088", "GO:0080090", "GO:0090068", "GO:0090304", "GO:0090306", "GO:0098609",
"GO:1901071", "GO:1901360", "GO:1901362", "GO:1901576", "GO:1901987", "GO:1901988", "GO:1901990",
"GO:1901991", "GO:1902275", "GO:1902299", "GO:1902589", "GO:1902679", "GO:1902749", "GO:1903046",
"GO:1903047", "GO:1903308", "GO:1903322", "GO:2000026", "GO:2000112", "GO:2000113", "GO:2001141")

Resources