Why won't this list of strings store as a variable in R?
1
1
Entering edit mode
2.2 years ago
emilyc ▴ 30

Hello/bonjour,

I really cannot figure out the reason I am getting an error with the below when executed in R.

RNA1 <- c("ARE85692.1", "WP_030538461.1", "OLA28585.1", "WP_030092979.1", "WP_011255103.1", "WP_037470143.1", "WP_037470142.1","WP_048575187.1", "WP_040265129.1", "WP_112366619.1", "OZS41314.1", "AGH47784.1", "KSV62316.1", "WP_052448286.1", "WP_063735071.1", "KYL83848.1", "WP_012644006.1", "WP_051849361.1", "ACF68028.1", "OJY67256.1", "EHV83032.1", "XP_020442226.1", "RGU03766.1", "WP_000904906.1", "PTR09915.1", "EKU54097.1", "WP_104504265.1", "AEA08378.1", "WP_084929469.1", "AKN19375.1", "CLP57205.1", "WP_071925129.1", "WP_066491086.1", "PZU06012.1", "WP_030199248.1", "XP_025029738.1", "RCN39061.1", "WP_026925198.1", "XP_013869014.1", "WP_085810747.1", "CRY96001.1", "ONH68315.1", "ASG92531.1", "XP_021849475.1", "XP_006401694.1", "WP_096234110.1", "WP_086730043.1", "WP_072340239.1", "WP_031455762.1", "WP_011565327.1", "XP_026410054.1", "OEU57032.1", "WP_063357489.1", "YP_009329821.1", "WP_054311735.1", "WP_069548609.1", "GBG31406.1", "WP_077692070.1", "PFH62043.1", "WP_093049484.1", "XP_022039943.1", "PRP78866.1", "XP_018737851.1", "RMY65069.1", "RKY44823.1", "YP_009329976.1", "YP_009333557.1", "WP_119236352.1", "ODT01658.1", "XP_021940059.1", "WP_090634955.1", "XP_020190111.1", "PVU98352.1", "YP_009337427.1", "ASM94072.1", "WP_106566124.1", "ASM94072.1", "WP_005183695.1", "EOA18517.1", "WP_031514849.1", "WP_121631597.1", "WP_029313977.1", "WP_031514849.1", "WP_121631597.1", "WP_029313977.1", "YP_009333388.1", "WP_039951580.1", "YP_009333424.1", "WP_076143666.1", "KIR87973.1", "WP_111579388.1", "XP_011395463.1", "WP_094786685.1", "AGZ83338.1", "OIP93066.1", "XP_014283183.1", "WP_009740728.1", "PYO78928.1", "PYM36611.1", "AOZ73397.1", "KYK23134.1", "WP_073281990.1", "WP_115122543.1", "WP_003648784.1", "YP_009237556.1", "YP_009333186.1", "YP_009333507.1", "XP_013368103.1", "XP_018782030.1", "WP_114764940.1", "WP_082342709.1", "XP_026614825.1", "WP_096746960.1", "WP_093320012.1", "ARU76991.1", "AFR11835.1", "XP_002910093.1", "WP_073176644.1", "WP_086490062.1", "RHN80591.1", "WP_062831894.1", "CDB02563.1", "GAX95753.1", "AXQ65872.1", "XP_023329285.1", "WP_004082834.1", "WP_013307564.1", "KFV82731.1", "WP_031138773.1", "XP_020682540.1", "APG76144.1", "WP_035114579.1", "WP_006284965.1", "WP_096474323.1", "WP_042681208.1", "WP_097150106.1", "AAW51878.1", "SET36711.1", "KFP07431.1", "WP_071357402.1", "PZO55424.1", "WP_018341803.1", "WP_018341803.1", "XP_020578684.1", "XP_016347362.1", "CZR67299.1", "KFX48225.1", "CZR67299.1", "SOE19862.1", "YP_009337755.1", "AWK77840.1", "KKW02112.1", "APG76452.1", "ASM94018.1", "YP_009333600.1", "YP_009333601.1", "PYU14395.1", "WP_069185297.1", "YP_009337082.1", "YP_009330048.1", "AUM61889.1", "XP_012339246.1", "WP_010100069.1", "YP_009333384.1", "OEG70557.1", "CEL73936.1", "WP_072887783.1", "XP_020574395.1", "YP_009342290.1", "AFF57920.1", "YP_009330042.1", "ORY25512.1", "OJU61881.1", "ETL37738.1", "EKD65879.1", "XP_008889488.1", "WP_103061524.1", "YP_009330042.1", "WP_105635083.1", "XP_020691136.1", "EPB92962.1", "WP_035470959.1", "KIK35098.1", "WP_053655326.1", "KRT66746.1", "RIK26981.1", "CDL24210.1", "GAB94973.1", "YP_001039741.1", "OCT97283.1", "NP_193640.4", "XP_007365969.1", "PYN94992.1", "WP_115971353.1", "WP_030195772.1", "WP_090992472.1", "XP_018762443.1", "YP_009330008.1", "AVH80932.1", "WP_112380387.1", "PRY26922.1", "CQD23474.1", "WP_010408743.1", "WP_106130445.1", "EAQ33519.1", "KXW55186.1", "KXI15614.1", "XP_024359367.1", "OGE31818.1", "YP_009337883.1", "AGT15715.1", "XP_014737065.1", "AGZ83336.2", "AFM44928.2", "WP_004727033.1", "CDA25608.1", "WP_100205692.1", "WP_028109468.1", "YP_009337671.1", "XP_024875031.1", "XP_014145525.1", "XP_020474819.1", "XP_005061300.1", "SIO87404.1", "CEI98194.1", "WP_019528182.1", "XP_014530733.1", "OLZ29151.1", "XP_016180396.1", "KFB98075.1", "WP_051506973.1", "XP_020780343.1", "RJU90914.1", "WP_048426347.1", "SIR30680.1", "XP_005051765.1", "APG76171.1", "APG76598.1", "EMP55287.1", "YP_009336792.1", "XP_007001859.1", "KXS96290.1", "OON05112.1", "YP_009109631.1", "OMJ77737.1", "AJD07497.1", "PYL28269.1", "XP_021863274.1", "WP_004160142.1", "OTA70178.1", "YP_398835.1", "RIW43611.1", "XP_022910622.1", "WP_107712039.1", "OMO51929.1", "WP_071550802.1", "WP_088469378.1", "SUX89036.1", "CBA31922.1", "CZR19882.1", "KTC66800.1", "WP_085515616.1", "YP_009333600.1", "YP_654545.1", "YP_654545.1", "OHB51241.1", "PIO64269.1", "EDK39810.2", "XP_013363451.1", "PHS21967.1", "WP_083520182.1", "OAQ67482.1", "WP_104331052.1", "CAX33877.1", "STX28550.1", "YP_009449401.1", "YP_009333557.1", "WP_114380100.1", "KKS15734.1", "PKY48696.1", "OWK58877.1", "WP_119795562.1", "GAX86195.1", "AAB94620.1", "WP_009694801.1", "AWK77840.1", "PCF46882.1", "WP_009060397.1", "AJP36355.1", "YP_009336791.1", "WP_075151084.1", "WP_100304320.1", "YP_009333437.1", "YP_009337854.1", "XP_025388358.1", "WP_103312029.1", "XP_009517785.1", "YP_009337045.1", "WP_115390984.1", "WP_083885471.1", "PZP85870.1", "APQ44496.1", "WP_025425191.1", "AAX26869.1", "PHT27344.1", "WP_017430083.1", "WP_088642165.1", "CDJ81252.1", "XP_007130401.1", "WP_090235612.1", "WP_021278083.1", "OGJ57224.1", "OFW09128.1", "WP_104635294.1", "ASM94017.1", "ETL31718.1", "WP_071814864.1", "WP_043211725.1", "EPS42677.1", "YP_009337772.1", "YP_009330042.1", "YP_009329862.1", "RMZ28204.1", "AAD24412.1", "WP_062451953.1", "OXE37212.1", "WP_090474888.1", "WP_114909516.1", "WP_093034338.1", "WP_041782265.1", "WP_046232340.1", "YP_009336927.1", "WP_008191349.1", "SLE30469.1", "EFL15839.1", "EID19494.1", "EFE84358.1", "SPF69569.1", "WP_120491108.1", "WP_087006979.1", "WP_039875332.1", "APG76184.1", "SUX89036.1", "CBA31922.1", "KOT11881.1", "ADI16723.1", "AOE05674.1", "AOE10198.1", "AOE10199.1", "AQK66169.1", "KJS33120.1", "WP_013995201.1", "WP_089591822.1", "ASM94093.1", "KMS64820.1", "AOE07163.1", "AOE07164.1", "AOE11734.1", "AOE07606.1", "APQ44493.1", "APQ44496.1", "YP_009333600.1", "AOE10200.1", "SPY22707.1", "XP_021891377.1", "BAK20600.1", "XP_018733639.1", "XP_005383010.1", "OGX05865.1", "AFM44928.2", "YP_009337445.1", "AHA86934.1", "WP_036204856.1", "WP_055080489.1", "XP_018734836.1", "YP_009336700.1", "WP_115823841.1", "XP_025262873.1", "XP_006916488.1", "WP_084329043.1", "WP_015347430.1", "XP_814918.1", "WP_015284209.1", "KOB71805.1", "RBP18207.1", "ASM94017.1", "WP_056655483.1", "YP_007438853.1", "XP_024908946.1", "WP_117872353.1", "AKH67441.1", "PZX36280.1", "ORY42375.1", "CEO96512.1", "XP_002671596.1", "OJI06181.1", "YP_009337230.1", "AYN75542.1", "WP_031470382.1", "WP_051737908.1", "WP_112948296.1", "YP_009337111.1", "RLJ02486.1", "YP_009342270.1", "KUK29015.1", "CQD23510.1", "WP_090423511.1", "KQS54592.1", "SWW83940.1", "WP_061772349.1", "XP_013650435.1", "KIK72446.1", "WP_035344944.1", "WP_019617976.1", "YP_009337445.1", "WP_083642681.1", "YP_009337419.1", "WP_112094499.1", "OCB87632.1", "YP_009329821.1", "EEP55936.1", "WP_075172010.1", "WP_089221271.1", "WP_092405127.1", "WP_087307961.1", "OUS08811.1", "XP_021707674.1", "WP_073193414.1", "APG76212.1", "WP_060167633.1", "KZC89585.1", "WP_112148229.1", "WP_100645044.1", "WP_112380386.1", "WP_030092974.1", "RMG50508.1", "OFY65797.1", "WP_074310443.1", "RLV95769.1", "YP_009336636.1", "APG77045.1", "WP_082633868.1", "APG77046.1", "KTC66578.1", "KHG25866.1", "XP_022538281.1", "WP_102365619.1", "KGJ03428.1", "WP_047867244.1", "GAM02817.1", "WP_047867245.1", "WP_049570233.1", "PYI30954.1", "WP_099543287.1", "WP_106457008.1", "ASM94018.1", "WP_020590223.1", "YP_009336792.1", "YP_392465.1", "WP_076067437.1", "XP_024386541.1", "OLS15339.1", "XP_016526832.1", "CEM06887.1", "WP_107660914.1", "WP_118990021.1", "WP_048381386.1", "WP_030939398.1", "APG77253.1", "XP_022031898.1", "SAM01137.1", "WP_075585659.1", "WP_075153469.1", "GBH14995.1", "WP_007407197.1", "AWN14257.1", "WP_097297685.1", "AOX46253.1", "KHS45135.1", "XP_006776713.1", "WP_088296610.1", "YP_009333150.1", "RKY44687.1", "XP_008875055.1", "YP_009333545.1", "YP_392465.1", "WP_074834324.1", "XP_009063951.1", "PKS10204.1", "WP_108850444.1", "WP_062386622.1", "PHT30680.1", "AAO24320.1", "WP_045185214.1", "YP_009329821.1", "KXQ43755.1", "OQY64528.1", "ADI17229.1", "CAJ30045.1", "SMG06634.1", "WP_061773072.1", "WP_107953972.1", "KDO81281.1", "CAX33878.1", "WP_015329842.1", "XP_005775359.1", "OYV07171.1", "WP_088086110.1", "XP_007017423.2", "YP_009337704.1", "CDQ86554.1", "WP_091009173.1", "XP_023952606.1", "WP_055438060.1", "OJW01441.1", "XP_014609874.1", "AXY86077.1", "WP_087974390.1", "CEJ90739.1", "KYN31989.1", "YP_009330023.1", "AXQ51448.1", "WP_066630827.1", "RMX74157.1", "WP_092247952.1", "WP_116678544.1", "XP_020487964.1", "WP_062230413.1", "WP_056617232.1", "XP_021910847.1", "XP_017768995.1", "OAF16132.1", "WP_107525136.1", "WP_119493636.1", "WP_082748398.1", "WP_042490936.1", "CEE80498.1", "RGS16953.1", "AYE66860.1", "CDQ90625.1", "EDM70192.1", "XP_011697304.1", "KFD96747.1", "XP_001746844.1", "WP_086732958.1", "AAR32107.1", "WP_024524936.1", "WP_121848546.1", "WP_096684028.1", "APG76841.1", "CAJ30046.1", "WP_019005849.1", "PPR79129.1", "WP_121471861.1", "YP_009333601.1", "WP_018191362.1", "GAE78858.1", "WP_075260779.1", "RAV32216.1", "PZQ69074.1", "AGZ83336.2", "BAG46935.1", "OCL12566.1", "WP_083417402.1", "OON04083.1", "WP_103123647.1", "WP_052178944.1", "WP_079125492.1", "PSR90737.1", "RMG95085.1", "XP_011571352.1", "RMJ27228.1", "OLP82095.1", "WP_008618938.1", "SFB48779.1", "XP_010085865.1", "KIK45414.1", "WP_068433130.1", "KDB14550.1", "AAA87625.1", "GAT56413.1", "XP_004338718.1", "KIL88497.1", "YP_001429583.1", "WP_073397577.1", "AOY34458.1", "YP_009329863.1", "ANA08048.1", "KRO88946.1", "WP_007078151.1", "XP_010155229.1", "EMS52259.1", "XP_020434888.1", "WP_121368830.1", "CDB39267.1", "PXY51748.1", "PIE80481.1", "CEP18960.1", "XP_012227353.1", "RGP63998.1", "WP_107099300.1", "XP_024139964.1", "RMX47585.1", "XP_007373726.1", "EAQ35133.1", "WP_010339210.1", "SOC89939.1", "KIY12868.1", "WP_058600399.1", "WP_082052479.1", "CNJ48920.1", "YP_009337800.1", "XP_002619317.1", "AHJ61123.1", "EEW79284.1", "CCG06601.1", "CCG06582.1", "YP_009333352.1", "WP_029449191.1", "PCJ51959.1", "OAJ11263.1", "KLC40008.1", "WP_083966399.1", "WP_052597349.1", "CDW72166.1", "EJY85214.1", "WP_007405213.1", "XP_014062671.1", "GAM01020.1", "CDQ29749.1", "YP_009362296.1", "XP_017240548.1", "OFQ97201.1", "XP_018267507.1", "XP_007700505.1", "XP_023904983.1", "PHT26618.1", "ASM94018.1", "EFG00476.1", "KRY33441.1", "CDQ90285.1", "WP_028535927.1", "WP_086607027.1", "PAV92842.1", "WP_014241917.1", "WP_113667938.1", "XP_018330205.1", "GAU96577.1", "AKQ01593.1", "WP_011563027.1", "CKY60557.1", "WP_006099521.1", "EJY76437.1", "WP_111375676.1", "WP_026532066.1", "WP_082420995.1")

Error: unexpected symbol in:
"#store accession numbers
RNA1 <- c("ARE85692.1"

Sorry it is long. This was composed using unix commands and is not manually composed. Does R have a limit for the number of strings that can be stored?

The example below stores fine:

RNAtest <- c("ARE85692.1", "WP_030538461.1")
 print(RNAtest)
[1] "ARE85692.1"     "WP_030538461.1"

Thank you in advance, sorry for the simple issue. My thoughts are that it's beyond a grammatical error, but I could be very wrong.

R strings • 502 views
ADD COMMENT
1
Entering edit mode

Probably missing quotations somewhere. It is bad practice to read long objects like this into R directly for exactly the reason you see. The object is so long that you cannot visually inspect it for correct quoting and formatting. Don't you have these as a file and can import them via reading the entire file?

ADD REPLY
0
Entering edit mode

Yes, it's a separate file completely manipulated in unix, none of it is manual. I've copied and pasted it into R just because I am sending this complete script to someone who doesn't understand how to use R. It's exactly the same in the file that I read in.

ADD REPLY
0
Entering edit mode

Try outside RStudio, if at all possible.

It works fine for me (here, I shortened it).; however, I believe that my R version detects the maximum limit and creates a newline itself:

RNA1 <- c("ARE85692.1", "WP_030538461.1", "OLA28585.1", "WP_030092979.1", "WP_011255103.1", "WP_037470143.1", "WP_037470142.1","WP_048575187.1", "WP_040265129.1", "WP_112366619.1", "OZS41314.1", "AGH47784.1", "KSV62316.1", "WP_052448286.1", "WP_063735071.1", "KYL83848.1", "WP_012644006.1", "WP_051849361.1", "ACF68028.1", "OJY67256.1", "EHV83032.1", "XP_020442226.1", "RGU03766.1", ... "OFQ97201.1", "XP_018267507.1", "XP_007700505.1", "XP_023904983.1", "PHT26618.1", "ASM94018.1", "EFG00476.1", "KRY33441.1", "CDQ90285.1", "WP_028535927.1", "WP_086607027.1", "PAV92842.1", "WP_014241917.1", "WP_113667938.1", "XP_018330205.1", "GAU96577.1", "AKQ01593.1", "WP_011563027.1", "CKY60557.1", "WP_006099521.1", "EJY76437.1", "WP_111375676.1", "WP_026532066.1", "WP_082420995.1")

length(RNA1)
[1] 656


sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.0
ADD REPLY
0
Entering edit mode

yes, I tried in the terminal directly. The same issue occurs. I can shorten it and get it to work also, but I was hoping to avoid having to do this. Thanks for the help!

ADD REPLY
2
Entering edit mode
2.2 years ago
Benn 8.2k

There is a maximum of what fits in one line in the R console. So use new lines, for example only 5-10 accessions on one line (also for your own legibility).

ADD COMMENT
0
Entering edit mode

Do you have any idea of the actual limit? Based on this I can manipulate it outside of R. Thanks either way.

ADD REPLY
1
Entering edit mode

I think 4096 characters, but I am not sure.

ADD REPLY
0
Entering edit mode

Ah it's by characters - that makes more sense. Awesome, thank you!

ADD REPLY
0
Entering edit mode

Hi @emilyc, if you think this is the answer you should accept it for recognition and future reference. Thanks

ADD REPLY

Login before adding your answer.

Traffic: 1740 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6