איתור מיקום קובץ בעזרת שם הקובץ

17 views
Skip to first unread message

יוני יצחק

unread,
Mar 15, 2015, 1:14:12 AM3/15/15
to israel-r-...@googlegroups.com
שלום לכולם

יש לי פונקציה הרצה באופן באופן קבוע בכל פתיחת פרויקט, הפונקציה מארגנת וממיינת את נתוני ה RAW של הפרויקט.

הפונקציה רצה מתוך Library ייעודית והיא גנרית לחלוטין.


האם יש אפשרות להגדיר ב-R שורת חיפוש המחזירה את  ה path של קבצי ה RAW (על בסיס השם שלהם) על מנת שניתן יהיה להריץ אותה (מתוך ה-Library שלה) על כל פרויקט בלי להכניס את ה path של הפרויקט כמשתנה?


תודה רבה

יוני יצחק.

Liad Shekel

unread,
Mar 15, 2015, 2:27:17 AM3/15/15
to Israel R User Group
לא יעיל בעליל, אבל מכיוון שזה נעשה פעם אחת זה לא נורא.
files_path <- list.files("C://", recursive = TRUE) ### use the directory you want to search inside
files_name <- files_path %>% strsplit("/") %>% tail(1) ### extract the name of the file
files_path[ grep("File_name_pattern",files_name) ] 



--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
:-)

Liad Shekel

unread,
Mar 15, 2015, 2:35:32 AM3/15/15
to Israel R User Group
סורי, אני כותב בלי R ופתאום הבנתישיש לי טעות. 
תיקון:
files_path <- list.files("C://", recursive = TRUE) ### use the directory you want to search inside
files_name <- files_path %>% strsplit("/") %>% sapply(tail,1)
files_path[ grep("File_name_pattern",files_name) ] 
--
:-)

יוני יצחק

unread,
Mar 16, 2015, 1:26:13 AM3/16/15
to israel-r-...@googlegroups.com
ממש תודה ליעד!

עושה את העבודה מצויין, השלב הראשון של יצירת ה list.files לוקח חמש שניות אבל מאפשר לי להריץ את הקוד גנרית בלי להגדיר את ה path כמשתנה, וזו המטרה.

שוב תודה

יוני יצחק

2015-03-15 8:26 GMT+02:00 Liad Shekel <liad....@gmail.com>:

--
You received this message because you are subscribed to a topic in the Google Groups "Israel R User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/israel-r-user-group/0DWerwNPnF0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to israel-r-user-g...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages