[R] reikon: A package to interact with Thomson Reuters Eikon from R

2015-08-16 Thread Juan Manuel Truppia
Hi, I'm developing a package to interact from R with Eikon, the Thomson
Reuters financial data platform (a la Rblpapi).
You can find the package in Bitbucket at
https://bitbucket.org/juancentro/reikon.
The package is fully functional, but requires testing and usage in other
environments than mine.
It has documentation and a vignette.
Please report any bugs directly in Bitbucket, and I would gladly accept
help with the development.

Regards

Juan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Running R in Server

2015-08-16 Thread Swagato Chatterjee
Hello,

I have written a R script which runs a regression of a dataset and saves
the result in a csv file.

Now this dataset has to be edited periodically which is done in a server. I
need to run the R script in a server so that the results can also be shared
in a server and used in a web application.

I have coded in R and have used R in windows. I have never used
Ubuntu/Linux. Is there a step by step guide on how to run a R code in
server?

Thanks and Regards,

-- 
Swagato Chatterjee

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Running R in Server

2015-08-16 Thread Swagato Chatterjee
Hello,

I have written a R script which runs a regression of a dataset and saves
the result in a csv file.

Now this dataset has to be edited periodically which is done in a server. I
need to run the R script in a server so that the results can also be shared
in a server and used in a web application.

I have coded in R and have used R in windows. I have never used
Ubuntu/Linux. Is there a step by step guide on how to run a R code in
server?

Thanks and Regards,

Swagato

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] All results not showing in console (very large dataset)

2015-08-16 Thread John Kane

Write the results into an object and use head()?

Quick example
dat1  -  data.frame(aa = sample(x, 500, replace = TRUE),
bb  = sample(x, 500, replace = TRUE),
cc  = sample(x, 500, replace = TRUE),
dd =sample(x, 500, replace = TRUE)
)

head(dat1)

see ?head for more details

John Kane
Kingston ON Canada


 -Original Message-
 From: hazel_kn...@hotmail.co.uk
 Sent: Sun, 16 Aug 2015 02:10:51 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] All results not showing in console (very large dataset)
 
 Hi,
 
 I have a very large dataset, and have run a simper test on it. However,
 the
 output is so large that I cannot see the first sets of results in the
 console. How can I view them? I have tried saving to text, but it only
 saves
 what's in the console.
 
 Or is there a way to report the first X number of results from each
 contrasting test? Or summarise each test result individually?
 
 Thanks!
 
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/All-results-not-showing-in-console-very-large-dataset-tp4711150.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] All results not showing in console (very large dataset)

2015-08-16 Thread Aureus
Hi, 

I have a very large dataset, and have run a simper test on it. However, the
output is so large that I cannot see the first sets of results in the
console. How can I view them? I have tried saving to text, but it only saves
what's in the console. 

Or is there a way to report the first X number of results from each
contrasting test? Or summarise each test result individually?

Thanks!





--
View this message in context: 
http://r.789695.n4.nabble.com/All-results-not-showing-in-console-very-large-dataset-tp4711150.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Error

2015-08-16 Thread Nikita Dinger
Dear Sir,

I am getting this error

Error in rep(xi, length.out = nvar) :
  attempt to replicate an object of type 'closure'

I have read through the websites but cant really comprehend what this means?
Need your help.

This is my code

complete - function(directory, idvec = 1:332) {
df - data.frame(id = integer(), nobs = integer())
for (id in idvec) {
filename - paste(directory, /,
  sprintf(%03d, as.integer(id)),
  .csv, sep = )
filename - list.files()
data - rbind(data, read.csv(filename[id]))
}
str(data)
for (id in idvec)
{nd - data.frame(id = id,
 nobs = nrow(na.omit(data)))
df - rbind(df, nd)
}
return(df)

}

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] difference between write.csv(...) and write.table(..., sep=, )

2015-08-16 Thread Berend Hasselman

 On 16-08-2015, at 16:38, Jinsong Zhao jsz...@yeah.net wrote:
 
 Hi there,
 
 I notice that write.csv is a wrap of write.table. However, I can't get the 
 same results using both functions. Here is a reproducible example:
 
  x - matrix(1:6, nrow =2)
  rownames(x) - letters[1:2]
  colnames(x) - LETTERS[1:3]
  write.csv(x, )
 ,A,B,C
 a,1,3,5
 b,2,4,6
  write.table(x, , sep = ,)
 A,B,C
 a,1,3,5
 b,2,4,6
 
 The difference of outputs from both functions is clear.
 
 Is it possible to get the same results of write.csv using write.table?
 

Yes. Read  the item col.names in the help for write.table and go to the section 
“CSV files”..

Use  write.table(x, , sep = ,, col.names=NA)

Learn to use R’s help.

Berend

 Any suggestions will be really appreciated. Thanks in advance.
 
 Best,
 Jinsong
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] cut variable within a loop

2015-08-16 Thread Janka VANSCHOENWINKEL
Hi David,

Thanks for your comment. I'll explain what I want to do. I explained it
already earlier but the explanation might have gone lost in some of the
emails.

The variable irrigation ranges from 0 to 100. (maybe not in de small sample
I gave, but in reality I have over 6 observations and there the
variable ranges from 0 to 100). I want to make (and use) 100 different
samples. The sample is based each time on the i that I put at the
beginning of the loop.

So:

i = 1: this means there are 2 subsets. One from 0-1, another from 1-100
i = 2: this means there are 2 subsets. One from 0-2, another from 2-100
i = 3: this means there are 2 subsets. One from 0-3, another from 3-100
i = 4: this means there are 2 subsets. One from 0-4, another from 4-100
...
i = 96: this means there are 2 subsets. One from 0-96, another from 96-100
i = 97: this means there are 2 subsets. One from 0-97, another from 97-100
i = 98: this means there are 2 subsets. One from 0-98, another from 98-100
i = 99: this means there are 2 subsets. One from 0-99, another from 99-100

It might be possible that i = 1 and i = 2 give the same results in the
small dataset. But in the full dataset all numbers are represented.

The cut2 function is capable of cutting a sample based on a number
supplied. Yet, when I tell him this number is i, then it doesn't work. If
instead I write that the number is 10, then it does work and it gives me 2
subsets from 0-10 and from 10-100.

Hope this is more clear!

Janka


2015-08-14 20:10 GMT+02:00 David Winsemius dwinsem...@comcast.net:


 When using a function in R you may need to supply an argument name. Are
 you expecting this to be the number of groups. I cannot decipher the intent
 here with such sparse commentary, but this call to `cut2` does not make
 sense to me. Perhaps you meant the number of groups?  in which case you
 need  cut2( Alldata$irrigation, g=i ), since the arguments to cut2 are not
 that same as the arguments to cut.

 At the moment you are implicitly sending on the first pass a 1 and then on
 the second pass a 2 to the second argument of cut2 which is the `breaks`
 argument. So you wold be getting two different factors each with different
 cut-point levels. I looked at your data and in point of fact there would be
 no difference since you have 29 zero values and no values between 0 and 1.

  table(cut2(dat$irrigation, 1))

 0 [  1,100]
2921
  table(cut2(dat$irrigation, 2))

 0 [  2,100]
2921




   levels(Alldata$irri)-c(0,1)
 
   Alldata_Rainfed-subset(Alldata, irri == 0)
   Alldata_Irrigation-subset(Alldata, irri == 1)
 
   Alldata_Rainfed$w-Alldata_Rainfed$b48+Alldata_Rainfed$b50
   Alldata_Irrigation$w-Alldata_Irrigation$b48+Alldata_Irrigation$b50
 
   OLS_Rainfed - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+
   ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+
   pdnsty+portsML+cities500k+rentedland+subsidies1+
   elevmean+elevrange+
   t_gravel+t_gravel+t_ph_h2o+t_silt+t_sand+
   AT+BE+DK+ES+FI+FR+GR+IE+IT+LU+NL+PT+SE+WDE+EDE+UK,
 weights=w,Alldata_Rainfed)
 
   attach(Alldata_Rainfed)
 
   CoefRainfed_ps1 - OLS_Rainfed$coeff[2]
   CoefRainfed_ps2 - OLS_Rainfed$coeff[3]
   CoefRainfed_ps3 - OLS_Rainfed$coeff[4]
   CoefRainfed_ps4 - OLS_Rainfed$coeff[5]
   CoefRainfed_ts1 - OLS_Rainfed$coeff[6]
   CoefRainfed_ts2 - OLS_Rainfed$coeff[7]
   CoefRainfed_ts3 - OLS_Rainfed$coeff[8]
   CoefRainfed_ts4 - OLS_Rainfed$coeff[9]
   CoefRainfed_ps1sq - OLS_Rainfed$coeff[10]
   CoefRainfed_ps2sq - OLS_Rainfed$coeff[11]
   CoefRainfed_ps3sq - OLS_Rainfed$coeff[12]
   CoefRainfed_ps4sq - OLS_Rainfed$coeff[13]
   CoefRainfed_ts1sq - OLS_Rainfed$coeff[14]
   CoefRainfed_ts2sq - OLS_Rainfed$coeff[15]
   CoefRainfed_ts3sq - OLS_Rainfed$coeff[16]
   CoefRainfed_ts4sq - OLS_Rainfed$coeff[17]
 
   attach(Alldata_Rainfed)
 
 
   ## MARGINAL EFFECTS SEASONAL and YEARLY and REGIONAL (EU or COUNTRY
 level)
   # Maar dit is dus de marginale impact per LnALVperHA?
 
   Alldata_Rainfed$MEts1 =
  CoefRainfed_ts1+2*CoefRainfed_ts1sq*Alldata_Rainfed$ts1
   Alldata_Rainfed$MEts2 =
  CoefRainfed_ts2+2*CoefRainfed_ts2sq*Alldata_Rainfed$ts2
   Alldata_Rainfed$MEts3 =
  CoefRainfed_ts3+2*CoefRainfed_ts3sq*Alldata_Rainfed$ts3
   Alldata_Rainfed$MEts4 =
  CoefRainfed_ts4+2*CoefRainfed_ts4sq*Alldata_Rainfed$ts4
   Alldata_Rainfed$MEt   = Alldata_Rainfed$MEts1 +
  Alldata_Rainfed$MEts2 + Alldata_Rainfed$MEts3 + Alldata_Rainfed$MEts4
 
   Alldata_Rainfed$MEps1 =
  CoefRainfed_ps1+2*CoefRainfed_ps1sq*Alldata_Rainfed$ps1
   Alldata_Rainfed$MEps2 =
  CoefRainfed_ps2+2*CoefRainfed_ps2sq*Alldata_Rainfed$ps2
   Alldata_Rainfed$MEps3 =
  CoefRainfed_ps3+2*CoefRainfed_ps3sq*Alldata_Rainfed$ps3
   Alldata_Rainfed$MEps4 =
  CoefRainfed_ps4+2*CoefRainfed_ps4sq*Alldata_Rainfed$ps4
   Alldata_Rainfed$MEp   = Alldata_Rainfed$MEps1 +
  Alldata_Rainfed$MEps2 + 

Re: [R] difference between write.csv(...) and write.table(..., sep=, )

2015-08-16 Thread Marc Schwartz

 On Aug 16, 2015, at 9:38 AM, Jinsong Zhao jsz...@yeah.net wrote:
 
 Hi there,
 
 I notice that write.csv is a wrap of write.table. However, I can't get the 
 same results using both functions. Here is a reproducible example:
 
  x - matrix(1:6, nrow =2)
  rownames(x) - letters[1:2]
  colnames(x) - LETTERS[1:3]
  write.csv(x, )
 ,A,B,C
 a,1,3,5
 b,2,4,6
  write.table(x, , sep = ,)
 A,B,C
 a,1,3,5
 b,2,4,6
 
 The difference of outputs from both functions is clear.
 
 Is it possible to get the same results of write.csv using write.table?
 
 Any suggestions will be really appreciated. Thanks in advance.
 
 Best,
 Jinsong


 write.csv(x)
,A,B,C
a,1,3,5
b”,2,4,6


 write.table(x, sep = ,, qmethod = double, col.names = NA)
,A,B,C
a,1,3,5
b”,2,4,6


Read the section on CSV files in ?write.table

Regards,

Marc Schwartz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] difference between write.csv(...) and write.table(..., sep=, )

2015-08-16 Thread Michael Dewey

I think that if you do ?write.csv and then page down to the section
entitled CSV files the mystery will be solved for you in the first few 
paragraphs.


On 16/08/2015 15:38, Jinsong Zhao wrote:

Hi there,

I notice that write.csv is a wrap of write.table. However, I can't get
the same results using both functions. Here is a reproducible example:

  x - matrix(1:6, nrow =2)
  rownames(x) - letters[1:2]
  colnames(x) - LETTERS[1:3]
  write.csv(x, )
,A,B,C
a,1,3,5
b,2,4,6
  write.table(x, , sep = ,)
A,B,C
a,1,3,5
b,2,4,6

The difference of outputs from both functions is clear.

Is it possible to get the same results of write.csv using write.table?

Any suggestions will be really appreciated. Thanks in advance.

Best,
Jinsong

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] difference between write.csv(...) and write.table(..., sep=, )

2015-08-16 Thread Jinsong Zhao

Hi there,

I notice that write.csv is a wrap of write.table. However, I can't get 
the same results using both functions. Here is a reproducible example:


 x - matrix(1:6, nrow =2)
 rownames(x) - letters[1:2]
 colnames(x) - LETTERS[1:3]
 write.csv(x, )
,A,B,C
a,1,3,5
b,2,4,6
 write.table(x, , sep = ,)
A,B,C
a,1,3,5
b,2,4,6

The difference of outputs from both functions is clear.

Is it possible to get the same results of write.csv using write.table?

Any suggestions will be really appreciated. Thanks in advance.

Best,
Jinsong

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Error

2015-08-16 Thread Bert Gunter
What do you think data is in:

rbind(data, read.csv(filename[id]))

str(data) ## before running your function

will show you that it is probably the built in function data() which
is probably the source of your error.


Cheers,
Bert


Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Sun, Aug 16, 2015 at 2:01 AM, Nikita Dinger dingernik...@gmail.com wrote:
 Dear Sir,

 I am getting this error

 Error in rep(xi, length.out = nvar) :
   attempt to replicate an object of type 'closure'

 I have read through the websites but cant really comprehend what this means?
 Need your help.

 This is my code

 complete - function(directory, idvec = 1:332) {
 df - data.frame(id = integer(), nobs = integer())
 for (id in idvec) {
 filename - paste(directory, /,
   sprintf(%03d, as.integer(id)),
   .csv, sep = )
 filename - list.files()
 data - rbind(data, read.csv(filename[id]))
 }
 str(data)
 for (id in idvec)
 {nd - data.frame(id = id,
  nobs = nrow(na.omit(data)))
 df - rbind(df, nd)
 }
 return(df)

 }

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Error while submission

2015-08-16 Thread Nikita Dinger
I have completed part 2 of the assignment and am getting the desired output.
But on submitting the code, it shows as the answer is incorrect along with
this message:

function (..., list = character(), package = NULL, lib.loc = NULL, verbose
= getOption(verbose),
envir = .GlobalEnv)
Result:  Sorry, your answer was incorrect.

The following is my code for part 2:

complete - function(directory, idvec = 1:332) {
df - data.frame(id = integer(), nobs = integer())
for (id in idvec) {
filename - paste(directory, /,
  sprintf(%03d, as.integer(id)),
  5.csv, sep = )
filename - list.files()
dat - rbind(dat, read.csv(filename[id]))
}
str(data)
for (id in idvec)
{nd - data.frame(id = id,
 nobs = nrow(na.omit(dat)))
df - rbind(df, nd)
}
return(df)

}

I am using R 3.2.1 on a Windows 8 laptop.

How shall I solve this?

Thanks and regards
Nikita

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] cut variable within a loop

2015-08-16 Thread David Winsemius

On Aug 16, 2015, at 8:57 AM, Janka VANSCHOENWINKEL wrote:

 Hi David,
 
 Thanks for your comment. I'll explain what I want to do. I explained it 
 already earlier but the explanation might have gone lost in some of the 
 emails. 

I now see that you did explain that you wanted the positional matching in cut2 
as a break. The code runs without error on my machine, but delivers a lot of 
warnings about masking. You are repeatedly using attach on the same named 
objects. Using `attach` in programming is generally not a good idea. In 
interactive use it is safer to use `with`, although that is not generally 
considered safe in programming, either.

You need to do a better job of nailing down the source of the difficulty what 
ever it might be. While you say the cut2 function doesn't work, you don't 
actually give evidence of failure.

It's fairly simple to show that your theory about why your code fails in some 
way as being due to cut2 failing to accept an i value inside an lapply call 
is just wrong:

 o - lapply(1:3, function(i) { cut2( 0:10, i) } )
 o
[[1]]
 [1]  0  [ 1,10] [ 1,10] [ 1,10] [ 1,10] [ 1,10] [ 1,10]
 [8] [ 1,10] [ 1,10] [ 1,10] [ 1,10]
Levels:  0 [ 1,10]

[[2]]
 [1] [ 0, 2) [ 0, 2) [ 2,10] [ 2,10] [ 2,10] [ 2,10] [ 2,10]
 [8] [ 2,10] [ 2,10] [ 2,10] [ 2,10]
Levels: [ 0, 2) [ 2,10]

[[3]]
 [1] [ 0, 3) [ 0, 3) [ 0, 3) [ 3,10] [ 3,10] [ 3,10] [ 3,10]
 [8] [ 3,10] [ 3,10] [ 3,10] [ 3,10]
Levels: [ 0, 3) [ 3,10]


You also have two different definitions of weight2 for your irrigation model:

Alldata_Irrigation$weight2-Alldata_Irrigation$sys02*Alldata_Irrigation$se025
Alldata_Irrigation$weight2-Alldata_Irrigation$b48+Alldata_Irrigation$b50

-- 
David
 
 The variable irrigation ranges from 0 to 100. (maybe not in de small sample I 
 gave, but in reality I have over 6 observations and there the variable 
 ranges from 0 to 100). I want to make (and use) 100 different samples. The 
 sample is based each time on the i that I put at the beginning of the loop.
 
 So:
 
 i = 1: this means there are 2 subsets. One from 0-1, another from 1-100
 i = 2: this means there are 2 subsets. One from 0-2, another from 2-100
 i = 3: this means there are 2 subsets. One from 0-3, another from 3-100
 i = 4: this means there are 2 subsets. One from 0-4, another from 4-100
 ...
 i = 96: this means there are 2 subsets. One from 0-96, another from 96-100
 i = 97: this means there are 2 subsets. One from 0-97, another from 97-100
 i = 98: this means there are 2 subsets. One from 0-98, another from 98-100
 i = 99: this means there are 2 subsets. One from 0-99, another from 99-100
 
 It might be possible that i = 1 and i = 2 give the same results in the small 
 dataset. But in the full dataset all numbers are represented.
 
 The cut2 function is capable of cutting a sample based on a number 
 supplied. Yet, when I tell him this number is i, then it doesn't work. If 
 instead I write that the number is 10, then it does work and it gives me 2 
 subsets from 0-10 and from 10-100.
 
 Hope this is more clear!
 
 Janka
 
 
 2015-08-14 20:10 GMT+02:00 David Winsemius dwinsem...@comcast.net:
 
 When using a function in R you may need to supply an argument name. Are you 
 expecting this to be the number of groups. I cannot decipher the intent here 
 with such sparse commentary, but this call to `cut2` does not make sense to 
 me. Perhaps you meant the number of groups?  in which case you need  
 cut2( Alldata$irrigation, g=i ), since the arguments to cut2 are not that 
 same as the arguments to cut.
 
 At the moment you are implicitly sending on the first pass a 1 and then on 
 the second pass a 2 to the second argument of cut2 which is the `breaks` 
 argument. So you wold be getting two different factors each with different 
 cut-point levels. I looked at your data and in point of fact there would be 
 no difference since you have 29 zero values and no values between 0 and 1.
 
  table(cut2(dat$irrigation, 1))
 
 0 [  1,100]
2921
  table(cut2(dat$irrigation, 2))
 
 0 [  2,100]
2921
 
 
 
 
   levels(Alldata$irri)-c(0,1)
 
   Alldata_Rainfed-subset(Alldata, irri == 0)
   Alldata_Irrigation-subset(Alldata, irri == 1)
 
   Alldata_Rainfed$w-Alldata_Rainfed$b48+Alldata_Rainfed$b50
   Alldata_Irrigation$w-Alldata_Irrigation$b48+Alldata_Irrigation$b50
 
   OLS_Rainfed - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+
   ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+
   pdnsty+portsML+cities500k+rentedland+subsidies1+
   elevmean+elevrange+
   t_gravel+t_gravel+t_ph_h2o+t_silt+t_sand+
   AT+BE+DK+ES+FI+FR+GR+IE+IT+LU+NL+PT+SE+WDE+EDE+UK,
 weights=w,Alldata_Rainfed)
 
   attach(Alldata_Rainfed)
 
   CoefRainfed_ps1 - OLS_Rainfed$coeff[2]
   CoefRainfed_ps2 - OLS_Rainfed$coeff[3]
   CoefRainfed_ps3 - OLS_Rainfed$coeff[4]
   CoefRainfed_ps4 - OLS_Rainfed$coeff[5]
   

Re: [R] Error while submission

2015-08-16 Thread Sarah Goslee
On Sun, Aug 16, 2015 at 12:39 PM, Nikita Dinger dingernik...@gmail.com wrote:
 I have completed part 2 of the assignment and am getting the desired output.
 But on submitting the code, it shows as the answer is incorrect along with
 this message:

This list is not an appropriate place for you to ask for help with
your homework. Your course should have a way for you to get assistance
from instructor/TA/other students; this is not that way.

We on R-help can't do much for you, since none of us have any idea
what part 2 might be, and the list has a no-homework policy anyway.

 function (..., list = character(), package = NULL, lib.loc = NULL, verbose
 = getOption(verbose),
 envir = .GlobalEnv)
 Result:  Sorry, your answer was incorrect.

 The following is my code for part 2:

 complete - function(directory, idvec = 1:332) {
 df - data.frame(id = integer(), nobs = integer())
 for (id in idvec) {
 filename - paste(directory, /,
   sprintf(%03d, as.integer(id)),
   5.csv, sep = )
 filename - list.files()
 dat - rbind(dat, read.csv(filename[id]))
 }
 str(data)
 for (id in idvec)
 {nd - data.frame(id = id,
  nobs = nrow(na.omit(dat)))
 df - rbind(df, nd)
 }
 return(df)

 }

 I am using R 3.2.1 on a Windows 8 laptop.

 How shall I solve this?

 Thanks and regards
 Nikita

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Error while submission

2015-08-16 Thread Jeff Newmiller
Go to where you were given this assignment and ask them for help.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On August 16, 2015 9:39:28 AM PDT, Nikita Dinger dingernik...@gmail.com wrote:
I have completed part 2 of the assignment and am getting the desired
output.
But on submitting the code, it shows as the answer is incorrect along
with
this message:

function (..., list = character(), package = NULL, lib.loc = NULL,
verbose
= getOption(verbose),
envir = .GlobalEnv)
Result:  Sorry, your answer was incorrect.

The following is my code for part 2:

complete - function(directory, idvec = 1:332) {
df - data.frame(id = integer(), nobs = integer())
for (id in idvec) {
filename - paste(directory, /,
  sprintf(%03d, as.integer(id)),
  5.csv, sep = )
filename - list.files()
dat - rbind(dat, read.csv(filename[id]))
}
str(data)
for (id in idvec)
{nd - data.frame(id = id,
 nobs = nrow(na.omit(dat)))
df - rbind(df, nd)
}
return(df)

}

I am using R 3.2.1 on a Windows 8 laptop.

How shall I solve this?

Thanks and regards
Nikita

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Error - cannot open file 'specdata/001.csv': No such file or directory; Windows 8, R Version 3.2.1

2015-08-16 Thread Anthoni, Peter (IMK)
Hi Nikita,

To check whether the files are really there, run the following at the R prompt:

getwd()
list.files()

 *C:/Users/acer/My Documents/specdata/rprog-data-specdata/specdata*

Your working path looks like you either need to set it to:
  C:/Users/acer/My Documents/specdata/rprog-data-specdata
or change your read.csv to:
   df - read.csv(001.csv)

cheers
Peter



 On 15 Aug 2015, at 19:06, Nikita Dinger dingernik...@gmail.com wrote:
 
 I am having a problem in opening the excel files in specdata folder.
 
 I have completed coding the R program for the assignment but when I run the
 following commands in the R console,
 
 *source(pollutantmean.R)*
 * pollutantmean(specdata, nitrate, 23)*
 
 I get an error message stating
 
 *Error in file(file, rt) : cannot open the connection*
 *In addition: Warning message:*
 *In file(file, rt) :*
 *  cannot open file 'specdata/023.csv': No such file or directory*
 
 I tried everything and reset my Working Directory to
 
 
 *C:/Users/acer/My Documents/specdata/rprog-data-specdata/specdata*
 
 After the last specdata folder are all the excel sheets numbered 001 to 332.
 
 I searched the internet and all other options available, and got a solution
 to open it using the following command:
 
 *df - read.csv(specdata/001.csv)*
 
 
 This generated the following error message
 
 *Error in file(file, rt) : cannot open the connection*
 *In addition: Warning message:*
 *In file(file, rt) :*
 *  cannot open file 'specdata/001.csv': No such file or directory*
 
 I have tried various other commands also such as
 
 
 *path - c(paste(./,directory, /,formatC(id[i], width=3,
 flag=0),.csv,sep=))*
 
 However, all the commands show some error.
 
 What shall I do?
 I am using the 3.2.1 version of R on a Windows 8 laptop.
 
 Regards,
 Nikita Dinger
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.