[R] Would you please check my program

BINDU RANI binduphysics at gmail.com
Sun Mar 1 12:15:35 CET 2009


Dear All
                   I have written a program in R for the calculation
of Structure Function(SF). I have attached my data here which is the
data of 3rd attachment here. ( they have calculated SF and p0lotted
it. ) I want to check my results I have tried it on already published
results. I think my program is not giving me the same results. & I do
not know where I am making mistake. The attachment is the other paper
in which SF is clearly defined. If you have some time can you please
check my program.

My program is :

************************************************************************************************************************
data = read.table("Input.dat")
names(data) = c("tm","mg")
attach(data)
n = length(mg)
for(k in 1:(n-1))
{
tlag = diff(tm,k)
mlag = diff(mg,k)
for(i in 1:length(tlag))
{
cat(tlag[i],mlag[i],"\n")
}
}
#sort the output data(according to tlag)  out put file name = "structureA.dat" %
data = read.table("structureA.dat")
names(data)=c("dt","mg")
attach(data)
uniquedt = unique(dt)
for(i in min(uniquedt):max(uniquedt))
{
cmg = c(data$mg[data$dt == i])
cN = c(data$dt[data$dt == i])
pair = sum(cN)
sff = (sum(cmg*cmg))/(pair+i)
cat(i,sff,"\n")
}
detach(data)

*****************************************************************************************************************


--
Bindu Rani
JRF
ARIES
Nainital



--
Bindu Rani
JRF
ARIES
Nainital



--
Bindu Rani
JRF
ARIES
Nainital



--
Bindu Rani
JRF
ARIES
Nainital


More information about the R-help mailing list