Hi,

Thanks a lot. It worked with:-

write.table(data, file = outputModelFilePath, append=T, sep=",",
col.names=F)

Regards,
Harsh Yadav

On Wed, Aug 11, 2010 at 11:53 PM, David Winsemius <dwinsem...@comcast.net>wrote:

>
> On Aug 11, 2010, at 10:29 PM, harsh yadav wrote:
>
>  Hi,
>>
>> I am writing a function that writes to a csv file for every call.
>>
>> However, for the subsequent calls, I want to append the data to the
>> existing
>> csv file without appending the column names again.
>>
>> I tried searching in the previous posts, but I am stuck with different
>> errors.
>>
>> Here is what I am doing (dataF is a data-frame):-
>>
>> outputFilePath <- paste(getwd(), "/", "outputModel.csv", sep="");
>>
>> counter <- 1
>> for (userid in userids){
>>      dataF <- getUserData(userid)
>>
>>       if(counter == 1){
>> write.csv(dataF, file = outputFilePath, append=F)
>> }else{
>> write.csv(dataF, file = outputFilePath, append=T,col.names=NA)
>> }
>>
>>      counter <- counter + 1
>> }
>>
>> I tried setting col.names = F (In append=T), but no good.
>>
>> Can anyone throw light on the correct usage.
>>
>
> Change second write.csv to write.table, add a sep argument.
>
> write.csv() ignores an append argument. The second line of its code is:
>
> for (argname in c("append", "col.names", "sep", "dec", "qmethod")) if
> (!is.null(Call[[argname]]))
>        warning(gettextf("attempt to set '%s' ignored", argname),
>            domain = NA)
>
> Didn't you believe the warnings?
>
> --
> David.
>
>>
>> Thanks in advance.
>>
>> Regards,
>> Harsh Yadav
>>
>>        [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help@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.
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to