Well I got my answer. Thanks again Rui.

On Mon, Aug 13, 2012 at 9:24 PM, Avishek Dutta <avishek.dutta03328@gmail.com
> wrote:

> Thanks A LOT, I will keep this in mind!
>
>
> On Mon, Aug 13, 2012 at 9:15 PM, Rui Barradas <ruipbarradas@sapo.pt>wrote:
>
>> If you intend to use R code in a package, or to source() it, or to be
>> called by an external script, it's ALWAYS a good idea to make the package
>> where the functions come from explicit. In this case, and given that it's
>> working, use
>>
>> foreign::write.dbf()
>>
>> This is an example of the rule above.
>>
>> Rui Barradas
>> Em 13-08-2012 19:57, Avishek Dutta escreveu:
>>
>>> Well, let me tell you, this R script is meant to call Kulldorff in
>>> SpatialEpi, it is invoked from python from inside ArcToolbox (maybe
>>> something to do with the session).
>>>
>>>   A python script/tool in arcmap takes shape file, etc and calls this R
>>> script to execute Kulldorff(). Hence the log is not directly available. I
>>> attach images:
>>>
>>> *caseI.jpg =
>>>
>>>
>>> ##library(foreign)
>>> ##write.dbf(df,"H:\\CIV\\**CIVProject\\DATA\\plotdata.**dbf")  ###THIS
>>> IS NOT
>>> WORKING!#$z0^$(#*o$&$^%%$%#^##**#
>>>
>>> foreign::write.dbf(df,"H:\\**CIV\\CIVProject\\DATA\\**plotdata.dbf")
>>>
>>> sessionInfo()*
>>>
>>> *caseII.jpg =
>>>
>>>
>>> sessionInfo()
>>>
>>> library(foreign)
>>> write.dbf(df,"H:\\CIV\\**CIVProject\\DATA\\plotdata.**dbf")  ###THIS IS
>>> NOT
>>> WORKING!#$z0^$(#*o$&$^%%$%#^##**#
>>>
>>> foreign::write.dbf(df,"H:\\**CIV\\CIVProject\\DATA\\**plotdata.dbf")*
>>>
>>>
>>> I am at a loss, I don't see any difference in the images.
>>>
>>> Avishek
>>>
>>>
>>>
>>> On Mon, Aug 13, 2012 at 8:38 PM, Rui Barradas <ruipbarradas@sapo.pt>
>>> wrote:
>>>
>>>  Hello,
>>>>
>>>> That means that there's a conflit between foreign::write.dbf and an
>>>> object
>>>> in your R session, probably from another package. See (and post) the
>>>> output
>>>> of
>>>>
>>>> sessionInfo()
>>>>
>>>> Rui Barradas
>>>> Em 13-08-2012 19:25, Avishek Dutta escreveu:
>>>>
>>>>  Hey,
>>>>>
>>>>> Strangley, this is working
>>>>>
>>>>> foreign::write.dbf(df,"H:\\****CIV\\CIVProject\\DATA\\****
>>>>> plotdata.dbf")
>>>>>
>>>>>
>>>>> and this is not
>>>>>
>>>>> library(foreign)
>>>>> write.dbf(df,"H:\\CIV\\****CIVProject\\DATA\\plotdata.****dbf")
>>>>>
>>>>>
>>>>> Maybe it is the syntax? Can you please test this..?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Avishek
>>>>> On Mon, Aug 13, 2012 at 6:33 PM, Rui Barradas <ruipbarradas@sapo.pt>
>>>>> wrote:
>>>>>
>>>>>   Hello,
>>>>>
>>>>>> It works with me,
>>>>>>
>>>>>>
>>>>>> d1 <- read.table(text="
>>>>>> ID simloglkhd
>>>>>> 1 6.72782753120542
>>>>>> 2 3.37685863056105
>>>>>> 3 3.28498537979818
>>>>>> 4 4.15888243774255
>>>>>> ", header=TRUE)
>>>>>> d1
>>>>>> foreign::write.dbf(d1, "test.dbf")
>>>>>>
>>>>>> d2 <- foreign::read.dbf("test.dbf")
>>>>>> identical(d1, d2) # FALSE
>>>>>> all(d1 == d2)     # TRUE
>>>>>>
>>>>>> attributes(d1) # d1 doesn't have a
>>>>>> attributes(d2) # 'data_types' attribute
>>>>>>
>>>>>> unlink("test.dbf") # clean-up
>>>>>>
>>>>>>
>>>>>> So maybe it's a R version/package version thing? I really don't know,
>>>>>> try
>>>>>> updating the package.
>>>>>> Also, use single forward slashes in the pathnames, the result is
>>>>>> exactly
>>>>>> the same, but more portable and less messy.
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> Rui Barradas
>>>>>>
>>>>>> Em 13-08-2012 12:13, Avishek Dutta escreveu:
>>>>>>
>>>>>>   Dear all,
>>>>>>
>>>>>>> I am basically a GIS user and am new to R.
>>>>>>>
>>>>>>> I am trying to write a data frame to a dbf file.
>>>>>>>
>>>>>>> *n.simulations <- 999
>>>>>>>
>>>>>>> binomial <- kulldorff(geo, cases, population, NULL, pop.upper.bound,
>>>>>>> n.simulations, alpha.level, plot)
>>>>>>> cluster <- binomial$most.likely.cluster$******location.IDs.included
>>>>>>> df <- data.frame(ID=seq(1,n.******simulations,by=1),
>>>>>>> simloglkhd=binomial$simulated.******log.lkhd)
>>>>>>>
>>>>>>> write.dbf(df,"H:\\CIV\\******CIVProject\\DATA\\plotdata.******dbf")*
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I am getting this error.
>>>>>>>
>>>>>>> *Error in c<logical="L", integer="N",numeric="F",******charachetr="C",
>>>>>>> :
>>>>>>>
>>>>>>>
>>>>>>>     invalid subscript type 'list'
>>>>>>> Calls: write.dbf -> <Anonymous>*
>>>>>>>
>>>>>>> If I added *
>>>>>>>
>>>>>>> write.dbf(df,"H:\\CIV\\******CIVProject\\DATA\\plotdata.**
>>>>>>> dbf",factor2char=TRUE,max_******char=254)
>>>>>>>
>>>>>>>
>>>>>>> *
>>>>>>>
>>>>>>> Now, I get error as these are unused arguments.
>>>>>>>
>>>>>>> If I write it to text file using write.table, the text file looks
>>>>>>> like
>>>>>>> this.
>>>>>>>
>>>>>>> *"ID" "simloglkhd"
>>>>>>>
>>>>>>> "1" 1 6.72782753120542
>>>>>>> "2" 2 3.37685863056105
>>>>>>> "3" 3 3.28498537979818
>>>>>>> "4" 4 4.15888243774255
>>>>>>> .
>>>>>>> .
>>>>>>> .*
>>>>>>>
>>>>>>>
>>>>>>> Can anyone please tell me what am I doing worng?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Avishek
>>>>>>>
>>>>>>>           [[alternative HTML version deleted]]
>>>>>>>
>>>>>>> ______________________________******________________
>>>>>>> R-help@r-project.org mailing list
>>>>>>> https://stat.ethz.ch/mailman/******listinfo/r-help<https://stat.ethz.ch/mailman/****listinfo/r-help>
>>>>>>> <https://**stat.ethz.ch/mailman/****listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>>>>> >
>>>>>>> <https://stat.**ethz.ch/**mailman/listinfo/r-**help<http://ethz.ch/mailman/listinfo/r-**help>
>>>>>>> <http**s://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>>>>> >
>>>>>>>
>>>>>>> PLEASE do read the posting guide http://www.R-project.org/**
>>>>>>> posting-guide.html <http://www.R-project.org/****posting-guide.html<http://www.R-project.org/**posting-guide.html>
>>>>>>> <http://www.**R-project.org/posting-guide.**html<http://www.R-project.org/posting-guide.html>
>>>>>>> >
>>>>>>>
>>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>>>
>>>>>>>
>>>>>>>
>>
>

	[[alternative HTML version deleted]]

