Mapply Runs Into Endless Loop - Stack Overflow
-
- Home
- Questions
- Tags
- Users
- Companies
- Labs
- Jobs
- Discussions
- Collectives
-
Communities for your favorite technologies. Explore all Collectives
- Teams
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Try Teams for free Explore Teams - Teams
-
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsGet early access and see previews of new features.
Learn more about Labs mapply runs into endless loop Ask Question Asked 6 years ago Modified 6 years ago Viewed 94 times Part of R Language Collective 0I have a data.table like this:
testDT <- data.table(SFf = as.character(c("C1H1", "C3H4Cl")), Mult = as.integer(c(3,5)) )now I am trying to loop over the rows of this table and apply a function (multiform() from the package enviPat) to it like this:
mapply(multiform,testDT$SFf,testDT$Mult)the output of it should be two strings, namely "C3H3" and "C15H20Cl5". However the function simply never stops calculating and seems to get caught up in an endless loop.
When I apply the function like
multiform("C1H1",3)it works and I get "C3H3" as output. What am I doing wrong?
Yasel
Share Improve this question Follow asked Dec 11, 2018 at 16:50 yaselyasel 4433 silver badges13 bronze badges 5- 1 Probably you are doing nothing wrong, the function multiform is just really slow. Looking at it's code it seems totally plausible that it could take a very, very long time on even moderately sized inputs. – joran Commented Dec 11, 2018 at 16:58
- when I am using it only once it takes much less than a second. but when I tried it for two rows via mapply I stopped it after 10 min, so I think that canot be it – yasel Commented Dec 11, 2018 at 17:01
- It's taking time because of the second SFf value. If you do this multiform("C3H4Cl",5), it will also take too long. – Taher A. Ghaleb Commented Dec 11, 2018 at 17:04
- If it's taking too long on only 2 elements, then yes, probably something is specifically awry with the code that handles that particular case. – joran Commented Dec 11, 2018 at 17:08
- 1 You're right, it does end up in an infinite loop for that particular example. I don't know enough about chemical formulas to debug it effectively, but it is likely that this is a bug in the function. I would contact the package authors about it and show them this example. – joran Commented Dec 11, 2018 at 17:12
1 Answer
Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 2I got it. The problem was that the function multiform() does not allow elements without numbers behind them. So it wont take "C3H4Cl" but "C3H4Cl1".
I don't think that this is intended and will try to contact the authors of the package.
Share Improve this answer Follow answered Dec 11, 2018 at 17:15 yaselyasel 4433 silver badges13 bronze badges 1- I think they're aware. The "Details" section in this function's documentation says "Chemical formulas must conform to what is described in check_chemform". If you run data(isotopes); check_chemform(isotopes, 'C3H4Cl'), it will show you the corrected formula (with a 1 on the end). – IceCreamToucan Commented Dec 11, 2018 at 17:33
Your Answer
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Draft saved Draft discardedSign up or log in
Sign up using Google Sign up using Email and Password SubmitPost as a guest
Name EmailRequired, but never shown
Post Your Answer DiscardBy clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged
or ask your own question. R Language Collective Join the discussion This question is in a collective: a subcommunity defined by tags with relevant content and experts.- The Overflow Blog
- Legal advice from an AI is illegal
- Why do developers love clean code but hate writing documentation?
- Featured on Meta
- The December 2024 Community Asks Sprint has been moved to March 2025 (and...
- Stack Overflow Jobs is expanding to more countries
Related
16 Weird mapply behaviour: what have I missed? 0 Issues using mapply 3 Why does mapply repeat the same list multiple times? 1 How to trace where the Error occurs when executing a `mapply()`? 0 how to avoid this loop in R (rapply ? lapply ?) 0 mapply over a function yields erronoeusly the aplication of another function 4 Forced To Use mapply Is There A Workaround 1 Trouble with mapply 3 Struggling with Mapply 0 Using mapply to plotHot Network Questions
- Why doesn't a metal disk expand in all directions when heated?
- Explicit zero free regions for the Riemann zeta function
- Would reflected sunlight suffice to read a book on the surface of the Moon?
- What keyboard shortcuts disable the keyboard?
- Which is larger? 4^(5^9) or 5^(6^8)
- Meaning of Second line of Shakespeare's Sonnet 66
- Are there actual correct representations of curved spacetime?
- Do accidentals have other meanings, or is their usage in this hymn all wrong?
- What term am I missing from the Feynman diagram calculation?
- Why is truncation faster than direct polynomial expansion?
- Is the word "boy" racist in the following situation?
- Movie where a family crosses through a dimensional portal and end up having to fight for power
- Is `std::function` deprecated by `std::copyable_function` in C++26?
- PSE Advent Calendar 2024 (Day 18): A sweet & short expected chemistry Christmas puzzle
- how to increase precision when using the fpu library?
- Removing Matching Pixels?
- Why is my LED burning out?
- Error evaluating the area inside an epicycloid, spot my mistake?
- Product of all binomial coefficients
- Notepad++ find and replace string
- 310 Volt Brushless DC Motor Advantages
- adduser allows weak password - how to prevent?
- How to Mitigate Risks Before Delivering a Project with Limited Testing?
- Is there an English equivalent of Arabic "gowatra" - performing a task with none of the necessary training?
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
lang-rTừ khóa » C3h4cl
-
CID 15582100 | C3H4Cl - PubChem
-
2-Chloroallylradical | C3H4Cl - PubChem
-
Chloropropenium | C3H4Cl - ChemSpider
-
2-Chloro-1,2,3-propanetriyl | C3H4Cl - ChemSpider
-
Formula:C3H4Cl - LookChem
-
Molar Mass Of C3H4Cl
-
35561-39-8 Cyclopropyl, 2-chloro- C3H4Cl, Formula,NMR,Boiling ...
-
Give Structures And Numbers Of Total Isomers Of C3H4Cl(OH) - Toppr
-
C3H4Cl Molar Mass - ChemicalAid
-
Plots Of The Transient Absorbance At 240 Nm Observed When A ...
-
C9H9Cl - Molecular Formula - MOLBASE
-
(3,3, 3-Trifluoropropyl)Trichlorosilane - United Chemical Technologies
-
[PDF] Free Energies For Degradation Reactions Of 1,2,3 ... - Amazon S3