Re: [R] run r script in r-fiddle

2017-10-30 Thread Suzen, Mehmet
Hi Frank,

You could upload your R source file to a public URL, for example to
github and read via RCurl,
as source do not support https as far as I know. Here is a working example.

library('RCurl')
tmatrix <- 
getURL("https://raw.githubusercontent.com/msuzen/isingLenzMC/master/R/isingUtils.R";)
eval(parse(text=tmatrix))

Not that you need to use raw URL for github file.

Best,
-m





On 30 October 2017 at 01:56, Frank Mei  wrote:
> Hi All,
>
> I want to know how to run an R file on my computer in R-Fiddle?
>
> I tried source("filename.r"), but not working.
>
> thanks,
> Frank
>
> [[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] Pass Parameters to RScript?

2017-10-30 Thread Morkus via R-help
Is it possible to pass parameters to an R Script, say, from Java or other 
language?

I did some searches, but came up blank.

Thanks very much in advance,

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
[[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] Pass Parameters to RScript?

2017-10-30 Thread Eric Berger
I did a simple search and got  hits immediately, e.g.
https://www.r-bloggers.com/passing-arguments-to-an-r-script-from-command-lines/


On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help 
wrote:

> Is it possible to pass parameters to an R Script, say, from Java or other
> language?
>
> I did some searches, but came up blank.
>
> Thanks very much in advance,
>
> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted
> email.
> [[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.
>

[[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] Count non-zero values in excluding NA Values

2017-10-30 Thread David L Carlson
You need to send plain text emails so that this does not happen to your data.

Assuming you want to ignore the first 2 columns:

> colSums(dta[, 3:7]>0, na.rm=TRUE)
  Raki Whisky   Wine   Beer Cigarettes 
   153153153153 32


David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Engin YILMAZ
Sent: Sunday, October 29, 2017 1:49 PM
To: Ek Esawi 
Cc: r-help@r-project.org
Subject: Re: [R] Count non-zero values in excluding NA Values

Dear R Staff

This is my file (www.fiscalforecasting.com/data.csv)

if you don't download this file, my dataset same as following

Year

Month

A

B

C

D

E

2005

July

0

*4*

NA

NA

*1*

2005

July

0

NA

NA

0

*9*

2005

July

NA

*4*

0

*1*

0

2005

July

*4*

0

*2*

*9*

NA

I try to count non-zero values which are not NA values for every *column*

*Sincerely*
*Engin YILMAZ*






2017-10-29 15:01 GMT+03:00 Ek Esawi :

> Since i could not see your data, the easiest thing comes to mind is 
> court values excluding NAs, is something like this
> sum(!is.na(x))
>
> Best of luck--EK
>
> On Sun, Oct 29, 2017 at 6:25 AM, Engin YILMAZ 
> wrote:
>
>> Dear R Staff
>>
>> You can see my data.csv file in the annex.
>>
>> I try to count non-zero values in dataset but I need to exclude NA in 
>> this calculation
>>
>> My code is very long (following),
>> How can I write this code more efficiently and shortly?
>>
>> ## [NA_Count] - Find NA values
>>
>> data.na =sapply(data[,3:ncol(data)], function(c) 
>> sum(length(which(is.na
>> (c)
>>
>>
>> ## [Zero] - Find zero values
>>
>> data.z=apply(data[,3:ncol(data)], 2, function(c) sum(c==0))
>>
>>
>> ## [Non-Zero] - Find non-zero values
>>
>> data.nz=nrow(data[,3:ncol(data)])- (data.na+data.z)
>>
>>
>> Sincerely
>> Engin YILMAZ
>>
>> > =link&utm_campaign=sig-email&utm_content=webmail>
>> Virus-free.
>> www.avast.com
>> > =link&utm_campaign=sig-email&utm_content=webmail>
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>> __
>> 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/posti 
>> ng-guide.html and provide commented, minimal, self-contained, 
>> reproducible code.
>>
>
>


--
*Saygılarımla*
Engin YILMAZ


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[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] run r script in r-fiddle

2017-10-30 Thread Martin Maechler
> Suzen, Mehmet 
> on Mon, 30 Oct 2017 11:16:30 +0100 writes:

> Hi Frank, You could upload your R source file to a public
> URL, for example to github and read via RCurl, as source
> do not support https as far as I know. 

well... but your knowledge is severely (:-) outdated.
Why did you not try first?

source("https://raw.githubusercontent.com/msuzen/isingLenzMC/master/R/isingUtils.R";)

works for me even in R 3.3.0 which is really outdated itself!

__
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] run r script in r-fiddle

2017-10-30 Thread Suzen, Mehmet
We were talking about r-fiddle. It gives error there [*], that's why I
suggested using RCurl.

> source("https://raw.githubusercontent.com/msuzen/isingLenzMC/master/R/isingUtils.R";)
...
unsupported URL scheme
Error : cannot open the connection
>

On 30 October 2017 at 15:51, Martin Maechler  wrote:
>> Suzen, Mehmet 
>> on Mon, 30 Oct 2017 11:16:30 +0100 writes:
>
> > Hi Frank, You could upload your R source file to a public
> > URL, for example to github and read via RCurl, as source
> > do not support https as far as I know.
>
> well... but your knowledge is severely (:-) outdated.
> Why did you not try first?
>
> source("https://raw.githubusercontent.com/msuzen/isingLenzMC/master/R/isingUtils.R";)
>
> works for me even in R 3.3.0 which is really outdated itself!
>

__
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] Pass Parameters to RScript?

2017-10-30 Thread Morkus via R-help
Thanks Eric,

I saw that page, too, but it states:

"This post describes how to pass external arguments to R when calling a Rscript 
with a command line."

Not what I'm trying to do.

Thanks for your reply.

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.

>  Original Message 
> Subject: Re: [R] Pass Parameters to RScript?
> Local Time: October 30, 2017 9:39 AM
> UTC Time: October 30, 2017 1:39 PM
> From: ericjber...@gmail.com
> To: Morkus 
> r-help@r-project.org 
>
> I did a simple search and got  hits immediately, e.g.
> https://www.r-bloggers.com/passing-arguments-to-an-r-script-from-command-lines/
>
> On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help  
> wrote:
>
>> Is it possible to pass parameters to an R Script, say, from Java or other 
>> language?
>>
>> I did some searches, but came up blank.
>>
>> Thanks very much in advance,
>>
>> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
>> [[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.
[[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] run r script in r-fiddle

2017-10-30 Thread Suzen, Mehmet
 Note that, looks like r-fiddle runs R 3.1.2.

__
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] Pass Parameters to RScript?

2017-10-30 Thread Eric Berger
I do not program in Java but it seems a Java program can make system calls
which would be equivalent to running from the command line, but done from
within a Java program. Not sure whether that would meet your needs and if
not why not. Just a suggestion.

Check out

http://www.java-samples.com/showtutorial.php?tutorialid=8



On Mon, Oct 30, 2017 at 5:10 PM, Morkus  wrote:

> Thanks Eric,
>
> I saw that page, too, but it states:
>
> "This post describes how to pass external arguments to *R* when calling a
> Rscript *with a command line.*"
>
> Not what I'm trying to do.
>
> Thanks for your reply.
>
> Sent from ProtonMail , Swiss-based encrypted
> email.
>
>
>  Original Message 
> Subject: Re: [R] Pass Parameters to RScript?
> Local Time: October 30, 2017 9:39 AM
> UTC Time: October 30, 2017 1:39 PM
> From: ericjber...@gmail.com
> To: Morkus 
> r-help@r-project.org 
>
> I did a simple search and got  hits immediately, e.g.
> https://www.r-bloggers.com/passing-arguments-to-an-r-
> script-from-command-lines/
>
>
> On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help 
> wrote:
>
>> Is it possible to pass parameters to an R Script, say, from Java or other
>> language?
>>
>> I did some searches, but came up blank.
>>
>> Thanks very much in advance,
>>
>> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted
>> email.
>> [[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/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[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] Pass Parameters to RScript?

2017-10-30 Thread Jeff Newmiller
I do not do this either, and technically this list is not the right place to 
ask this multi-language question, rather apparently [1] is because the 
alternative to using a system call is to use the Rserve service. You should use 
a search engine to look for info on using rjava and rserve.

[1] https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/
-- 
Sent from my phone. Please excuse my brevity.

On October 30, 2017 8:33:48 AM PDT, Eric Berger  wrote:
>I do not program in Java but it seems a Java program can make system
>calls
>which would be equivalent to running from the command line, but done
>from
>within a Java program. Not sure whether that would meet your needs and
>if
>not why not. Just a suggestion.
>
>Check out
>
>http://www.java-samples.com/showtutorial.php?tutorialid=8
>
>
>
>On Mon, Oct 30, 2017 at 5:10 PM, Morkus  wrote:
>
>> Thanks Eric,
>>
>> I saw that page, too, but it states:
>>
>> "This post describes how to pass external arguments to *R* when
>calling a
>> Rscript *with a command line.*"
>>
>> Not what I'm trying to do.
>>
>> Thanks for your reply.
>>
>> Sent from ProtonMail , Swiss-based encrypted
>> email.
>>
>>
>>  Original Message 
>> Subject: Re: [R] Pass Parameters to RScript?
>> Local Time: October 30, 2017 9:39 AM
>> UTC Time: October 30, 2017 1:39 PM
>> From: ericjber...@gmail.com
>> To: Morkus 
>> r-help@r-project.org 
>>
>> I did a simple search and got  hits immediately, e.g.
>> https://www.r-bloggers.com/passing-arguments-to-an-r-
>> script-from-command-lines/
>>
>>
>> On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help
>
>> wrote:
>>
>>> Is it possible to pass parameters to an R Script, say, from Java or
>other
>>> language?
>>>
>>> I did some searches, but came up blank.
>>>
>>> Thanks very much in advance,
>>>
>>> Sent from [ProtonMail](https://protonmail.com), Swiss-based
>encrypted
>>> email.
>>> [[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/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
>   [[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] Scatterplot3d :: Rotating x tick labels by x degrees

2017-10-30 Thread Alex Restrepo
Hi,

I would like to rotate the x axis tick labels by 45 degrees.   Using the code 
below, could someone please provide an example?   Many Thanks In Advance, Alex

library("scatterplot3d")
mydf=data.frame(rate=seq(158, 314)
,age=seq(1, 157)
,market_date=seq(as.Date("2000/1/1"), as.Date("2003/1/1"), 
by="7 days"))

mydf$market_date=as.Date(mydf$market_date, format="%Y-%m-%d")

scatterplot3d(mydf$market_date
  ,mydf$rate
  ,mydf$age
  ,x.ticklabs = seq(as.Date("2000/1/1"), as.Date("2003/1/1"), 
by="330 days"))


[[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] lasso and ridge regression

2017-10-30 Thread Gafar Matanmi Oyeyemi
Dear All

The problem is about regularization methods in multiple regression when the
independent variables are collinear. A modified regularization method with
two tuning parameters l1 and l2 and their product l1*l2 (Lambda 1 and
Lambda 2) such that l1 takes care of ridge property and l2 takes care of
LASSO property is proposed

The proposed method is given


The problem is how to adapt "glmnet" to accomplish our task.

The extract of the code used is reproduced as follows;

cv.ridge<- glmnet(x, y, family="gaussian", alpha=0,
lambda=lambda1, standardize=TRUE)
cv.lasso<- glmnet(x, y, family="gaussian", alpha=1,
lambda=lambda2, standardize=TRUE)
##weight
a=1/abs(matrix(coef(cv.ridge, s=lambda1)[, 1][2:(ncol(x)+1)]
))^1
b=1/abs(matrix(coef(cv.lasso, s=lambda2)[, 1][2:(ncol(x)+1)]
))^1
c=a*b
w4 <-a+b+c
w4[w4[,1] == Inf] <- 9
# Fit modified procedure
fit<- glmnet(x, y, family="gaussian",
alpha=alpha,lambda=lambda1+lambda2, penalty.factor=w4)

The question is; Does the code address the modified procedure in as shown
in the equation? If not, suggestions are please welcome.

Thanks


-- 
OYEYEMI, Gafar Matanmi (Ph.D)
Reader
Department of Statistics
University of Ilorin.
Area of Specialization: Multivariate Analysis, Statistical Quality Control
& Total Quality Management.
Tel: +2348052278655, +2348068241885

[[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.