--
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/groups/opt_out.
--
היי
אני רוצה לחשב דיוק באופן הבא: יש לי וקטור של 0 ו-1, כאשר 1 הכוונה לתשובה נכונה ו-0 הכוונה לתשובה לא נכונה. אז לפי מה שאני מבינה אני צריכה:
1. לדעת את האורך של הוקטור.
2. לסכום את הוקטור.
3. לחלק את סכום הוקטור באורך הוקטור.
זה מה שייתן לי דיוק באופן שבו אני רוצה לחשב דיוק.
הפונקציה כן כתובה נכון, בדקתי אותה והיא עובדת :) .
העניין הוא שכאשר אני משתמשת בפונקציה בתוך tapply אני לא יכולה לשנות את ac_vector של הפונקציה שכתבתי, אלא אם כן שיניתי אותו מראש, כמו למשל בדוגמא הבאה:
ac_vector = ac_data$ac
mac_fun <- function(ac_vector) {
mac_calc<-(sum(ac_vector)/length(ac_vector))
return(mac_calc)}
mac = tapply(ac_data$ac,list(ac_data$subject,ac_data$condition),mac_fun)
האם יש דרך שבה אני אוכל לשלב את השורה הזאת
ac_vector = ac_data$ac
בשאר הקוד שכתבתי? אשמח להצעות והכוונה.
תודה רבה
אילה
To unsubscribe from
this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
2013/5/6 Ayala Allon <ayala...@gmail.com>
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsubscribe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.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/2ZNycGAgq_k/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to israel-r-user-g...@googlegroups.com.
שלום,
יש לי עוד שאלה בקשר לכתיבת פונקציות.
כשאני כותבת פונקציה לפי מה שאני מבינה היא יכולה להחזיר לי רק ערך אחד (מה שאני שמה ב- return).
האם יש דרך לגרום לפונקציה להחזיר לי מספר ערכים?
למשל בפונקציה שכתבתי הייתי רוצה שהיא תחזיר לי גם את head.data וגם את dim.data.
כשאני מריצה את הפונקציה הבאה R כותב לי הודעת שגיאה שאומרת שאני לא יכולה לשים יותר מערך אחד ב-return.
read.data = function (MyFileName.csv){data = read.csv(MyFileName.csv)
head.data = head(data)
dim.data = dim(data)
return(haed.data,dim.data)}
הודעת השגיאה שאני מקבלת:
> read.data("r5data-exp.csv")
Error in return(haed.data, dim.data) :
multi-argument returns are not permitted
תודה
אילה
או פשוט ווקטור עם שמות
return(c(head=head.data, dim=dim.data))
דרך אגב בצורה הזו לפונקציות כמו sapply קל מאוד להפוך את הפלט ל data.frame
תודה רבה!!
תודה!!!!
2013/6/4 Ayala Allon <ayala...@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/2ZNycGAgq_k/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to israel-r-user-group+unsub...@googlegroups.com.
--
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-group+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
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/2ZNycGAgq_k/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to israel-r-user-group+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
שלום,
אני רוצה לכתוב פונקציה שתעשה את הדבר הבא:
condition = paste(x1,x2, sep="_")
העניין הוא שכל פעם יהיה לי מספר שונה של X שאני ארצה לעשות בניהם paste. השאלה שלי היא איך אני יכולה לכתוב פונקציה באופן כללי ככה שכל פעם מספר האלמנטים שהיא תקבל יהיה שונה? אני רוצה לעשות את אותן האופרציות כל פעם עם מספר אלמנטים שונה.
אשמח להסבר על איך אפשר לעשות את זה.
תודה רבה,
אילה
--
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.