[R] I need help in seeing the code

peter dalgaard pdalgd at gmail.com
Tue Jul 22 15:02:09 CEST 2014


On 22 Jul 2014, at 08:31 , PIKAL Petr <petr.pikal at precheza.cz> wrote:

> Hi
> 
> Anyway. AFAIK your code looks OK to me, provided you want find the number of rows without NA in each file.
> 

...however, it is not clear to any of us whether the teacher has been instructing students to avoid expanding the vector of answers on each iteration, or maybe even teaching the semantics of lapply/sapply. It is also not clear that the response should contain the index number rather than the name of each file.

-pd

> Petr
> 
> 
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Sarah Goslee
>> Sent: Tuesday, July 22, 2014 8:22 AM
>> To: Darius Mulia
>> Cc: r-help at r-project.org
>> Subject: Re: [R] I need help in seeing the code
>> 
>> Hi Darius,
>> 
>> This is the main R-help list. We don't know anything about your
>> Coursera class, including what your code is supposed to do. Not only
>> that, this list has a no homework policy.
>> 
>> You need to use the discussion group associated with your course, or
>> whatever materials it provides, to get assistance.
>> 
>> Sarah
>> 
>> On Tuesday, July 22, 2014, Darius Mulia <muliadarius at gmail.com> wrote:
>> 
>>> Hi there,
>>> 
>>> I am Darius and I am taking the R Programming course in Coursera. I
>>> have a problem that I had spent so much looking for the problem. I
>>> wrote my code and I believe that the code works perfectly fine
>> because
>>> it produces the result as what the course demanded. However, when I
>>> tried to submit it, it says that my code is wrong. I do believe I
>> make
>>> mistake, but I cannot seem to find it. the code is as follow:
>>> 
>>> Complete.R
>>> 
>>> complete <- function(directory, id = 1:332) {
>>>  file <- list.files(directory, full.names=TRUE)
>>>  nobs <- c()
>>>  for (i in id){
>>>    file1 <- read.csv(file[i])
>>>    nobs1 <- sum(complete.cases(file1))
>>>    nobs <- c(nobs, nobs1)
>>>    df <- data.frame(nobs)
>>>  }
>>>  return(data.frame(id,df))
>>> }
>>> 
>>> 
>>> Please give me a hint where I should look at.
>>> 
>>> Thank you very much for your time and concern. I look forward hearing
>>> back from you.
>>> 
>>> Sincerely,
>>> 
>>> Darius Mulia.
>>> 
>>>        [[alternative HTML version deleted]]
>>> 
>>> ______________________________________________
>>> R-help at r-project.org <javascript:;> mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>> 
>> 
>> --
>> Sarah Goslee
>> http://www.stringpage.com
>> http://www.sarahgoslee.com
>> http://www.functionaldiversity.org
>> 
>>      [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> ________________________________
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.
> 
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.
> 
> This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
> If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.
> 
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
> - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
> - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list