Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-27 Thread Bos, Roger
Akhilesh,

I don't know if I am adding signal or noise here, but I installed R 3.5.0 
yesterday and installed data.table just fine, but I have Rtools installed.  
"Building packages from source" may sound intimidating, but Rtools is really 
easy to install and once installed, it does all the work for you.

Thanks,

Roger


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Fox, John
Sent: Friday, April 27, 2018 9:21 AM
To: Akhilesh Singh
Cc: r-help mailing list
Subject: Re: [R] Package 'data.table' in version R-3.5.0 not successfully being 
installed

Dear Akhilesh,

I hope that it's clear that the Windows binary I provided for the data.table 
package is a temporary solution, and that the maintainer should fix the package 
so that it passes its own tests. You should be careful using the package in its 
current state.

Best,
 John

> -Original Message-
> From: Akhilesh Singh [mailto:akhileshsingh.i...@gmail.com]
> Sent: Friday, April 27, 2018 4:10 AM
> To: Fox, John 
> Cc: r-help mailing list 
> Subject: Re: [R] Package 'data.table' in version R-3.5.0 not successfully 
> being
> installed
>
> Dear Dr. John Fox,
>
> The solution provided by you has worked. I downloaded the binary file of
> data.table package made available your website
>   >,
> installed it in R and RStudio. And I happy to report that it has successfully
> worked. Many thanks to you, and to other members of R-team who have tried
> help me.
>
>
> With regards,
>
>
> Dr. A.K. Singh
>
> On Thu, Apr 26, 2018 at 8:03 PM, Fox, John   > wrote:
>
>
> Dear A.K. Singh,
>
> As you discovered, the data.table package has an error under R 3.5.0
> that prevents CRAN from distributing a Windows binary for the package. The
> reason that you weren't able to install the package from source is apparently
> that you haven't installed the R package-building tools for Windows. See
>  project.org/bin/windows/Rtools/> >.
>
> Because a number of users of my Rcmdr and car packages have
> contacted me with a similar issue, as a temporary work-around I've placed a
> Windows binary for the data.table package on my website at
>   >.
> You should be able to install the package from there via the command
>
>
> install.packages("https://socialsciences.mcmaster.ca/jfox/.Pickup/data.table_
> 1.10.4-3.zip
>  ",
> repos=NULL, type="win.binary")
>
> I expect that this problem will go away when the maintainer of the
> data.table package fixes the error.
>
> I hope this helps,
>  John
>
> --
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> Web: socialsciences.mcmaster.ca/jfox/
> 
>
>
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org  boun...@r-project.org> ] On Behalf Of Akhilesh
> > Singh
> > Sent: Thursday, April 26, 2018 8:08 AM
> > To: r-help mailing list mailto:r-help@r-
> project.org> >
> > Subject: [R] Package 'data.table' in version R-3.5.0 not successfully
> > being installed
> >
> > Dear Sir,
> >
> > I am using R on Windows OS platform. I upgraded my R-system to
> version
> > R-3.5.0. While upgrading my libraries in R as well as in RStudio, I am
> > stuck up in the package 'data.table', which is required by many
> other
> > packages in R-codes in my R-Markdown files.
> >
> > I tried to install 'data.table' from "USA-berkely" and "UK-bristol"  as
> > well as "RStudio" mirrors when the following errors are being
> shown:
> >
> > From  USA-berkely and UK-bristol mirrors:
> > =
> > Package which is only available in source form, and may need
> >   compilation of C/C++/Fortran: ‘data.table’
> >   These will not be installed
> > Warning message:
> > In download.file(url, destfile = f, quiet = TRUE) :
> >   InternetOpenUrl failed: ''
> >
> > From RStudio mirror:
> > 
> > Package which is only available in source form, and may need
> compilation
> > of
> >   C/C++/Fortran: ‘data.table’
> >   These will not be installed
> >
> > Afterwards, I consulted google users, I downloaded the source
> package:
> > "data.table_1.10.4-3.tar.gz" from CRAN, stored it on desktop, and
> tried
> > following command for installing from source only:
> >
> >
> > install.packages("C:\\Users\\Dr. A.K.
> > Singh\\Desktop\\data.table_1.10.4-3.tar.gz", repos = NULL,
> > type="source")
> >
> > This generated following errors messages:
> >
> > > install.packages("C:\\Users\\Dr. A.K.
> > Singh\\Desktop

Re: [R] I cannot run R.EXE or RSCRIPT.EXE

2017-05-05 Thread Bos, Roger
Dominik,

Folders with spaces can be very tricky sometimes.  In my case single quotes 
didn't work, but double quotes did (see my example below).  Adding the full 
path to your PATH variable with eliminate the need to specify the full path, 
making it much easier.

Thanks,

Roger


Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\bosr>C:\Program Files\R\R-3.3.3\bin\R.exe
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\bosr>'C:\Program Files\R\R-3.3.3\bin\R.exe'
The filename, directory name, or volume label syntax is incorrect.

C:\Users\bosr>"C:\Program Files\R\R-3.3.3\bin\R.exe"

R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
Sent: Friday, May 05, 2017 6:01 AM
To: Dominik Szewczyk; r-help@r-project.org
Subject: Re: [R] I cannot run R.EXE or RSCRIPT.EXE

On 04/05/2017 4:08 PM, Dominik Szewczyk wrote:
> I cannot run R.EXE or RSCRIPT.EXE. It produces this error:
>
>
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
>
>
> I have attempted to put quotes around the full path including the executable 
> and also running the exectuable from within the path itself with the same 
> result. The only way I can do this is to move the installation from 
> C:\Program Files\R\R-3.4.0 to C:\R\..
>
>
> Is this a limitation of the program itself?

It sounds like a limitation of the way you're trying to run them, which you 
haven't told us.

Duncan Murdoch

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



This message and any attachments are for the intended recipient’s use only. 
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.




__
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] selecting colors to be used in a plot

2017-01-25 Thread Bos, Roger
Thanks Richard.  That worked beautifully!


-Original Message-
From: Richard M. Heiberger [mailto:r...@temple.edu]
Sent: Wednesday, January 25, 2017 12:58 PM
To: Bos, Roger
Cc: R Help R
Subject: Re: [R] selecting colors to be used in a plot

This package uses a nonstandard name colorset.
This is based on the help example for
?charts.PerformanceSummary

>  data(edhec)
>  charts.PerformanceSummary(edhec[,c(1,13)])
>  charts.PerformanceSummary(edhec[,c(1,13)],
> colorset=c("red","blue"))
>

On Wed, Jan 25, 2017 at 12:44 PM, Bos, Roger  wrote:
> My specific question relates to function charts.PerformanceSummary in package 
> PerformanceAnalytics, but the underlying problem is probably with base plot.
>
> In this sample code we see a chart with 10 groupings.  Apparently 10 
> groupings is bigger than the number of default colors (8), so red and black 
> are recycled, but in my case groups 1 and 2 are the worst and groups 9 and 10 
> are the best, so if the same red and black colors are used for both it gets 
> confusing:
>
> Minimal working example with recycled colors:
>
> dates <-
> as.Date(c('1970-01-02','1970-01-03','1970-01-04','1970-01-05','1970-01
> -06','1970-01-07','1970-01-08','1970-01-09','1970-01-10','1970-01-11')
> , format="%Y-%m-%d") x <- as.xts(matrix(runif(100),10,10),
> order.by=dates)
> names(x) <- paste("Group", 1:10)
> charts.PerformanceSummary(x, geometric=FALSE, ylog=TRUE, main='Log
> Return by Column')
>
> Since the documentation says you can pass other variables to plot, I try to 
> use “col” to set my own colors:
>
> colors <-
> c("#A6CEE3","#1F78B4","#B2DF8A","#33A02C","#FB9A99","#E31A1C","#FDBF6F
> ","#FF7F00","#CAB2D6","#6A3D9A") charts.PerformanceSummary(x,
> geometric=FALSE, ylog=TRUE, col = colors, main='Log Return by Column')
>
> Error in plot.xy(xy.coords(x, y), type = type, ...) :
>   formal argument "col" matched by multiple actual arguments
>
> I am sure it is possible to produce a plot using more than 8 colors.  Would 
> someone please point out what I am doing wrong?  Thanks in advance.
>
>
>
> This message and any attachments are for the intended recipient’s use only. 
> This message may contain confidential, proprietary or legally privileged 
> information. No right to confidential or privileged treatment of this message 
> is waived or lost by an error in transmission.
> If you have received this message in error, please immediately notify the 
> sender by e-mail, delete the message, any attachments and all copies from 
> your system and destroy any hard copies. You must not, directly or 
> indirectly, use, disclose, distribute, print or copy any part of this message 
> or any attachments if you are not the intended recipient.
>
>
>
>
> __
> 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.



This message and any attachments are for the intended recipient’s use only. 
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.




__
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] selecting colors to be used in a plot

2017-01-25 Thread Bos, Roger
My specific question relates to function charts.PerformanceSummary in package 
PerformanceAnalytics, but the underlying problem is probably with base plot.

In this sample code we see a chart with 10 groupings.  Apparently 10 groupings 
is bigger than the number of default colors (8), so red and black are recycled, 
but in my case groups 1 and 2 are the worst and groups 9 and 10 are the best, 
so if the same red and black colors are used for both it gets confusing:

Minimal working example with recycled colors:

dates <- 
as.Date(c('1970-01-02','1970-01-03','1970-01-04','1970-01-05','1970-01-06','1970-01-07','1970-01-08','1970-01-09','1970-01-10','1970-01-11'),
 format="%Y-%m-%d")
x <- as.xts(matrix(runif(100),10,10), order.by=dates)
names(x) <- paste("Group", 1:10)
charts.PerformanceSummary(x, geometric=FALSE, ylog=TRUE, main='Log Return by 
Column')

Since the documentation says you can pass other variables to plot, I try to use 
“col” to set my own colors:

colors <- 
c("#A6CEE3","#1F78B4","#B2DF8A","#33A02C","#FB9A99","#E31A1C","#FDBF6F","#FF7F00","#CAB2D6","#6A3D9A")
charts.PerformanceSummary(x, geometric=FALSE, ylog=TRUE, col = colors, 
main='Log Return by Column')

Error in plot.xy(xy.coords(x, y), type = type, ...) :
  formal argument "col" matched by multiple actual arguments

I am sure it is possible to produce a plot using more than 8 colors.  Would 
someone please point out what I am doing wrong?  Thanks in advance.



This message and any attachments are for the intended recipient’s use only. 
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.




__
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] getting data from a webpage

2016-12-19 Thread Bos, Roger
Glenn,

R Studio did a webinar on Web Scraping using the rvest package that made it 
look really easy.  I haven't gotten around to using it yet, but the video 
should be on their website somewhere.  The link below is the PDF of the slides. 
 It should be education and will probably give you what you need to know to get 
the data you need:

https://github.com/rstudio/webinars/blob/master/32-Web-Scraping/02-Web-Scraping.pdf



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Glenn Schultz
Sent: Monday, December 19, 2016 10:02 AM
To: R Help R
Subject: [R] getting data from a webpage

All,

I was getting data swap rate data from the St. Louis Fed FRED database via the 
FRED API.  ICE stopped reporting to FRED and now I must get the data from the 
ICE website.  I would like to use httr to get the data but I really don't know 
much about website design.  I think the form redirects but I am not sure that 
is the case much less how to identify what website the form redirects to.  I 
used the developer and inspect elements to come up with the below which failed 
miserably.  In addition, I purchase the book Automated Data Collection with R 
which has not been to useful helping me to understand how to navigate pages 
using forms and redirects.

Can anyone provide a good reference to understanding how to get data from 
websites using forms and redirects.  Specifically,

How find the actual webpage that on must submit the POST request.
How to the find the redirected page which really has the data.

Best,
Glenn

library(httr)
#get initial cookies
h <- handle("https://www.theice.com/";)
GET(handle = h)
POST(url = "https://www.theice.com/marketdata/reports/180";,
body = list(reportDate = "15-Dec-2016", SeriesNameAnRunCode_chosen = "USD Rates 
1100"), encode = "form", handle = h) page <- GET(url= 
"https://www.theice.com/marketdata/reports/icebenchmarkadmin/ISDAFIXHistoricalRates.shtml";,
handle = h)
__
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.



This message and any attachments are for the intended recipient’s use only. 
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.




__
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] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
Bill,

Thanks for your help.  Not that I ever doubted you, but I tried your method on 
my actual data and I can confirm it does work.  I guess I am still wondering 
why using .export in foreach doesn’t allow the variable to be found as that 
method would seem to be the most straightforward.

Thanks again for your help!

Roger




This message and any attachments are for the intended recipient’s use only.

This message may contain confidential, proprietary or legally privileged

information. No right to confidential or privileged treatment

of this message is waived or lost by an error in transmission.

If you have received this message in error, please immediately

notify the sender by e-mail, delete the message, any attachments and all

copies from your system and destroy any hard copies.  You must

not, directly or indirectly, use, disclose, distribute,

print or copy any part of this message or any attachments if you are not

the intended recipient.
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Friday, October 07, 2016 11:57 AM
To: Bos, Roger
Cc: R-help
Subject: Re: [R] weighted regression inside FOREACH loop

Using the temporary child environment works because model.frame, hence lm, 
looks for the variables used in the formula, subset, and weights arguments 
first in the data argument and then, if the data argument is not an 
environment, in the environment of the formula argument.

Bill Dunlap
TIBCO Software
wdunlap tibco.com<http://tibco.com>

On Fri, Oct 7, 2016 at 8:18 AM, William Dunlap 
mailto:wdun...@tibco.com>> wrote:
A more general way is to change the environment of your formula to
a child of its original environment and add variables like 'weights' or
'subset' to the child environment.  Since you change the environment
inside a function call it won't affect the formula outside of the function call.
E.g.

fmla <- as.formula("y ~ .")

models <- foreach(d=1:10, .combine=rbind, .errorhandling='remove') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  localEnvir <- new.env(parent=environment(fmla))
  environment(fmla) <- localEnvir
  localEnvir$weights <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=weights)
  return(mod$coef)
}
models
#  (Intercept) x
#result.1  -0.16910860 1.0022022
#result.2   0.03326814 0.9968325
#result.3  -0.08177174 1.0022907
#...
environment(fmla)
#



Bill Dunlap
TIBCO Software
wdunlap tibco.com<http://tibco.com>

On Fri, Oct 7, 2016 at 7:44 AM, Bos, Roger 
mailto:roger@rothschild.com>> wrote:
All,

I figured out how to get it to work, so I am posting the solution in case 
anyone is interested.  I had to use attr to set the weights as an attribute of 
the data object for the linear model.  Seems convoluted, but anytime I tried to 
pass a named vector as the weights the foreach loop could not find the 
variable, even if I tried exporting it.  If anybody knows of a better way 
please let me know as this does not seem ideal to me, but it works.

library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
fmla <- as.formula("y ~ .")
models <- foreach(d=1:10, .combine=rbind, .errorhandling='pass') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  attr(datdf, "weights") <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=attr(data, "weights"))
  return(mod$coef)
}
Models





-Original Message-
From: R-help 
[mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] On 
Behalf Of Bos, Roger
Sent: Friday, October 07, 2016 9:25 AM
To: R-help
Subject: [R] weighted regression inside FOREACH loop

I have a foreach loop that runs regressions in parallel and works fine, but 
when I try to add the weights parameter to the regression the coefficients 
don’t get stored in the “models” variable like they are supposed to.  Below is 
my reproducible example:

library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
fmla <- as.formula("y ~ .")
models <- foreach(d=1:10, .combine=rbind, .errorhandling='remove') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  weights <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=weights)
  #mod <- lm(fmla, data=datdf)
  return(mod$coef)
}
models

You can change the commenting on the two “mod <-“ lines to see that the 
non-weighted one works and the weighted regression doesn’t work.  I tried using 
.export="weights" in the foreach line, but R says that weights is already being 
exported.

Thanks in advance for any suggestions.





***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged 
information. No right to conf

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
All,

I figured out how to get it to work, so I am posting the solution in case 
anyone is interested.  I had to use attr to set the weights as an attribute of 
the data object for the linear model.  Seems convoluted, but anytime I tried to 
pass a named vector as the weights the foreach loop could not find the 
variable, even if I tried exporting it.  If anybody knows of a better way 
please let me know as this does not seem ideal to me, but it works.

library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
fmla <- as.formula("y ~ .")
models <- foreach(d=1:10, .combine=rbind, .errorhandling='pass') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  attr(datdf, "weights") <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=attr(data, "weights"))
  return(mod$coef)
}
Models





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bos, Roger
Sent: Friday, October 07, 2016 9:25 AM
To: R-help
Subject: [R] weighted regression inside FOREACH loop

I have a foreach loop that runs regressions in parallel and works fine, but 
when I try to add the weights parameter to the regression the coefficients 
don’t get stored in the “models” variable like they are supposed to.  Below is 
my reproducible example:

library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
fmla <- as.formula("y ~ .")
models <- foreach(d=1:10, .combine=rbind, .errorhandling='remove') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  weights <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=weights)
  #mod <- lm(fmla, data=datdf)
  return(mod$coef)
}
models

You can change the commenting on the two “mod <-“ lines to see that the 
non-weighted one works and the weighted regression doesn’t work.  I tried using 
.export="weights" in the foreach line, but R says that weights is already being 
exported.

Thanks in advance for any suggestions.





***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies.  You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.

__
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] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
I have a foreach loop that runs regressions in parallel and works fine, but 
when I try to add the weights parameter to the regression the coefficients 
don’t get stored in the “models” variable like they are supposed to.  Below is 
my reproducible example:

library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
fmla <- as.formula("y ~ .")
models <- foreach(d=1:10, .combine=rbind, .errorhandling='remove') %dopar% {
  datdf <- data.frame(y = 1:100+2*rnorm(100), x = 1:100+rnorm(100))
  weights <- rep(c(1,2), 50)
  mod <- lm(fmla, data=datdf, weights=weights)
  #mod <- lm(fmla, data=datdf)
  return(mod$coef)
}
models

You can change the commenting on the two “mod <-“ lines to see that the 
non-weighted one works and the weighted regression doesn’t work.  I tried using 
.export="weights" in the foreach line, but R says that weights is already being 
exported.

Thanks in advance for any suggestions.





***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.

__
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] problems reading XML type file from ishares website

2016-07-29 Thread Bos, Roger
Jeff,

Thanks so much for your help.  I feel pretty confident in saying that there is 
no way I could have figured out how to open that file (in R) by myself.  It was 
hard enough to get the data I needed once I could read the file.  In case 
anyone on the list is interested, here is a working solution to download the 
S&P 500 weights, though I am sure there is a better way than mine:

  library(XML)
  temp <- "https://www.ishares.com/us/239726/fund-download.dl";
  fname <- "C:/pit/" %+% etf %+% "_FundHoldings.xls"
  download.file(url = temp, destfile = fname)
  txt <- readLines(fname, encoding="UTF-8-BOM" )
  txt <- sub( "", "", txt )
  fnamenobom  <- "nobom.xml"
  cat( paste( txt, collapse="\n" ), file=fnamenobom )
  xmlfile  <- xmlTreeParse(fnamenobom)
  xmltop = xmlRoot(xmlfile)
  xml_data <- xmlToList(xmlfile)

  datadate <- unlist(xml_data[["Worksheet"]][[1]])[1]
  d <- list()
  for (ii in 10:length(xml_data[["Worksheet"]])) {
rd <- unlist(xml_data[["Worksheet"]][[ii]])
d[[ii]] <- data.frame(Symbol=rd[1], weight=as.numeric(rd[10]), ISIN=rd[31])
  }
  out <- rbindlist(d)
  out$datadate <- datadate
  out

Thanks,

Roger





***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
Sent: Thursday, July 28, 2016 2:55 PM
To: Bos, Roger; R-help
Subject: Re: [R] problems reading XML type file from ishares website

Er, I failed to include the step to write the repaired data to a file...

fnamenobom  <- "nobom.xml"
cat( paste( txt, collapse="\n" ), file=fnamenobom ) xmlfile  <- xmlTreeParse( 
fnamenobom )

--
Sent from my phone. Please excuse my brevity.

On July 28, 2016 11:20:23 AM PDT, Jeff Newmiller  
wrote:
>Please keep the list included in the thread (e.g. reply-all?).
>
>I looked at the file and agree that it looks like xml with a utf8 byte
>order mark and Unix line endings, which means it is not XLS and it is
>not XLSX (which is a zipped directory of xml files with DOS line
>endings). Excel complains but manages to open the file if it has the
>XLS extension,  but I am not aware that any of the usual R Excel
>packages will understand this file.
>
>The byte order mark can be addressed by opening the file with
>encoding="UTF-8-BOM", but as you mentioned originally the XML structure
>is still broken (c.f. the error message about the Style ending tag).
>Line 16 seems to use /Style rather than /ss:Style. Maybe
>
>library(XML)
>txt <- readLines( fname, encoding="UTF-8-BOM" ) txt <- sub( "",
>"", txt ) fnamenobom  <- "nobom.xml"
>xmlfile  <- xmlTreeParse( "nobom.xml" )

__
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] problems reading XML type file from ishares website

2016-07-28 Thread Bos, Roger
The ishares website has the S&P 500 stocks you can download as a XLS file, 
which opens fine in Excel, but I am not able to open it in R due to what seems 
to be invalid XML formatting.   I tried using XLConnect and XML as shown below. 
 Does anyone know a workaround or can point out what I am doing wrong.  Here is 
my reproducible code:

temp <- "https://www.ishares.com/us/239726/fund-download.dl";
fname <- "ivv.xls"
download.file(url = temp, destfile = fname)
readWorksheetFromFile(fname)
library(XML)
xmlfile <- xmlTreeParse(fname)

09:06:17 > readWorksheetFromFile(fname)
Error: InvalidFormatException (Java): Your InputStream was neither an OLE2 
stream, nor an OOXML stream
09:06:17 > library(XML)
09:06:25 > xmlfile <- xmlTreeParse(fname)
Opening and ending tag mismatch: Style line 14 and Style
Error: 1: Opening and ending tag mismatch: Style line 14 and Style


Thanks in advance, Roger







This message and any attachments are for the intended recipient's use only.

This message may contain confidential, proprietary or legally privileged

information. No right to confidential or privileged treatment

of this message is waived or lost by an error in transmission.

If you have received this message in error, please immediately

notify the sender by e-mail, delete the message, any attachments and all

copies from your system and destroy any hard copies.  You must

not, directly or indirectly, use, disclose, distribute,

print or copy any part of this message or any attachments if you are not

the intended recipient.

[[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] Attaching a pdf file to an email generated with sendmailR?

2015-10-09 Thread Bos, Roger
Michael,

I use sendmailR to attached a file to an email and it does work.  I remember 
there was something non-intuitive when I was figuring it out.  I use both the 
attachPath and the attachName.  The attachPath has the full path including the 
filename and the attachName just has the filename.  I don't why it wants the 
filename in both parameters, but it works for me.

emailR(to = "some...@email.com", subject = "Morning Notes", msg = msg, 
attachPath = newwd %+% fnameNotes, attachName = fnameNotes)

> fnameNotes
[1] "morningNotes_20151009.html"
> newwd %+% fnameNotes
[1] 
"//rinnycs0051/research/R_HOME_Research/Markdown/morningNotes/morningNotes_20151009.html"
> fnameNotes
[1] "morningNotes_20151009.html"

Thanks,

Roger







***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Ashton
Sent: Thursday, October 08, 2015 5:24 PM
To: Frans Marcelissen
Cc: r-help@r-project.org
Subject: Re: [R] Attaching a pdf file to an email generated with sendmailR?

No particular reason for sendmailR...I will try mailR and thanks!



On Oct 8, 2015, at 4:49 PM, Frans Marcelissen 
mailto:fransiepansiekever...@gmail.com>> wrote:

Hi Michael,
I don't know whether there is a particulal reason for using sendmailR, but I 
use mailR for this without any problem.
mailR::send.mail(from, to, subject = "", body = "", encoding = "iso-8859-1",
  html = FALSE, inline = FALSE, smtp = list(), authenticate = FALSE,
  send = TRUE, attach.files = NULL, debug = FALSE, ...)

If you use an external smtp server, enter login name and password in parameter 
smtp as follows:
smtp = list(host.name = "smtp.X", port = X, 
user.name = "X", passwd = "X", ssl = X)

2015-10-08 18:49 GMT+02:00 Michael Ashton 
mailto:m.ash...@enduringinvestments.com>>:
For some time I have been using sendmailR to generate a simple message when a 
report was done running.

Recently, I started adding a couple of pertinent statistics in the body of the 
email.

Now, I've finally decided that what the heck, I ought to simply attach the 
report itself to the email. The report is generated as a pdf file.

I can't seem to get this to work in any simple way with mime_part; if I specify 
a path to the file it simply assumes that "P:/blablabla/thefile.pdf" is a 
message I want to put in a text file attachment.

I assume I am doing something incorrectly and likely something simple. But 
maybe there is a clever trick I am missing. My send line is simply:

sendmail(from,to,subject,body,control=list(smtpServer="mail.optonline.net"))

where body is something like this:

body <- list("Here's your stupid file",mime_part(x="P:/partofpath/ 
thefile.pdf",name="file.pdf"))

Any suggestions are welcome!

Thanks,

Mike


This email and any attachments are confidential and inte...{{dropped:9}}

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



This email and any attachments are confidential and intended only for the 
recipient noted above. You are hereby notified that any use, printing, copying 
or disclosure is strictly prohibited without the permission of Enduring 
Investments LLC. For further information please contact: 
managem...@enduringinvestments.com; (973) 457-4602.

[[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] Running R in Server

2015-08-18 Thread Bos, Roger
There is probably nothing that can give you a step by step guide.  You are 
touching on a couple of different subjects.  If you just want to run code 
automatically on a windows server you can use task scheduler to call Rscript 
filename.R.  If you want to create Web application, that's a bit harder.  I 
still use Rpad, which works on windows, but development of it stopped a long 
time so I wouldn't suggest using it.  All the other web application approaches 
such as RApache only work on Linux.

If I understand correctly what you want to do, you might be able to create a 
HTML report using RMarkdown and host that on the website.  If you really need a 
web app, I suggest looking into Shiny.  You can make a shiny app, host it for 
free on the cloud.  You will have a lot to learn, but it will be time well 
spent.  https://www.rstudio.com/

Thanks,

Roger



***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Swagato 
Chatterjee
Sent: Sunday, August 16, 2015 4:17 AM
To: r-help@r-project.org
Subject: [R] Running R in Server

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-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] using dcast with a function of multiple arguments

2015-07-20 Thread Bos, Roger
I am trying to figure out how to use dcast.data.table with a function with 
multiple arguments.  Here is my reproducible example for a simple function of 
one argument:

require(data.table)
dt <- as.data.table(mtcars)
dcast.data.table(dt, carb ~ cyl, value.var='mpg', fun=mean)

If I instead want to use, say, weighted.mean(x, w), how do I do so?

The docs say
...
Any other arguments that maybe passed to the aggregating function.

So I tried:

> dcast.data.table(dt, carb ~ cyl, value.var='mpg', fun=weighted.mean, w="wt")
Error in weighted.mean.default(data[[value.var]][0], ...) :
  'x' and 'w' must have the same length

The docs also say that value.var can be a list, so I tried that:

 In cases where value.var is a list, the function should be able to handle a 
list input and provide a single value or list of length one as output.

> dcast.data.table(dt, carb ~ cyl, value.var=list('mpg','wt'), 
> fun=weighted.mean)
Error in dcast.data.table(dt, carb ~ cyl, value.var = list("mpg", "wt"),  :
  'value.var' must be a character vector of length 1.

I didn't actually expect that to work, but without an example I don't know what 
else to try.  Any hints would be greatly appreciated.

Thanks,

Roger



***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.

__
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] advice on making HTML tables

2015-07-14 Thread Bos, Roger
Answering my own question, I was able to make the tables look better in IE 
using some simple CSS:

td { 
padding: 6px;
}


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bos, Roger
Sent: Tuesday, July 14, 2015 11:36 AM
To: r-help@r-project.org
Subject: [R] advice on making HTML tables

This might be a little off topic, but I am starting to produce some HTML 
reports that contain mostly tables and they look great in Chrome but really bad 
in IE, so I wanted to see if anyone knows of a better way or an easy fix.  One 
option I have used is to convert to PDF, but sometimes it is nice to have the 
report in HTML format.

For my reproducible example, copy the text below into R Studio and hit the knit 
button. If you look at the HTML output in Chrome the columns are nicely spread 
out and in IE the columns are jammed right next to each other with minimal/no 
spacing.  Maybe there is a CSS fix?

---
title: "Untitled"
output: html_document
---

```{r}
knitr::kable(cars)
```

Here is my session info:

R version 3.2.1 Patched (2015-07-11 r68646)
Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 
7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252 
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] 
LC_TIME=English_United States.1252

attached base packages:
[1] datasets  tools utils stats graphics  grDevices methods   base

other attached packages:
 [1] xtable_1.7-4sqldf_0.4-10RSQLite_1.0.0   DBI_0.3.1  
 gsubfn_0.6-6
 [6] proto_0.3-10Rcpp_0.11.6 Quandl_2.6.0
testthat_0.10.0 lubridate_1.3.3
[11] sendmailR_1.2-1 rmarkdown_0.7   devtools_1.8.0  
data.table_1.9.4Rpad_1.3.0
[16] formatR_1.2 dplyr_0.4.2.9002plyr_1.8.3  reshape2_1.4.1 
 ggplot2_1.0.1
[21] xts_0.9-7   zoo_1.7-12  XLConnect_0.2-11
XLConnectJars_0.2-9 timeDate_3012.100
[26] R2HTML_2.3.1RODBC_1.3-12quadprog_1.5-5  prettyR_2.1-1  
 MASS_7.3-42
[31] fortunes_1.5-2  corpcor_1.6.8   manipulate_1.0.1

loaded via a namespace (and not attached):
 [1] rJava_0.9-6  lattice_0.20-31  tcltk_3.2.1  colorspace_1.2-6 
htmltools_0.2.6
 [6] yaml_2.1.13  base64enc_0.1-2  chron_2.3-47 stringr_1.0.0
munsell_0.4.2
[11] gtable_0.1.2 memoise_0.2.1evaluate_0.7 knitr_1.10.5 
parallel_3.2.1
[16] curl_0.9.1   highr_0.5scales_0.2.5 rversions_1.0.2  
digest_0.6.8
[21] stringi_0.5-5grid_3.2.1   magrittr_1.5 crayon_1.3.1 
xml2_0.1.1
[26] assertthat_0.1   R6_2.1.0 git2r_0.10.1







***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment of this message 
is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the 
sender by e-mail, delete the message, any attachments and all copies from your 
system and destroy any hard copies.  You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message or any attachments 
if you are not the intended recipient.

__
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] advice on making HTML tables

2015-07-14 Thread Bos, Roger
This might be a little off topic, but I am starting to produce some HTML 
reports that contain mostly tables and they look great in Chrome but really bad 
in IE, so I wanted to see if anyone knows of a better way or an easy fix.  One 
option I have used is to convert to PDF, but sometimes it is nice to have the 
report in HTML format.

For my reproducible example, copy the text below into R Studio and hit the knit 
button. If you look at the HTML output in Chrome the columns are nicely spread 
out and in IE the columns are jammed right next to each other with minimal/no 
spacing.  Maybe there is a CSS fix?

---
title: "Untitled"
output: html_document
---

```{r}
knitr::kable(cars)
```

Here is my session info:

R version 3.2.1 Patched (2015-07-11 r68646)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] datasets  tools utils stats graphics  grDevices methods   base

other attached packages:
 [1] xtable_1.7-4sqldf_0.4-10RSQLite_1.0.0   DBI_0.3.1  
 gsubfn_0.6-6
 [6] proto_0.3-10Rcpp_0.11.6 Quandl_2.6.0
testthat_0.10.0 lubridate_1.3.3
[11] sendmailR_1.2-1 rmarkdown_0.7   devtools_1.8.0  
data.table_1.9.4Rpad_1.3.0
[16] formatR_1.2 dplyr_0.4.2.9002plyr_1.8.3  reshape2_1.4.1 
 ggplot2_1.0.1
[21] xts_0.9-7   zoo_1.7-12  XLConnect_0.2-11
XLConnectJars_0.2-9 timeDate_3012.100
[26] R2HTML_2.3.1RODBC_1.3-12quadprog_1.5-5  prettyR_2.1-1  
 MASS_7.3-42
[31] fortunes_1.5-2  corpcor_1.6.8   manipulate_1.0.1

loaded via a namespace (and not attached):
 [1] rJava_0.9-6  lattice_0.20-31  tcltk_3.2.1  colorspace_1.2-6 
htmltools_0.2.6
 [6] yaml_2.1.13  base64enc_0.1-2  chron_2.3-47 stringr_1.0.0
munsell_0.4.2
[11] gtable_0.1.2 memoise_0.2.1evaluate_0.7 knitr_1.10.5 
parallel_3.2.1
[16] curl_0.9.1   highr_0.5scales_0.2.5 rversions_1.0.2  
digest_0.6.8
[21] stringi_0.5-5grid_3.2.1   magrittr_1.5 crayon_1.3.1 
xml2_0.1.1
[26] assertthat_0.1   R6_2.1.0 git2r_0.10.1







***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.

__
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] as.numeric looses precision

2015-07-02 Thread Bos, Roger
I have a string that contains a number and when I convert it to a number I 
loose precision and I would like to know if there is a way to avoid that.  Here 
is my example:

p <- "1087.003489"
as.numeric(p, digits=6)

R gives me 1087.003:

> p <- "1087.003489"
> as.numeric(p, digits=6)
[1] 1087.003

I would be nice if I could keep all the decimal places after the conversion.

Thanks,

Roger





***
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.

__
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] R convert pdf/png to html

2015-06-03 Thread Bos, Roger
Valerio,

Actually htmlize works pretty well.  I used it for a long time.  If you want to 
get the most help from this forum you need to provide a reproducible example 
showing htmlize not working for you.

Nevertheless, today I would recommend going with RMarkdown.  It may be overkill 
for your example, but if you want to produce HTML output in the future, it is 
good to know:

http://rmarkdown.rstudio.com/

Thanks,

Roger








***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn
Sent: Wednesday, June 03, 2015 1:46 PM
To: MacQueen, Don
Cc: r-help@r-project.org
Subject: Re: [R] R convert pdf/png to html

Or try the brand-new way:

http://www.r-pkg.org/search.html?q=html

--Ista

On Wed, Jun 3, 2015 at 1:06 PM, MacQueen, Don  wrote:
> When it's as simple as in Boris's example, just use cat() statements.
>
> Otherwise, go to CRAN, find the packages page ("Table of available
> packages, sorted by name"), and search for "html"
>
> -Don
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 6/3/15, 9:38 AM, "valerio orfano"  wrote:
>
>>Hi Boris and thanx a lot
>>
>>Which library should i be using to create html in R?
>>
>>rgds valerio
>>On 03 Jun 2015, at 18:08, Boris Steipe  wrote:
>>
>>> ... as in: the png exists in a directory that is accessible to the
>>>server?
>>>
>>> That would be as simple as creating a HTML document with the
>>>following
>>>contents:
>>>
>>> >>"http://www.w3.org/TR/html4/strict.dtd";>
>>> 
>>>  
>>>
>>>
>>>
>>> B.
>>>
>>>
>>> On Jun 3, 2015, at 11:32 AM, valerio orfano 
>>>wrote:
>>>
 Hi All

 Is there any chance in R to convert a png and/or pdf file into an html?
 Any example?

 I¹ve tried htmlize but doesn¹t work out!

 Rgds valerio
 __
 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-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-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] problem setting default timezone

2015-04-23 Thread Bos, Roger
Dear All,

I would like to learn the proper way to set the default time zone so I get the 
correct date for my files.  The code below is non-reproducible (sorry) because 
it is based on a file on my system, but I hope someone will be able to help me 
anyway.

I have a file that was last modified on 4/21/2015:

> file.info("E:/snap/q/snap_q_q1_" %+% endPeriod %+% ".txt")$mtime
[1] "2015-04-21 20:26:33 EDT"

When I convert that to a date, I gives me 2015-04-22.  I read about timezones 
and saw that there are two possible places to set the default values: One as a 
system variable and one as an option.  To be safe I set both:

> Sys.setenv(TZ='America/New_York')
> Sys.getenv("TZ")
[1] "America/New_York"
> options(tz='America/New_York')
> getOption("tz")
[1] "America/New_York"
> as.Date(file.info("E:/snap/q/snap_q_q1_" %+% endPeriod %+% ".txt")$mtime)
[1] "2015-04-22"

But as you can see R still gives me the wrong date.  I can get the correct date 
as follows:

> as.Date(file.info("E:/snap/q/snap_q_q1_" %+% endPeriod %+% ".txt")$mtime, 
> tz='America/New_York')
[1] "2015-04-21"

But my question is why is the as.Date function not using the timezone I have 
set?

Thank you in advance,
Roger


***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


__
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] Reading in an XLS (really XML) file from website

2015-02-27 Thread Bos, Roger
All,

I am trying to read the S&P 500 constituents from the iShares website using the 
following code:

   URL <- "http://www.ishares.com/us/239726/fund-download.dl";
   setInternet2(TRUE)
   download.file(url=URL, destfile="temp.xls")
   out <- readWorksheetFromFile(file="temp.xls", sheet="Holdings", header=TRUE, 
startRow=13)

R returns the following error:

>out <- readWorksheetFromFile(file="temp.xls", sheet="Holdings", 
> header=TRUE, startRow=13)
Error: IllegalArgumentException (Java): Your InputStream was neither an OLE2 
stream, nor an OOXML stream
In addition: Warning message:
In download.file(url = URL, destfile = "temp.xls") :
  downloaded length 1938303 != reported length 200

Upon further examination this is because the format is really XML.  Is there 
any way to get XLConnect or any other excel reader to read in an XML file?  I 
thought XML was for new Excel format.

Barring that, can we read in the file using the XML package? I tried the 
following code...

   require(XML)
   tmp <- xmlParse(URL)

... but I get this error:

Opening and ending tag mismatch: Style line 14 and Style
Error: 1: Opening and ending tag mismatch: Style line 14 and Style

Thanks in advance for any help or hints,

Roger



***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


__
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] better two column output from rmarkdown

2014-11-05 Thread Bos, Roger
Disclaimer: This question is more about HTML than R, but since I am using 
rmarkdown, I am not sure of a better forum to ask this.  The code example below 
produces two column HTML output.  If you run the example you will see that the 
"" paragram starts off at the bottom of the first column and wraps around 
to the top of the second column.  I am wondering if there is a HTML tag or 
anything so I can keep the "" section together and not have it wrap to the 
next column.  Also, if you know of a better way to create two column output, I 
would be happy hear that as well.  I have placed the CSS inside the .Rmd file 
to make it easier to run.

library(rmarkdown)
render('example.Rmd')


example.Rmd file:
---
output:
  html_document:
theme: readable
highlight: null
css: null
fig_width: 1
fig_height: 1
fig_caption: true

---

#TEST {
   -moz-column-count: 2;
   -moz-column-gap: 20px;
   -webkit-column-count: 2;
   -webkit-column-gap: 20px;
}


```{r test, eval=TRUE, echo=FALSE, error=FALSE, message=FALSE, warning=FALSE}

aa <- paste(rep('a', 49), collapse=" ")
bb <- paste(rep('', 49), collapse=" ")
cc <- paste(rep('ccc', 49), collapse=" ")
dd <- paste(rep('dd', 49), collapse=" ")
ee <- paste(rep('e', 49), collapse=" ")
```

### TEST ### {#TEST}
`r aa`

`r bb`

`r cc`

`r dd`

`r ee`



***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.


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


Re: [R] Workaround for RODBC asymmetric numeric data treatment

2014-10-03 Thread Bos, Roger
Andrew,

I ran your code using my SQL Server database and it seems like it worked okay 
for me, in that I end up with "num" data types when I read the data back in.  
So it may be a setting on your database.  I don't claim to know which one.

BTW, I had to install 5 or 6 separate packages to get fPortfolio to load.  
Anyone know why 
install.packages("fPortfolio",repos="http://R-Forge.R-project.org";) can't 
install all the dependencies automatically?

Thanks,

Roger


> library(RODBC)

> library(fPortfolio)
Loading required package: timeSeries

Attaching package: ‘timeSeries’

The following object is masked from ‘package:zoo’:

time<-

Loading required package: fBasics


Rmetrics Package fBasics
Analysing Markets and calculating Basic Statistics
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: i...@rmetrics.org

Attaching package: ‘fBasics’

The following object is masked from ‘package:TTR’:

volatility

Loading required package: fAssets
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = 
vI[[j]]) :
  there is no package called ‘DEoptimR’
Error: package ‘fAssets’ could not be loaded
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)

> library(RODBC)

> library(fPortfolio)
Loading required package: fAssets
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘sn’
Error: package ‘fAssets’ could not be loaded
> library(RODBC)
> library(fPortfolio)
Loading required package: fAssets
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘sn’
Error: package ‘fAssets’ could not be loaded
> library(timeSeries)
> head(SWX.RET$SBI)
Error in head(SWX.RET$SBI) :
  error in evaluating the argument 'x' in selecting a method for function 
'head': Error: object 'SWX.RET' not found
> library(fPortfolio)
Loading required package: fAssets
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘sn’
Error: package ‘fAssets’ could not be loaded
> library(fPortfolio)
Loading required package: fAssets


Rmetrics Package fAssets
Analysing and Modeling Financial Assets
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: i...@rmetrics.org
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘slam’
Error: package or namespace load failed for ‘fPortfolio’
> library(fPortfolio)
Package Rsolnp (1.14) loaded.  To cite, see citation("Rsolnp")

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘kernlab’
Error: package or namespace load failed for ‘fPortfolio’
> library(fPortfolio)
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  there is no package called ‘rneos’
Error: package or namespace load failed for ‘fPortfolio’
> library(fPortfolio)


Rmetrics Package fPortfolio
Portfolio Optimization
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: i...@rmetrics.org
> head(SWX.RET$SBI)
[1] -0.0020881194 -0.0001045205 -0.0013597617  0.0004185852  0.00 
-0.0010467917
> str(SWX.RET$SBI)
 num [1:1916] -0.002088 -0.000105 -0.00136 0.000419 0 ...
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)

> mydata<-as.timeSeries(SWX.RET)

> head(mydata)
GMT
 SBI  SPISII LP25 LP40  
   LP60
2000-01-04 -0.0020881194 -0.034390059  0.1367381 -0.011994298 -0.018013035 
-0.026155259
2000-01-05 -0.0001045205 -0.010408271 -0.00495530624 -0.003657054 -0.005837489 
-0.009011403
2000-01-06 -0.0013597617  0.012119128  0.00381289851 -0.001323897 -0.001644737 
-0.002395959
2000-01-07  0.0004185852  0.022461656 -0.00061621046  0.007714991  0.011660151  
0.017062613
2000-01-10  0.00  0.002107677  0.00238057889  0.003029081  0.004565523  
0.006948020
2000-01-11 -0.0010467917 -0.002773654 -0.00029384531 -0.002422531 -0.003142903 
-0.004183466
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)

> df2beSavedByRODBC =as.data.frame(mydata)

> str(df2beSavedByRODBC)
'data.frame':   1916 obs. of  6 variables:
 $ SBI : num  -0.002088 -0.000105 -0.00136 0.000419 0 ...
 $ SPI : num  -0.03439 -0.01041 0.01212 0.02246 0.00211 ...
 $ SII : num  0.137 -0.0049553 0.0038129 -0.0006162 0.0023806 ...
 $ LP25: num  -0.01199 -0.00366 -0.00132 0.00771 0.00303 ...
 $ LP40: num  -0.01801 -0.00584 -0.00164 0.01166 0.00457 ...
 $ LP60: num  -0.02616 -0.00

Re: [R] Copying tables from R to Excel

2014-09-23 Thread Bos, Roger
Here is a simple method I saw mentioned on this list a few years ago:

toExcel <- function(x, tag=FALSE) {write.table(x, "clipboard-128", sep="\t", 
row.names=tag)}




***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of David L Carlson
Sent: Tuesday, September 23, 2014 10:15 AM
To: ivan.calan...@univ-reims.fr; r-help@r-project.org
Subject: Re: [R] Copying tables from R to Excel

If you looked at the documentation for R2HTML you might have noticed that there 
is no function HTML.matrix. Perhaps your recommendation from an unnamed source 
is out of date? Assuming you loaded the package with library(R2HTML) as Ivan 
suggested, the command would be

HTML( summary(iris), file("clipboard", "w"), append=F )

Which will work just fine as long as you are using the Windows operating 
system. More technically, HTML() is a generic function with methods (156 in 
this case) for many different data types including matrices and tables.

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



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ivan Calandra
Sent: Tuesday, September 23, 2014 8:12 AM
To: r-help@r-project.org
Subject: Re: [R] Copying tables from R to Excel

library(R2HTML) ??

Le 23/09/14 15:04, Angel Rodriguez a écrit :
> Dear Subscribers,
>
> I've found this recommendation to paste an R table to Excel:
>
> HTML.matrix( summary(iris), file("clipboard", "w"), append=F )
> # paste into Excel
>
> After installing R2HTML and writting that command, I get:
>
> Error: could not find function "HTML.matrix"
>
> Any clue?
>
> Thank you very much,
>
> Angel Rodr�guez-Laso
>
>   [[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.

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


Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-09 Thread Bos, Roger
What I do in cases like that is wrap the code in a FALSE statement so it won't 
get executed:  its easy to add and remove as needed.

If (FALSE) {

...Code to exclude

}



***
This message and any attachments are for the named person's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of PO SU
Sent: Monday, September 08, 2014 10:50 PM
To: R. Help
Subject: [R] How to use multi paragraph comment like /* and */ in cpp?


Dear expeRts,
   I find it's terrible  when  i want to comment multi paragraph (e.g.  a 30 
lines function) , i have to comment each line with #,  is there any good way to 
do that ?
   I investgate it, but found no easy way, may you help me ?





--

PO SU
mail: desolato...@163.com
Majored in Statistics from SJTU
__
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.
__
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.


Re: [R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-05-01 Thread Bos, Roger
Duncan,

Yes, I admit I haven't updated since 2.15.2 so I was behind.  I am seeing the 
same problem with reading from RODBC (sql server) tables.  I write data to a 
table and then read it back.  In R 2.15 it would come in numeric.  Under R 3.1 
it comes in as a string.

Thanks,

Roger


-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Sent: Wednesday, April 30, 2014 4:40 PM
To: Bos, Roger; r-help@r-project.org
Subject: Re: [R] R 3.1 changes to type.convert causing strings where I used to 
get numeric

On 30/04/2014, 4:20 PM, Bos, Roger wrote:
> Dear R-help,
>
> I recently upgraded to R 3.1 patched and code that ran fine previously and 
> now giving a lot of errors because the data is coming in as strings instead 
> of numeric.  I can fix my code to wrapping each item I want to use with 
> as.numeric(), but that seems very inefficient.
>
> I looked at the change list for R 3.1 and I see the first item is a change in 
> type.convert() that seems to be causing me grief.  The suggestion is to use 
> colClasses, but when I try to do so I get an error regarding the quotes 
> again...
>
>>ann1  <- read.table(driveletter %+% "/snap/ann/snap_fyr_ann1_"
>> %+% i %+% ".txt", header=TRUE, quote="", as.is=TRUE,
>> colClasses='numeric')
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
>scan() expected 'a real', got '"1033.7"'
>
> Does anyone have any suggestions?

This sounds like two separate problems.  The first is the change to 
type.convert().  That's going to be dealt with (it's already in R-devel, will 
eventually be handled in R-patched and 3.1.1).  You deserve part of the blame 
for this for never testing the pre-release version.  It would have been easier 
to fix before release, but nobody who tested then bothered to report it.

The second problem is one I don't recall hearing reported before.  If you have 
a .csv file containing the lines

X
"1"

then it should be readable as a .csv, because the quotes should be stripped.  
In fact it is readable now if you *don't* specify that the column is numeric, 
and it will be converted to a numeric value.
However, if you do use colClasses="numeric" you'll get an error.  That looks 
wrong, though it is consistent with ?read.table.

 > x <- c("X", '"1"')
 > read.csv(textConnection(x))
   X
1 1
 > read.csv(textConnection(x), colClasses="numeric") Error in scan(file, what, 
 > nmax, sep, dec, quote, skip, nlines, na.strings,  :
   scan() expected 'a real', got '"1"'
 >


Duncan Murdoch

>
>
> CHANGES IN R 3.1.0:
> NEW FEATURES
>
>
> type.convert() (and hence by default read.table()) returns a character vector 
> or factor when representing a numeric input as a double would lose accuracy. 
> Similarly for complex inputs.
> If a file contains numeric data with unrepresentable numbers of decimal 
> places that are intended to be read as numeric, specify colClasses in 
> read.table() to be"numeric".
>
>
> ***
> This message is for the named person's use only. It may
> contain confidential, proprietary or legally privileged
> information. No right to confidential or privileged treatment
> of this message is waived or lost by an error in transmission.
> If you have received this message in error, please immediately
> notify the sender by e-mail, delete the message and all
> copies from your system and destroy any hard copies.  You must
> not, directly or indirectly, use, disclose, distribute,
> print or copy any part of this message if you are not
> the intended recipient.
> __
> 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.
>


***
This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not
the intended recipient.
__
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.


[R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-04-30 Thread Bos, Roger
Dear R-help,

I recently upgraded to R 3.1 patched and code that ran fine previously and now 
giving a lot of errors because the data is coming in as strings instead of 
numeric.  I can fix my code to wrapping each item I want to use with 
as.numeric(), but that seems very inefficient.

I looked at the change list for R 3.1 and I see the first item is a change in 
type.convert() that seems to be causing me grief.  The suggestion is to use 
colClasses, but when I try to do so I get an error regarding the quotes again...

>   ann1  <- read.table(driveletter %+% "/snap/ann/snap_fyr_ann1_" %+% i 
> %+% ".txt", header=TRUE, quote="", as.is=TRUE, colClasses='numeric')
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  scan() expected 'a real', got '"1033.7"'

Does anyone have any suggestions?


CHANGES IN R 3.1.0:
NEW FEATURES


type.convert() (and hence by default read.table()) returns a character vector 
or factor when representing a numeric input as a double would lose accuracy. 
Similarly for complex inputs.
If a file contains numeric data with unrepresentable numbers of decimal places 
that are intended to be read as numeric, specify colClasses in read.table() to 
be"numeric".


***
This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not
the intended recipient.
__
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.


Re: [R] passing variable names to dplyr - SOLVED

2014-01-28 Thread Bos, Roger
All,

I asked over at the manipulatr group and Hadley showed me how to do it.  In 
case anyone is interested I will post the solution here:

target <- "hp"
call <- substitute(mutate(mtcars, scale(target)), list(target = 
as.name(target)))
eval(call)

Thanks,

Roger

-Original Message-
From: arun [mailto:smartpink...@yahoo.com]
Sent: Monday, January 27, 2014 5:25 PM
To: Bos, Roger
Subject: Re: [R] passing variable names to dplyr

Hi Roger,

This works on library(plyr), but not in dplyr.

target <- "hp"
res2 <- plyr:::mutate(mtcars,hp1= eval(parse(text= 
sprintf("scale(as.numeric(%s))",target
A.K.




On Monday, January 27, 2014 10:47 AM, "Bos, Roger"  
wrote:
All,

I would like to figure out how to pass variable names to the dplyr function 
mutate.  For example, this works because hp is one of the variable names on 
mtcars:

mutate(mtcars, scale(hp))

Let's says I want to pass in the target variable instead of hard-coding the 
name, as follows:

target <- "hp"
mutate(mtcars, scale(target))

That dones't work.  I read somewhere about using lapply, but that suggestion 
didn't work for me either:

target <- lapply("hp", as.symbol)
mutate(mtcars, scale(target))

Does anyone know how to do this?

Thanks,

Roger

***
This message is for the named person's use only. It may contain confidential, 
proprietary or legally privileged information. No right to confidential or 
privileged treatment of this message is waived or lost by an error in 
transmission.
If you have received this message in error, please immediately notify the the 
sender by e-mail, delete the message and all copies from your system and 
destroy any hard copies.  You must not, directly or indirectly, use, disclose, 
distribute, print or copy any part of this message if you are not the intended 
recipient.
__
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.

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


[R] using substitute with multiple parameters

2014-01-27 Thread Bos, Roger
Dear All,

I can't figure out how to pass multiple arguments to substitute to build up a 
call statement.  One argument works fine:

>target <- "val1"

> call <- substitute(select(zidx_df, datadate, target), list(target = 
> as.name(target)))

> call
select(zidx_df, datadate, val1)

Now I would like to pass multiple arguments to substitute so that I get 
"select(zidx_df, datadate, val1, val2, val3)", but I only get the first 
argument:

> target <- c("val1", "val2", "val3")

> call <- substitute(select(zidx_df, datadate, target), list(target = 
> as.name(target)))

> call
select(zidx_df, datadate, val1)

I have tried multiple variations, but none of them are even close, so I won't 
embarrass myself by posting them here.

Thanks in advance, Roger

***

This message is for the named person's use only. It may\...{{dropped:15}}

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


[R] passing variable names to dplyr

2014-01-27 Thread Bos, Roger
All,

I would like to figure out how to pass variable names to the dplyr function 
mutate.  For example, this works because hp is one of the variable names on 
mtcars:

mutate(mtcars, scale(hp))

Let's says I want to pass in the target variable instead of hard-coding the 
name, as follows:

target <- "hp"
mutate(mtcars, scale(target))

That dones't work.  I read somewhere about using lapply, but that suggestion 
didn't work for me either:

target <- lapply("hp", as.symbol)
mutate(mtcars, scale(target))

Does anyone know how to do this?

Thanks,

Roger

***
This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the the sender by e-mail, delete the message and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not
the intended recipient.
__
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.


Re: [R] speeding up "sum of squared differences" calculation

2013-10-22 Thread Bos, Roger
Thanks for the Rccp example Ken!  I vaguely knew about Rccp, but I didn't 
realize how easy it was to use it.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Kenneth Knoblauch
Sent: Tuesday, October 22, 2013 9:13 AM
To: S Ellison
Cc: r-help@r-project.org
Subject: Re: [R] speeding up "sum of squared differences" calculation

Actually, you don't need to use c() in the dist example, either, which should 
shave off a few microseconds for a function call.  It was late last night ...

Ken

On 22-10-2013 15:08, S Ellison wrote:
>> Conclusion: hard to beat outer() for this purpose in R
> ... unless you use Ken Knoblauch's suggestion of dist() or Rccp.
> 
> Nice indeed.
> 
> 
> S Ellison
> 
> 
> ***
> This email and any attachments are confidential. Any use, copying or 
> disclosure other than by the intended recipient is unauthorised. If 
> you have received this message in error, please notify the sender 
> immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
> and delete this message and any copies from your computer and network.
> LGC Limited. Registered in England 2991879.
> Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK

--
Kenneth Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


[R] speeding up "sum of squared differences" calculation

2013-10-21 Thread Bos, Roger
All,

I am using a sum of squared differences in the objective function of an 
optimization problem I am doing and I have managed to speed it up using the 
outer function versus the nested for loops, but my suspicion is that the 
calculation could be done even quicker.  Please see the code below for a simple 
example.  If anyone can point out a faster way I would appreciate it greatly.

Thanks,

Roger

X <- runif(1000)

now <- proc.time()
ans <- 0
for (i in 1:length(X)) {
  for (j in 1:length(X)) {
ans <- ans + (X[i]-X[j])*(X[i]-X[j])
  }
}
ans
speed <- proc.time() - now; cat(" That took ", round(speed[3],1), " secs.\n", 
sep="")

now <- proc.time()
gg <- outer(X, X, FUN="-")
sum(gg*gg)
speed <- proc.time() - now; cat(" That took ", round(speed[3],1), " secs.\n", 
sep="")

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


[R] Cannot create Java virtual machine (-1)

2012-08-08 Thread Bos, Roger
All,

I am trying to get the XLConnect package to work on one of my servers and I am 
getting an error that XLConnectJars cannot create the java virtual machine.  
The server is a 32-bit Windows  Server 2003 machine with R 2.15.1.  The version 
of Java installed on the server is J2SE Environment 5.0 update 8.  I know this 
not the latest version of Java, and I will try to update it when I get 
exclusive access to the server, but in the meantime is there anything else 
anyone can suggest for this error?


Loading required package: XLConnectJars
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'XLConnectJars', details:
  call: .jinit()
  error: Cannot create Java virtual machine (-4)
Error: package 'XLConnectJars' could not be loaded
> library(rJava)
> library(XLConnect)
Loading required package: XLConnectJars
Error : .onLoad failed in loadNamespace() for 'XLConnectJars', details:
  call: .jinit()
  error: Cannot create Java virtual machine (-1)
Error: package 'XLConnectJars' could not be loaded
> library(XLConnectJars)
Error : .onLoad failed in loadNamespace() for 'XLConnectJars', details:
  call: .jinit()
  error: Cannot create Java virtual machine (-1)
Error: package/namespace load failed for 'XLConnectJars'
> .jinit()
Error in .jinit() : Cannot create Java virtual machine (-1)

Thanks,

Roger



***
This message is for the named person's use only. It may\...{{dropped:11}}

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


Re: [R] getting error in Rpad::json()

2012-07-24 Thread Bos, Roger
Dinesh,

I can't answer your question, but its my understanding that Rpad is no longer 
being developed as the original person (Tom Short) doesn't have enough time and 
no one else has taken it over.  So if you can find any other package that does 
what you need, I would use that one instead.

Thanks,

Roger

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Dinesh K. Somani
Sent: Tuesday, July 24, 2012 12:27 PM
To: r-help@r-project.org
Subject: [R] getting error in Rpad::json()

Hi,

I am trying to convert an R object to JSON, using Rpad::json. I get the 
following error when there is an empty vector in there.
Using R version 2.15.0 (2012-03-30) on OpenSUSE 11.4 on an Intel machine; Rpad 
- 1.3.0

>Rpad::json(numeric(0))

> class(Rpad::json(numeric(0)))
[1] "json"

> Rpad::json(list(x=numeric(0)))
Error in res[i] <- json(x[[i]]) : replacement has length zero
> traceback()
2: json.list(list(x = numeric(0)))
1: Rpad::json(list(x = numeric(0)))


Am I not using the right package/function or options? Will appreciate help.

Thanks and regards
Dinesh

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

***
This message is for the named person's use only. It may\...{{dropped:11}}

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


[R] quantstrat questions

2012-07-24 Thread Bos, Roger
Quantstrat useRs,

I have a number of questions about how to use quantstrat that I have 
accumulated since I have begun playing with it.  First, can the orderqty be 
dynamic?  All of the examples I have seen are based on placing an order for 100 
shares when a rule is triggered.  Is it possible to set it up to buy the 
maximum number of shares given the starting or current equity?  Similar to that 
question, I think most examples buy 100 shares each time a buy is triggered?  
Is it possible to make the rules only buy at the first buy trigger?  So the 
fund is either long 100% equity or in cash for a fixed starting equity.

Another idea I would like to try to implement is a slow trading strategy where 
you have to keep a position for at least x days after a buy.  For example some 
small cap or international funds have a penalty for trading in and out too 
quickly.  It would be nice to test how much such a restriction hurts you?

My final question is how to create a rule that uses more than one signal.  Here 
I have an code sample below.  In the sample I add three moving averages, ma50, 
ma160, and ma200:


#Adding indicators to a strategy
stratName <- add.indicator(strategy = stratName, name = "SMA", 
arguments =
list(x=quote(Cl(mktdata)), n=50),label= "ma50" )
stratName <- add.indicator(strategy = stratName, name = "SMA", 
arguments =
list(x=quote(Cl(mktdata)), n=160),label= "ma160")
stratName <- add.indicator(strategy = stratName, name = "SMA", 
arguments =
list(x=quote(Cl(mktdata)), n=200),label= "ma200")

#Adding signals to a strategy
stratName <- add.signal(strategy = 
stratName,name="sigCrossover",arguments =
list(columns=c("ma50","ma160"), 
relationship="gte"),label="ma50.gt.ma160")
stratName <- add.signal(strategy = 
stratName,name="sigCrossover",arguments =
list(column=c("ma50","ma160"),relationship="lt"),label="ma50.lt.ma160")

stratName <- add.signal(strategy = 
stratName,name="sigCrossover",arguments =
list(columns=c("ma50","ma200"), 
relationship="gte"),label="ma50.gt.ma200")
stratName <- add.signal(strategy = 
stratName,name="sigCrossover",arguments =
list(column=c("ma50","ma200"),relationship="lt"),label="ma50.lt.ma200")


How would I modify the rules below to enter when ma50 greater than both ma160 
and ma200 and exit when ma50 is below both ma160 and ma200?

#Add rules to a strategy
stratName <- add.rule(strategy = stratName,name='ruleSignal', arguments 
=
list(sigcol="maFast.gt.maSlow",sigval=TRUE, orderqty=100, 
ordertype='market', orderside='long'),type='enter')
stratName <- add.rule(strategy = stratName,name='ruleSignal', arguments 
=
list(sigcol="maFast.lt.maSlow",sigval=TRUE, orderqty='all', 
ordertype='market', orderside='long'),type='exit')

Thanks to everyone who helped develop quantstrat and blotter,

Roger


***

This message is for the named person's use only. It may\...{{dropped:15}}

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


[R] OT: Any reason why one of my computers is so slow?

2012-06-28 Thread Bos, Roger
This is not a criticism of R, but R runs much slower on one of my machines than 
it does on the others, so something is wrong with that machine, but I don't 
know where to look for a remedy.  Here are the details:

I have a 32-bit win xp machine running at 2.66Ghz and a 64-bit win 7 machine 
running at 3.00 GHz.  I have noticed that the win 7 machine seems slower, so I 
ran the rbenchmark example of creating a vector from 1:10^8 five times and the 
win xp machine scored 1.6 seconds while the win 7 machines scores 3.0 seconds.  
Both machines are about 3 years old.  I expect a 64-bit to be slightly slower 
for some operations, but I just bought a new 64-bit PC for home that I runs at 
3.1 GHz and it scores 0.64 seconds.  Therefore I will likely buy a new PC to 
replace my win 7 machine, but its still nagging me that a Xeon 3.0 processor 
would be so much slower than my other machines.  The machines have different 
numbers of cores, but that shouldn't matter since R is single threaded.

I have a access to a number of machines at work, but the win 7 machine is the 
only one with 16Gb of RAM.  Like I said, I will probably replace the win 7 
machine, but if anyone has any suggestions I would love to try them.

Thanks,

Roger

***
This message is for the named person's use only. It may\...{{dropped:11}}

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


[R] Job posting for programmer with database skills

2012-02-17 Thread Bos, Roger
NYC-based equity asset management company is seeking a junior-level
programmer with R, VBA, and MS-SQL skills.  HTML skill is a plus.  This
permanent, full-time position will involve working on projects and
improving our daily processes.  Finance knowledge is helpful, but not
necessary.  We are an equal opportunity employer with a generous
benefits package.  Immediate opening.  Please forward resume and salary
requirements to tom.rawli...@rothschild.com.
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


[R] LaTeX and Sweave on windows

2012-02-15 Thread Bos, Roger
I am completely new to LaTeX and Sweave, so I am trying to follow the
tutorial in the following link:

http://www.r-bloggers.com/using-latex-r-and-sweave-to-create-reports-in-
windows/

I installed MiKTeX 2.9 and TeXnicCenter, but I get a build error when
compiler the example file:
The two errors are: "Error: running 'texi2dvi' on 'test.tex' failed" and
"R> ! LaTeX Error: File '(.xls' not found."

I am using a 32-bit windows machine and R 2.14.1patched.  Any
suggestions are welcome, including links to other tutorials.

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


Re: [R] Odp: Remove space from string

2012-01-13 Thread Bos, Roger
I have NO knowledge of regexpr, but someone helped me out once and I put
it into a function I call "trim".  Here is the line I use:

function(x) gsub("^[[:space:]]+|[[:space:]]+$", "", x)

One more thing you can try.  Hope it helps, Roger

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Petr PIKAL
Sent: Friday, January 13, 2012 7:40 AM
To: Vikram Bahure
Cc: r-help@r-project.org
Subject: [R] Odp: Remove space from string

Hi

> 
> Dear R users,
> 
> I have some trivial query.
> 
> I have a string, I want to remove space from the string.
> 
> For eg.
> 
> Input:
> a <- " Remove space "
> 
> Output required:
> "Removespace"

It seems to be simple. Even myself with very poor knowledge of regexpr
can suggest solution.

gsub(" ", "", a)

Regards
Petr


> 
> I tried using str_trim but only removes end spaces. library(stringr).
> 
> Regards
> Vikram
> 
>[[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.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


Re: [R] cbind alternate

2012-01-06 Thread Bos, Roger
You could break the data into chunks, so you cbind and save 50,000
observations at a time.  That should be less taxing on your machine and
memory.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Mary Kindall
Sent: Friday, January 06, 2012 12:43 PM
To: r-help@r-project.org
Subject: [R] cbind alternate

I have two one dimensional list of elements and want to perform cbind
and then write into a file. The number of entries are more than a
million in both lists. R is taking a lot of time performing this
operation.

Is there any alternate way to perform cbind?

x = table1[1:100,1]
y = table2[1:100,5]

z = cbind(x,y)   //hanging the machine

write.table(z,'out.txt)



--
-
Mary Kindall
Yorktown Heights, NY
USA

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

***
This message is for the named person's use only. It may\...{{dropped:11}}

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


[R] How to use assign function within foreach

2011-10-25 Thread Bos, Roger
All,

 

I would like to use the assign to save some data from a calculation
within a foreach loop.  Below is a contrived example where I cannot get
output_1 ... output_100 to show up in my list when I do ls().  I have
tried different combinations of pos and envir without anything showing
up. 

 

out <- foreach(d=1:100, .combine=rbind) %dopar% {

x <- 10 * d

assign(paste("output_", d, sep=""), x, envir = .GlobalEnv)

}



out

ls()



I am using doSNOW and here is the additional setup code needed to run
the above example if you don't already have a parallel backend
configured:

 

library(foreach)

library(doSNOW)

cl <- makeCluster(rep("localhost",8), type = "SOCK")

registerDoSNOW(cl)

 

Thanks in advance for any help.  Roger

 

 
***

This message is for the named person's use only. It may\...{{dropped:18}}

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


[R] Constrained regressions (suggestions welcome)

2011-09-19 Thread Bos, Roger
All,

Could anyone recommend a package that allows the user to constrain the
coefficients from a multiple regression equation?  

I tried using the  gl1ce function in lasso2, but couldn't get it to
work.  I created a contrived example to illustrate my starting point.

data(cars)
 fmla <- formula(dist ~ speed)
 gl1c.E <- gl1ce(fmla, data = cars)
 gl1c.E
 gl1c.E <- gl1ce(fmla, data = cars, link=identity())
 gl1c.E

I started with the example, but I think my data is more Gaussian than
binomial.  This returns the following errors.

>  data(cars)
>  fmla <- formula(dist ~ speed)
>  gl1c.E <- gl1ce(fmla, data = cars)
Error in family(family) : 
  link "family" not available for gaussian family; available links are
'inverse', 'log', 'identity'
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)
>  gl1c.E <- gl1ce(fmla, data = cars, link=identity())
Error in identity() : argument "x" is missing, with no default

In this example I haven't even gotten to the stage of constraining the
coefficients yet because I can't get the function to work with minimal
inputs.

Thanks,

RogerRoger J. Bos, CFA
Rothschild Asset Management, Inc.
Tel +1 (212) 405-5471
Email roger@rothschild.com
1251 Avenue of the Americas, NY, NY  10020
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


Re: [R] Writting excel files

2011-09-12 Thread Bos, Roger
Marc's links lists many packages.  Of those, I would recommend
XLConnect. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Marc Schwartz
Sent: Monday, September 12, 2011 12:53 PM
To: Damian Abalo
Cc: r-help
Subject: Re: [R] Writting excel files

On Sep 12, 2011, at 10:28 AM, Damian Abalo wrote:

> Hello.
> I need to generate, using R code, an excel file with multiple sheets, 
> I wonder if any of you know how to do so.
> 
> Thanks for the help


See the following:

R Data Import/Export Manual:
http://cran.r-project.org/doc/manuals/R-data.html

R Wiki: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows

HTH,

Marc Schwartz

__
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.
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


Re: [R] How to specify a variable name in the regression formula without hard coding it SOLVED

2011-09-08 Thread Bos, Roger
The answer to my question was :

fmla <- as.formula(names(mat)[y] %+% " ~ .")
mod <- try(rlm(fmla, data=mat[zidx, c(y, x)]), silent=TRUE) 

Thanks for your help and the quick response.

Roger

-Original Message-
From: Jean-Christophe BOUËTTÉ [mailto:jcboue...@gmail.com] 
Sent: Thursday, September 08, 2011 9:22 AM
To: Bos, Roger
Cc: r-help@r-project.org
Subject: Re: [R] How to specify a variable name in the regression formula 
without hard coding it

have a look at ?formula and the examples

2011/9/8 Bos, Roger :
> I have a matrix called mat and y is the column number of my response 
> and x is a vector of the column numbers of my terms.  The variable 
> name of y can change, so I don't want to hardcode it.  I can find out 
> the name as
> follows:
>
>>names(mat)[y]
> [1] "er12.l"
>
> Then I can run the regression by hard coding the variable name as
> follows:
>
>> mod <- try(rlm(er12.l ~ ., data=mat[zidx, c(y, x)]),
> silent=TRUE)
>
> But how would I do so without hard coding the name er12.l?
>
> I set up a reproducible example.  In the following my regression 
> formula is aa ~ bb + cc, or more simply aa ~ .
> How can I use the name of the first column without hard coding aa?
>
> dat <- data.frame(aa=runif(50), bb=runif(50), cc=runif(50)) 
> names(dat)[1] lm(aa ~ ., data=dat[1:10,])
>
> Thanks,
>
> Roger
> ***
>
> This message is for the named person's use only. It ...{{dropped:26}}

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


[R] Variable scoping question

2011-09-08 Thread Bos, Roger
I modified an example in the object.size help page to create a function
I want to be able to run:

"mysize" <- function() {
z <- sapply(ls(), function(w) object.size(get(w)))
as.matrix(rev(sort(z))[1:5])
}
mysize()

When I test the lines inside the function it works fine:

> z <- sapply(ls(), function(w) object.size(get(w)))

> as.matrix(rev(sort(z))[1:5])
 [,1]
mat 166344288
mod 130794704
zidx   799664
wfidx  799664
megacap799664
>

But when I try to run the function, it produces an error:

> "mysize" <- function() {
+ z <- sapply(ls(), function(w) object.size(get(w)))
+ as.matrix(rev(sort(z))[1:5])
+ }

> mysize()
Error in rev(sort(z)) : 
  error in evaluating the argument 'x' in selecting a method for
function 'rev': Error in sort.int(x, na.last = na.last, decreasing =
decreasing, ...) : 
  'x' must be atomic
> 

It must be a variable scoping problem, but I am not sure how to tackle
it.

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


[R] How to specify a variable name in the regression formula without hard coding it

2011-09-08 Thread Bos, Roger
I have a matrix called mat and y is the column number of my response and
x is a vector of the column numbers of my terms.  The variable name of y
can change, so I don't want to hardcode it.  I can find out the name as
follows:

>names(mat)[y]
[1] "er12.l"

Then I can run the regression by hard coding the variable name as
follows:

> mod <- try(rlm(er12.l ~ ., data=mat[zidx, c(y, x)]),
silent=TRUE)

But how would I do so without hard coding the name er12.l?

I set up a reproducible example.  In the following my regression formula
is aa ~ bb + cc, or more simply aa ~ .
How can I use the name of the first column without hard coding aa?

dat <- data.frame(aa=runif(50), bb=runif(50), cc=runif(50))
names(dat)[1]
lm(aa ~ ., data=dat[1:10,])

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


[R] How to speed up regressions (related to data.frame)

2011-09-06 Thread Bos, Roger
All,

I have a function that runs a set of regressions (using the rlm
function) and I notice that it run much slower on my 64-bit R than it
does on my 32-bit R.  I guess the bigger bit size slows it down.
Anyway, I looked into Rprof to see how I can speed it up.  I saw that
78% of the total time is spent in [.data.frame, so I tried converting my
data to a matrix using data.matrix, but then rlm complained that data
needs to be in the form of a data.frame.  Am I stuck or is there still
maybe a way to speed up my function?

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:14}}

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


Re: [R] R in Batch mode

2011-07-14 Thread Bos, Roger
Duncan's suggestion is probably the way to go, but I will just point out
that R does have a facility to perform a task when an error occurs.  I
have my code set up to send me an email when my batch code fails.
(email() is a function I wrote that executes sql command to send email
via dbmail.)

.Err <- function() {email("roger@rothschild.com","!Notify: Job
FAILED on " %+% Sys.info()[4],"","TEXT","HIGH")}
options (error = .Err)

Thanks,

Roger


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Duncan Murdoch
Sent: Wednesday, July 13, 2011 5:04 PM
To: cornejo...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] R in Batch mode

On 11-07-13 4:15 PM, Jorge Cornejo wrote:
> Hi, I'm running long code in Batch mode (as a process in ubuntu using 
> $nohup R CMD BATCH MyCode.R out.out&), but every one in a while it 
> fail and the process stops.
>
> When the code finish with no problems, it sends an e-mail, but if 
> fails, I'm not aware unless I check the working process, and I cannot 
> be checking the process all day!.
>
> Is there any way to send me a warning when the process stops/fails?

This is really an Ubuntu question, isn't it?

I'd suggest writing a script which calls your R batch file.  The last
thing the batch file should do is write some sort of status value.  The
last thing the script should do is check and act on the status.

Of course, if whatever kills your batch file kills the script too,
you're out of luck.

Duncan Murdoch

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] foreach not recognizing functions in memory

2011-07-13 Thread Bos, Roger
Saskay, 

Thanks so much for that example.  It worked fine on my system.  I didn't
realized SNOW worked on windows.  I will have to read more about it.

Thanks again,

Roger 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of saskay
Sent: Wednesday, July 13, 2011 2:59 PM
To: r-help@r-project.org
Subject: Re: [R] foreach not recognizing functions in memory

Try the below code:
==

library(foreach)
library(doSNOW)
getDoParWorkers()
getDoParName()
registerDoSNOW(makeCluster(2, type = "SOCK"))
getDoParWorkers()
getDoParName()

testFun <- function(m) {
out <- m*m
}

out <- foreach(m=1:10, .combine=rbind,*.verbose=T*) %dopar% testFun(m)

helper <- function(i) {

   out <- foreach(m=1:i, .combine=rbind,*.export="testFun", .verbose=T*)
%dopar% testFun(m)  }

 out <- helper(10)

--
View this message in context:
http://r.789695.n4.nabble.com/foreach-not-recognizing-functions-in-memor
y-tp3663603p3665806.html
Sent from the R help mailing list archive at Nabble.com.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] foreach not recognizing functions in memory

2011-07-13 Thread Bos, Roger
My apologies for not mentioning which backend and OS I am using. I am using 
doSMP on a windows machine.  I read up on doSMP, but all the examples they show 
are based on calling foreach directly, not from within a function.

The code works fine using %do% instead of %dopar%.  Does anyone have an example 
where user written function has to be exported to slave processors?

Thanks,

Roger 

-Original Message-
From: wootten.adrie...@gmail.com [mailto:wootten.adrie...@gmail.com] On Behalf 
Of Adrienne Wootten
Sent: Tuesday, July 12, 2011 5:49 PM
To: Bos, Roger
Cc: r-help@r-project.org
Subject: Re: [R] foreach not recognizing functions in memory

Roger,

I think I know why you are having a problem.  Your foreach is using %dopar% and 
judging from your output you have active parallel processing.  When running 
something in paralell, the master is the processor used by the Rgui, and the 
slaves are in the background.  My guess is the the function you made is the 
memory of the master, but not in the memory for the slaves.  You need to pass 
the function "TestFun" to your slaves.  If the slave don't know about it, using 
foreach with %dopar% will fail since the function doesn't exist on the slave 
processors.  Without knowing what package you used to do your parallel 
processing I can't tell you how to pass the function you created to your slave 
processors.

Try running the foreach command with %do% in place of %dopar%.  If the command 
works, then it is probably a problem that function isn't in memory on the slave 
processors.

Adrienne

On Tue, Jul 12, 2011 at 5:28 PM, Bos, Roger  wrote:
> All,
>
> I am not understanding the scoping used in foreach when it is used 
> inside a function.  I keep getting "could not find function" errors 
> for functions that are in memory when I try to use foreach within a 
> function call.  I have a simple example below.  "testFun" is in memory 
> and works when called by foreach directly, but when I place foreach in 
> a function called "helper" and then call helper, foreach cannot find 
> "testFun".
> Can anyone provide a fix?  I hope its just a simple mistake on my part 
> and not a limitation of foreach.
>
>> source(.trPaths[5], echo=TRUE, max.deparse.length=150)
>
>> "testFun" <- function(m) {
> + out <- m*m
> + }
>
>> out <- foreach(m=1:10, .combine=rbind) %dopar% testFun(m)
>
>> "helper" <- function(i) {
> +
> + out <- foreach(m=1:i, .combine=rbind) %dopar% testFun(m) }
>
>> out <- helper(10)
> Error in testFun(m) : task 1 failed - "could not find function 
> "testFun""
>>
>
> Thanks,
>
> Roger
>
> ***
>
> This message is for the named person's use only. It 
> may\...{{dropped:20}}
>
> __
> 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.
>



--
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences North Carolina State 
University
***

This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the the sender by e-mail, delete the message and all 
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute, 
print or copy any part of this message if you are not
the intended recipient.





__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

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


[R] foreach not recognizing functions in memory

2011-07-12 Thread Bos, Roger
All,

I am not understanding the scoping used in foreach when it is used
inside a function.  I keep getting "could not find function" errors for
functions that are in memory when I try to use foreach within a function
call.  I have a simple example below.  "testFun" is in memory and works
when called by foreach directly, but when I place foreach in a function
called "helper" and then call helper, foreach cannot find "testFun".
Can anyone provide a fix?  I hope its just a simple mistake on my part
and not a limitation of foreach.

> source(.trPaths[5], echo=TRUE, max.deparse.length=150)

> "testFun" <- function(m) { 
+ out <- m*m
+ }

> out <- foreach(m=1:10, .combine=rbind) %dopar% testFun(m)

> "helper" <- function(i) {
+ 
+ out <- foreach(m=1:i, .combine=rbind) %dopar% testFun(m)
+ }

> out <- helper(10)
Error in testFun(m) : task 1 failed - "could not find function
"testFun""
>

Thanks,

Roger

***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Rpad library

2011-07-05 Thread Bos, Roger
Please note that Rpad is not being updated and does not work
(unmodified) with versions of R greater than 2.9.  So if you are trying
to use it and it is not working, that may explain your difficulty.

I still use it because better alternatives, like RApache, don't work on
Windows. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of David Winsemius
Sent: Monday, July 04, 2011 2:16 PM
To: ATANU
Cc: r-help@r-project.org
Subject: Re: [R] Rpad library


On Jul 4, 2011, at 12:45 PM, ATANU wrote:

> can anyone help me with a well documented tutorial on Rpad package?  
> I need to
> do HTML programming in R.Can anyone help me with a tutorial?

Trivial Google searching produces this link:

http://rpad.googlecode.com/svn-history/r76/Rpad_homepage/index.html

>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Rpad-library-tp3644041p3644041.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Email out of R (code)

2011-05-19 Thread Bos, Roger
I took a look at sendmailR when I was trying to figure out how to send
email a few years ago.  I ended up using my SQL Server dbmail facility,
which I can easily access from R using the RODBC package.  In case my
scenario applies to anyone else, I will paste the simple function I
wrote to serve as an example to anyone else who may want to do the same
thing:


"email" <- function(to, subject, msg, texttype='TEXT', imp='NORMAL',
profileName='Roger Bos') {
go <- try(sqlQuery(xf, "EXECUTE msdb..sp_send_dbmail  
 @profile_name  = '" %+% profileName %+% "',
  @recipients= '" %+% to %+% "',
 @body  = '" %+% msg %+% "',
 @subject   = '" %+% subject %+% "',
 @query = '',
  @body_format   = " %+% texttype %+% ",
  @importance= '" %+% imp %+% "',
  @attach_query_result_as_file = 0"))
}
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Daniel Malter
Sent: Thursday, May 19, 2011 2:04 PM
To: r-help@r-project.org
Subject: Re: [R] Email out of R (code)

As I (thought I) understood from the sendmailR manual, the package does
currently not support server authentication, or does it?

Daniel 

--
View this message in context:
http://r.789695.n4.nabble.com/Email-out-of-R-code-tp3530671p3536512.html
Sent from the R help mailing list archive at Nabble.com.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Read.xls in gdata

2011-05-12 Thread Bos, Roger
All,  

When I use gdata::read.xls to read in an excel file it seems to round
the data to three decimal places and also converts the dates to factors.
Does anyone know how to 1) get more precision in the numeric data and 2)
how to prevent the dates from being converted to levels or factors?  I
tries settings as.is=TRUE, but that didn't help.

Thanks, Roger
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] lower/upper case question

2010-12-20 Thread Bos, Roger
toupper() and tolower() 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Erin Hodgess
Sent: Friday, December 17, 2010 4:10 PM
To: R help
Subject: [R] lower/upper case question

Dear R People:

Is there a function to convert a character string to all uppercase or
all lowercase please?

I'm sure that I've used one before but I'm drawing a blank.

Thanks,
Erin


--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences University of Houston -
Downtown
mailto: erinm.hodg...@gmail.com

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Rapache on windows

2010-12-13 Thread Bos, Roger
I asked Jeff Horner that question a while back and he said it was Linux
only.  He doesn't have time to create a windows version.
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Santosh Srinivas
Sent: Saturday, December 11, 2010 8:37 AM
To: r-help@r-project.org
Subject: [R] Rapache on windows

Hello all,

I searched on the www but could not find installation instructution for
rapache on windows. The page says that the release runs on UNIX/Linux
and Mac OS X operating systems.
Has anyone been able to configure it on windows? Any idea how to go
about it?

Thank you.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Saving/loading custom R scripts

2010-09-09 Thread Bos, Roger
Josh,

I liked your idea of setting the repo in the .Rprofile file, so I tried it:

r <- getOption("repos")
r["CRAN"] <- "http://cran.stat.ucla.edu";
options(repos = r)
rm(r)

And now when I open R I get an error:

  Error in r["CRAN"] <- "http://cran.stat.ucla.edu"; : 
  cannot do complex assignments in base namespace
> 

I am using R2.11.1pat in windows.  

Thanks,

Roger



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Joshua Wiley
Sent: Wednesday, September 08, 2010 11:20 AM
To: DrCJones
Cc: r-help@r-project.org
Subject: Re: [R] Saving/loading custom R scripts

Hi,

Just create a file called .Rprofile that is located in your working directory 
(this means you could actually have different ones in each working directory).  
In that file, you can put in code just like any other code that would be 
source()d in.  For instance, all my .Rprofile files start with:

r <- getOption("repos")
r["CRAN"] <- "http://cran.stat.ucla.edu";
options(repos = r)
rm(r)

So that I do not have to pick my CRAN mirror.  Similarly you could merely add 
this line to the file:

source(file = 
"http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-with-Post-Hoc.r.txt";)

and R would go online, download that file and source it in (not that I am 
recommending re-downloading every time you start R).  Then whatever names they 
used to define the functions, would be in your workspace.

Note that in general, you will not get any output alerting you that it has 
worked; however, if you type ls() you should see those functions'
names.

Cheers,

Josh

On Wed, Sep 8, 2010 at 12:25 AM, DrCJones  wrote:
>
> Hi,
> How does R automatically load functions so that they are available 
> from the workspace? Is it anything like Matlab - you just specify a 
> directory path and it finds it?
>
> The reason I ask is because  I found a really nice script that I would 
> like to use on a regular basis, and it would be nice not to have to 
> 'copy and paste' it into R on every startup:
>
> http://www.r-statistics.com/wp-content/uploads/2010/02/Friedman-Test-w
> ith-Post-Hoc.r.txt
>
> This would be for Ubuntu, if that makes any difference.
>
> Cheers
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Saving-loading-custom-R-scripts-tp253092
> 4p2530924.html Sent from the R help mailing list archive at 
> Nabble.com.
>
> __
> 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.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Help with ddply to eliminate a for..loop

2010-08-26 Thread Bos, Roger
I created a small example to show something that I do a lot of.  "scale"
data by month and return a data.frame with the output.  "id" represents
repeated observations over "time" and I want to scale the "slope"
variable.  The "out" variable shows the output I want.  My for..loop
does the job but is probably very slow versus other methods.  ddply
seems ideal, but despite playing with the baseball examples quite a bit
I can't figure out how to get it to work with my sample dataset.  

TIA for any help, Roger

Here is the sample code:

dat <- data.frame(id=rep(letters[1:5],3),
time=c(rep(1,5),rep(2,5),rep(3,5)), slope=1:15)
dat

for (i in 1:3) {
mat <- dat[dat$time==i, ]
outi <- data.frame(mat$time, mat$id, slope=scale(mat$slope))
if (i==1) {
out <- outi
} else {
out <- rbind(out, outi)
}
}
out

Here is the sample output:

> dat <- data.frame(id=rep(letters[1:5],3),
time=c(rep(1,5),rep(2,5),rep(3,5)), slope=1:15)

> dat
   id time slope
1   a1 1
2   b1 2
3   c1 3
4   d1 4
5   e1 5
6   a2 6
7   b2 7
8   c2 8
9   d2 9
10  e210
11  a311
12  b312
13  c313
14  d314
15  e315

> for (i in 1:3) {
+ mat <- dat[dat$time==i, ]
+ outi <- data.frame(mat$time, mat$id, slope=scale(mat$slope))
+ if (i==1) {
+ out   [TRUNCATED] 

> out
   mat.time mat.id  slope
1 1  a -1.2649111
2 1  b -0.6324555
3 1  c  0.000
4 1  d  0.6324555
5 1  e  1.2649111
6 2  a -1.2649111
7 2  b -0.6324555
8 2  c  0.000
9 2  d  0.6324555
102  e  1.2649111
113  a -1.2649111
123  b -0.6324555
133  c  0.000
143  d  0.6324555
153  e  1.2649111
> 
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Linux Editor

2010-08-02 Thread Bos, Roger
I use RKWard and find it to be pretty good.  It show the consol built-in
and has good editing features.  You can add custom shortcuts so I can
make it work just like I make Tinn-R work (i.e. hit F10 to run selected
code, etc.).  Please note that Tinn-R is not available on Linux (to my
knowledge), though I wish it were.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of seeliger.c...@epamail.epa.gov
Sent: Monday, August 02, 2010 11:49 AM
To: r-help@r-project.org
Subject: Re: [R] Linux Editor

> Is there anything comparable to the mac version of R with its built in

> console, editor, etc??

Aside from ESS/EMACS, you might try JGR, Tinn-R and Eclipse with StatET.

The later has the most features and is the best IDE, and we're in the
process of migrating to it from Tinn-R.

cur
--
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov
541/754-4638
[[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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] [Rd] R CMD build wiped my computer

2010-07-28 Thread Bos, Roger
Ubuntu also uses ~ as a backup file syntax, but Ubuntu has a trash can
where deleted files are located, so it would be easy to restore them.  I
would be surprised if Fedora didn't also have a trash can. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Duncan Murdoch
Sent: Wednesday, July 28, 2010 11:12 AM
To: Jarrod Hadfield
Cc: r-help@r-project.org; Marc Schwartz
Subject: Re: [R] [Rd] R CMD build wiped my computer

On 28/07/2010 10:01 AM, Jarrod Hadfield wrote:
> Hi Marc,
>
> Thanks for the info on recovery - most of it can pieced together from 
> backups but a quick, cheap and easy method of recovery would have been

> nicer.
>
> My main concern is that this could happen again and that the "bug" is 
> not limited to R 2.9. I would think that an accidental carriage return

> at the end of a file name (even a temporary one) would be a reasonably

> common phenomenon (I'm surprised I hadn't done it before).
>   

If you can put together a recipe to reproduce the problem (or a less
extreme version of R deleting files it shouldn't), we'll certainly fix
it.  But so far all we've got are guesses about what might have gone
wrong, and I don't think anyone has been able to reproduce the problem
on current R.

Duncan Murdoch
> Cheers,
>
> Jarrod
>
>
>
> On 28 Jul 2010, at 14:04, Marc Schwartz wrote:
>
> > Jarrod,
> >
> > Noting your exchange with Martin, Martin brings up a point that 
> > certainly I missed, which is that somehow the tilde ('~') character 
> > got into the chain of events. As Martin noted, on Linuxen/Unixen 
> > (including OSX), the tilde, when used in the context of file name 
> > globbing, refers to your home directory. Thus, a command such as:
> >
> >  ls ~
> >
> > will list the files in your home directory. Similarly:
> >
> >  rm ~
> >
> > will remove the files there as well. If the -rf argument is added, 
> > then the deletion becomes recursive through that directory tree, 
> > which appears to be the case here.
> >
> > I am unclear, as Martin appears to be, as to the steps that caused 
> > this to happen. That may yet be related in some fashion to Duncan's 
> > hypothesis.
> >
> > That being said, the use of the tilde character as a suffix to 
> > denote that a file is a backup version, is not limited to Fedora or 
> > Linux, for that matter. It is quite common for many text editors 
> > (eg. Emacs) to use this. As a result, it is also common for many 
> > applications to ignore files that have a tilde suffix.
> >
> > Based upon your follow up posts to the original thread, it would 
> > seem that you do not have any backups. The default ext3 file system 
> > that is used on modern Linuxen, by design, makes it a bit more 
> > difficult to recover deleted files. This is due to the unlinking of 
> > file metadata at the file system data structure level, as opposed to

> > simply marking the file as deleted in the directory structures, as 
> > happens on Windows.
> >
> > There is a utility called ext3undel 
> > (http://projects.izzysoft.de/trac/ext3undel
> > ), which is a wrapper of sorts to other undelete utilities such as 
> > PhotoRec and foremost. I have not used it/them, so cannot speak from

> > personal experience. Thus it would be a good idea to engage in some 
> > reviews of the documentation and perhaps other online resources 
> > before proceeding. The other consideration is the Catch-22 of not 
> > copying anything new to your existing HD, for fear of overwriting 
> > the lost files with new data. So you would need to consider an 
> > approach of downloading these utilities via another computer and 
> > then running them on the computer in question from other media, such

> > as a CD/DVD or USB HD.
> >
> > A more expensive option would be to use a professional data recovery

> > service, where you would have to consider the cost of recovery 
> > versus your lost time. One option would be Kroll OnTrack UK 
> > (http://www.ontrackdatarecovery.co.uk/
> > ). I happen to live about a quarter mile from their world HQ here in

> > a suburb of Minneapolis. I have not used them myself, but others 
> > that I know have, with good success. Again, this comes at a 
> > potentially substantial monetary cost.
> >
> > The key is that if you have any hope to recover the deleted files, 
> > you not copy anything new onto the hard drive in the mean time.
> > Doing so will decrease the possibility of file recovery to near 0.
> >
> > As Duncan noted, there is great empathy with your situation. We have

> > all gone through this at one time or another. In my case, it was 
> > perhaps 20+ years ago, but as a result, I am quite anal retentive 
> > about having backups, which I have done for some time on my systems,

> > hourly.
> >
> > HTH,
> >
> > Marc Schwartz
> >
> >
> > On Jul 28, 2010, at 5:55 AM, Jarrod Hadfield wrote:
> >
> >> Hi Martin,
> >>
> >> I think this is the most likely reason given that the name in the 
> >> DESCRIPTION file d

Re: [R] Linux-Windows problem

2010-07-06 Thread Bos, Roger
Its not an R problem, but an editor problem (therefore slightly off-topic I 
admit).  I do most of the coding in Windows and somestimes the Rkward editor 
(in linux) will not open the file and it tells me it cannot determine the 
encoding.  If I try to source that file into R (in the linux version) I 
sometimes get an unexpected character on line such and such, but I don't see 
any problem and the code runs fine in windows.  The fix, I discovered is to 
open the file in notepad (in windows) and resave it.  Then Rkward will open it 
just fine.  

I am sure there is an easy setting I can change to make the two work more 
smoothly together, but I just haven't found it yet.

Thanks,

Roger


-Original Message-
From: henrik.bengts...@gmail.com [mailto:henrik.bengts...@gmail.com] On Behalf 
Of Henrik Bengtsson
Sent: Tuesday, July 06, 2010 9:24 AM
To: Bos, Roger
Cc: Uwe Ligges; Ildiko Varga; r-help
Subject: Re: [R] Linux-Windows problem

Sorry for asking the obvious, but have you confirmed that you are running the 
same version of R on both systems?

/H

On Tue, Jul 6, 2010 at 2:11 PM, Bos, Roger  wrote:
> Uwe,
>
> I suspect I might be having a similar problem as the R code I generate 
> in Windows editor (Tinn-R) doesn't always open properly in my Linux 
> editor (Rkward), but I don't know how to change the default encoding 
> in either one.
>
> In R on both machines, getOption("encoding") returns "native.enc", so 
> the problem is not with R, but rather at the OS or editor level.  If 
> you or anyone could help me out that would be appreciated.
>
> Thanks,
>
> Roger
>
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org]
> On Behalf Of Uwe Ligges
> Sent: Monday, July 05, 2010 10:04 AM
> To: Ildiko Varga
> Cc: r-help@r-project.org
> Subject: Re: [R] Linux-Windows problem
>
>
>
> On 05.07.2010 14:31, Ildiko Varga wrote:
>> Dear All,
>>
>> I faced the following problem. With the same data.frame the results 
>> are different under Linux and Windows.
>> Could you help on this topic?
>
> I guess you read in the data differently since you have different 
> default encodings on both platforms (e.g. latin1 vs. UTF-8) and you 
> data is probably not plain ASCII.
>
> Best,
> Uwe Ligges
>
>> Thanks in advance,
>> Ildiko
>>
>> Linux:
>>   >  d = read.csv("CRP.csv")
>>   >  d$drugCode = as.numeric(d$drug)
>>   >  cor(d, use="pairwise.complete.obs")
>> PATIENT BL.CRP   X24HR.CRP   X48HR.CRP drug   
>> drugCode PATIENTNA NA  NA  NA   NA 
>> NA BL.CRP NA  1.000  0.84324880 -0.05699590   NA 
>> -0.3367147 X24HR.CRP  NA  0.8432488  1. -0.06162383   NA 
>> -0.3557316 X48HR.CRP  NA -0.0569959 -0.06162383  1.   NA  
>> 0.1553356 drug   NA NA  NA  NA   NA 
>> NA drugCode   NA -0.3367147 -0.35573159  0.15533562   NA  
>> 1.000 Warning message:
>> In cor(d, use = "pairwise.complete.obs") : NAs introduced by coercion
>>   >  str(d)
>> 'data.frame':   41 obs. of  6 variables:
>>$ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13
>> 14
>> 15 17 ...
>>$ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
>>$ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
>>$ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
>>$ drug : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 
>> 1
> 1
>> 1 ...
>>$ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
>>
>>   Windows:
>>   >  d = read.csv("CRP.csv")
>>   >  d$drugCode = as.numeric(d$drug)
>>   >  cor(d, use="pairwise.complete.obs") Error in cor(d, use =
>> "pairwise.complete.obs") : 'x' must be numeric
>>   >  str(d)
>> 'data.frame':   41 obs. of  6 variables:
>>$ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13
>> 14
>> 15 17 ...
>>$ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
>>$ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
>>$ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
>>$ drug : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 
>> 1
> 1
>> 1 ...
>>$ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
>>
>>   [[alternative HTML version deleted]]
>>
>> __

Re: [R] Linux-Windows problem

2010-07-06 Thread Bos, Roger
Uwe,

I suspect I might be having a similar problem as the R code I generate
in Windows editor (Tinn-R) doesn't always open properly in my Linux
editor (Rkward), but I don't know how to change the default encoding in
either one.  

In R on both machines, getOption("encoding") returns "native.enc", so
the problem is not with R, but rather at the OS or editor level.  If you
or anyone could help me out that would be appreciated.

Thanks,

Roger 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Uwe Ligges
Sent: Monday, July 05, 2010 10:04 AM
To: Ildiko Varga
Cc: r-help@r-project.org
Subject: Re: [R] Linux-Windows problem



On 05.07.2010 14:31, Ildiko Varga wrote:
> Dear All,
>
> I faced the following problem. With the same data.frame the results 
> are different under Linux and Windows.
> Could you help on this topic?

I guess you read in the data differently since you have different
default encodings on both platforms (e.g. latin1 vs. UTF-8) and you data
is probably not plain ASCII.

Best,
Uwe Ligges

> Thanks in advance,
> Ildiko
>
> Linux:
>   >  d = read.csv("CRP.csv")
>   >  d$drugCode = as.numeric(d$drug)
>   >  cor(d, use="pairwise.complete.obs")
> PATIENT BL.CRP   X24HR.CRP   X48HR.CRP drug   drugCode
> PATIENTNA NA  NA  NA   NA NA
> BL.CRP NA  1.000  0.84324880 -0.05699590   NA -0.3367147
> X24HR.CRP  NA  0.8432488  1. -0.06162383   NA -0.3557316
> X48HR.CRP  NA -0.0569959 -0.06162383  1.   NA  0.1553356
> drug   NA NA  NA  NA   NA NA
> drugCode   NA -0.3367147 -0.35573159  0.15533562   NA  1.000
> Warning message:
> In cor(d, use = "pairwise.complete.obs") : NAs introduced by coercion
>   >  str(d)
> 'data.frame':   41 obs. of  6 variables:
>$ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13 
> 14
> 15 17 ...
>$ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
>$ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
>$ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
>$ drug : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 1
1
> 1 ...
>$ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
>
>   Windows:
>   >  d = read.csv("CRP.csv")
>   >  d$drugCode = as.numeric(d$drug)
>   >  cor(d, use="pairwise.complete.obs") Error in cor(d, use = 
> "pairwise.complete.obs") : 'x' must be numeric
>   >  str(d)
> 'data.frame':   41 obs. of  6 variables:
>$ PATIENT  : Factor w/ 41 levels "RV13","RV14",..: 2 3 4 6 7 12 13 
> 14
> 15 17 ...
>$ BL.CRP   : num  7.3 31.2 4.2 6.7 1.6 7.7 5.3 38.9 1 7.3 ...
>$ X24HR.CRP: num  6.1 24.9 11.1 4.9 1 5 3.7 18 1 7.3 ...
>$ X48HR.CRP: num  121.5 40 28.4 34.5 33.3 ...
>$ drug : Factor w/ 2 levels "active","placebo": 1 1 1 1 1 1 1 1
1
> 1 ...
>$ drugCode : num  1 1 1 1 1 1 1 1 1 1 ...
>
>   [[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.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Slightly OT: how to save Tinn-R files to open in linux

2010-06-15 Thread Bos, Roger
I use two PCs for my R programming, one Win32 and one Linux (Ubuntu 10).
In Windows I use Tinn-R to save my code and occasionally I am unable to
open a Tinn-R saved file in Ubuntu.  If I try to open in gedit I get a
message that "gedit has not been able to detect the character encoding."
To correct this problem I have to open the file in notepad and save it
again.  Is there a setting I can change in Tinn-R (or in Ubuntu) so that
these files will play well together?  This doesn't happen all the time,
but enough to be annoying.  Thanks in advance for any advice.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Using object.size inside a function

2010-04-13 Thread Bos, Roger
When I encounter memory errors, I like to see the size of the objects in
memory, so I modified one of the examples:

z <- sapply(ls(), function(x) object.size(get(x)))
as.matrix(rev(sort(z))[1:10])

This works fine if I run it as is, but if I try to place it inside a
function, I get an error (see below).  I tried using sort.list and
unlist, but I couldn't get it to work.  I don't understand why the
commands work by themselves but not in a function.  Its probably a
simple fix, can anyone enlighten me?

Thanks, Roger.

> "mysize" <- function() {
+ z <- sapply(ls(), function(x) object.size(get(x)))
+ as.matrix(rev(sort(z))[1:10])
+ }

> mysize()
Error in sort.list(z) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
> 
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] R 2.6 Support Question

2010-04-06 Thread Bos, Roger
Many others have made good comments regarding your questions, my
suggestion would be this:  You may or may not know that R is freely
available and that you can install more than one version of R on the
same PC, so I would suggest installing both R 2.6 and the latest version
of R (2.10.x) and try running your code under both versions and see
what, if any, errors crop up.  There is a good chance that your code
will run unmodified on R 2.10, although there have been some minor
changes in function returns and the like, but its best just to try it
out and see what you get.  Ideally if your code runs on both and you get
the same output, you can feel comfortable upgrading to the latest
version.

HTH,

Roger

 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Raadt, Timothy W.
Sent: Monday, April 05, 2010 10:21 AM
To: 'r-help@R-project.org'
Subject: [R] R 2.6 Support Question


Hello,

I have a question on the support of the R 2.6 software.  We are in the
process of planning for a  hardware refresh and our new machines will be
running Windows 7 and Internet Explorer 8.   My question is if the R 2.6
software would be supported on a system running Windows 7 and Internet
Explorer 8?  Also, are you aware of any customers having issues with
Windows 7 and/or  Internet Explorer 8?

Thank you for your time and any information you can provide.

Tim Raadt
Systems Developer
Federated Insurance
121 East Park Square
Owatonna, MN 55060
507-444-7163





This e-mail and its attachments are intended only for the use of the
addressee(s) and may contain privileged, confidential or proprietary
information. If you are not the intended recipient, or the employee or
agent responsible for delivering the message to the intended recipient,
you are hereby notified that any dissemination, distribution,
displaying, copying, or use of this information is strictly prohibited.
If you have received this communication in error, please inform the
sender immediately and delete and destroy any record of this message.
Thank you.
[[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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Reading SQL Server Tables using RODBC

2010-03-25 Thread Bos, Roger
Paul,

I have never tried odbcDriverConnect, but I can tell you how I connect to my 
SQL Server 2005 db.  I create a DNS entry using "odbcad32" (use start>run).  
You can specify everything there and test the connection.  Once that tests 
okay, just use the following:

library(RODBC)
xf <- odbcConnect("dns entry name", "sql username", "sql user password")

HTH,

Roger


 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Paul Miller
Sent: Thursday, March 25, 2010 12:47 PM
To: r-help@r-project.org
Subject: [R] Reading SQL Server Tables using RODBC

Hello Everyone,
 
I'm still quite new to R and am having trouble reading SQL Server Tables using 
RODBC. I've looked though the RODBC documentation as well as material I found 
online and in the book "Data Manipulation with R," but I just can't quite seem 
to get things to work.
 
Right now, I have code that looks something like:
 
channel <- odbcDriverConnect
("Driver=SQL Server;
Server=Fred; Connection=xx.x.x.xxx
Database=mydatabasename;
uid=pmiller; pwd=password;
Trusted_Connection=FALSE;")
 
When I run this code, I get the following error:
 
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] 
Data source name not found and no default driver specified
 
I do seem to be able to make a connection if I use:
 
channel <- odbcDriverConnect("driver=SQL Server; server=Fred")
 
Here, I haven't specified enough information but am allowed to do so 
subsequently using the SQL Server Login.
 
Can anyone show me how to rewrite the code above to make the connection I need 
without using the SQL Server Login?
 
Thanks,
 
Paul
 
 
 


  __
Looking for the perfect gift? Give the gift of Flickr! 


[[alternative HTML version deleted]]
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] rpad ?

2010-03-24 Thread Bos, Roger
Erich,

I use Rpad actively so I am disappointed to hear it is no longer being
updated.  Would you be willing to share your modifications with the
list, or at least with me?

Thanks,

Roger
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Erich Neuwirth
Sent: Tuesday, March 23, 2010 4:47 PM
To: r-help@r-project.org
Subject: Re: [R] rpad ?

We are using RPad for a teaching application here.
But we had to find many things the hard way, and additionally, it did
not survive the latest R release change.
There is a minimal repair, but the maintainer does not answer any email
any more. We did the repair and are giving a modified version to our
students, but we do not have enough resource to take over maintenance.



On 3/23/2010 8:00 PM, sjaffe wrote:
> 
> Is anyone using rpad? Is there any documentation or examples beyond 
> that in the 'man' directory of the source?
> 

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group Visit our SunSITE at
http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Creating pdfs using qplot in qqplot2

2010-03-23 Thread Bos, Roger
I am trying to create plots within a for loop and output them to a pdf.
Here is a working example using plot:

  gg <- data.frame(datadate=1:4, spread=5:8)
  pdf()
  for (i in 1:3) {
  plot(gg$datadate, gg$spread, main=i)
  }
  dev.off()

I am trying to learn more about ggplot2 so I try a slight modification
and it doesn't work.  Anyone know how to do this using qplot in ggplot2?


   gg <- data.frame(datadate=1:4, spread=5:8)
  pdf()
  for (i in 1:3) {
  qplot(gg$datadate, gg$spread, geom="line", main=i)
  }
  dev.off()

***

This message is for the named person's use only. It may\...{{dropped:20}}

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


[R] Remove leading and trailing white spaces

2009-11-20 Thread Bos, Roger
I have a character string and I would like to remove the leading and
tailing white spaces.  The example for 'sub' shows how to remove the
trailing white spaces, but I still can't figure out how to remove both
trailing and leading white spaces because I can't find any documentation
for what "+$" means or what "\\s+$" means.  Maybe its because I don't
have a Unix background.  Thanks in advance for any help with this.

str <- 'Now is the time  '
sub(' +$', '', str)  ## spaces only
sub('[[:space:]]+$', '', str) ## white space, POSIX-style
sub('\\s+$', '', str, perl = TRUE) ## Perl-style white space

Thanks,

Roger
***

This message is for the named person's use only. It may\...{{dropped:23}}

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


Re: [R] Transporting data in different R windows

2009-07-29 Thread Bos, Roger
I wrote simple function to copy data from/to excel using the clipboard.
These should also work from one window to the next:

# To read from clipboard
"fromExcel" <- function() {read.table("clipboard-128", header=TRUE,
sep="\t")}
"toExcel" <- function(x) {write.table(x, "clipboard-128", sep="\t",
row.names=FALSE)} 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Bogaso
Sent: Wednesday, July 29, 2009 9:16 AM
To: r-help@r-project.org
Subject: [R] Transporting data in different R windows


Hi,

I am working with multiple R-windows opened and would like to transport
some variables from one to another. Is there any direct way to do this
without saving them in hard-disk?

Thanks
--
View this message in context:
http://www.nabble.com/Transporting-data-in-different-R-windows-tp2471907
7p24719077.html
Sent from the R help mailing list archive at Nabble.com.

__
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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

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


Re: [R] Most used R editors

2009-06-02 Thread Bos, Roger
I have not seen Tinn-R mentioned so I will mention it.  Its worked great for 
me.  Eclipse is a nice IDE, but its more complicated that what is necessary for 
R programming.
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Martial Sankar
Sent: Tuesday, June 02, 2009 3:06 AM
To: rhelp
Subject: [R] Most used R editors


Hi,

I am a little lonely as R users in my group. So, I would like to know which 
editor is the most used in the R community.
This post is some kind of survey.

Personally, I use  Emacs with ESS, It permits to :

- open more than one R session
- split the emacs editor as many part as you want.
- use a lot of keybindings.
...

I also tried Rkwards, Scilab (windows), JGR etc... but they are not suitable 
for what I do.

Best,

- Martial


_
Découvrez toutes les possibilités de communication avec vos proches

[[alternative HTML version deleted]]


** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] How do I sign off this server

2008-10-27 Thread Bos, Roger
John,

If you really do like the R-help list, you may want to see if your email
program has folders and auto-rules.  Since all R-help emails have [R] in
the subject line, you can put all those email in a separate folder so
everything doesn't get mixed up.  That is what I do.

HTH, Roger

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Fresen, John
Sent: Sunday, October 26, 2008 11:42 PM
To: Fresen, John; r-help@r-project.org
Subject: Re: [R] How do I sign off this server

I signed onto this R-help server.  It's wonderful but I'm getting to
many e-mails all mixed up with other important e-mails.  I can't cope
with it all.  
How do I sign off?

Thanks

John 

John L. Fresen, PhD
Department of Statistics, 134N Middlebush Hall University of
Missouri-Columbia, 65211, MO, US
(573) 882-9660 (phone)   (573) 884-5524 (fax)
www.stat.missouri.edu
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Martin Ballaschk
Sent: Saturday, October 25, 2008 7:52 PM
To: r-help@r-project.org
Subject: Re: [R] help: selection of data

Hi Jim.

jim holtman schrieb:
> If you only want the first sequence,

Yes, that's true, I forgot to say that!

>> x <- c(-10, -5, 0, 5, 10, 15, 20)
>> y <- c(10, 10, 10, -5, -6, -7, 10)
>> data <- as.matrix( cbind(x, y) )
>> # if you only want the first 'run', then use 'rle' to find it mask <-

>> data[,1] > 0 & data[,2] > min(data[,2]) run <- rle(mask) # now either

>> the first or second will be TRUE, so find it offset <- cumsum(c(1, 
>> run$lengths))  # off set of the start of
sequence
>> index <- if (run$values[1]) 1 else 2
>> new_data <- data[seq(from=offset[index], length=run$lengths[index]),]
>>

Although I'm far from understanding that -- it seems to work very well
for me. Will have a look into it tomorrow ...

Thanks!

Cheers
Martin

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

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] Creating GUIs for R

2008-10-12 Thread Bos, Roger
Ricardo,

I forgot to mention to you the web site: www.rpad.org.  You can view that site 
to see how well Rpad will look using your configuration.  I only have Windows 
and I recall that under Firefox my page didn't work quite as well as it did 
with IE, but I don't know if that was my limited HTML skills or something 
inherent to Rpad.  I am also not on the latest version of Rpad, so its best to 
view official site to see how it will look.

Thanks,

Roger
 

-Original Message-
From: [Ricardo Rodriguez] Your XEN ICT Team [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2008 7:24 PM
To: Bos, Roger
Cc: R-help
Subject: Re: [R] Creating GUIs for R

Hi Roger,

Bos, Roger wrote:
> I haven't heard Rpad mentioned yet, so I will mention it.  Rpad allows you to 
> run R code inside a browser window.  You can many any kind of GUI you want 
> using html forms and then call the R function from the html page.  The 
> Apache/Rpad install works on any platform and anyone who uses it just need a 
> browser.  I use it at my work to make my R function available to everyone 
> else (none of whom know R).  Very happy with it.

Has you tried Safari or Firefox 3.0 running on Mac with your Rpad installation? 
I am not sure if I am getting a running local Rpad copy here. Thanks!

Best,

Ricardo

--
Ricardo Rodríguez
Your XEN ICT Team


** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] Creating GUIs for R

2008-10-10 Thread Bos, Roger
I haven't heard Rpad mentioned yet, so I will mention it.  Rpad allows you to 
run R code inside a browser window.  You can many any kind of GUI you want 
using html forms and then call the R function from the html page.  The 
Apache/Rpad install works on any platform and anyone who uses it just need a 
browser.  I use it at my work to make my R function available to everyone else 
(none of whom know R).  Very happy with it.

Good luck,

Roger
 



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [Ricardo 
Rodriguez] Your XEN ICT Team
Sent: Thursday, October 09, 2008 5:05 PM
To: Greg Snow
Cc: Antonio Martinez Cortizas; [EMAIL PROTECTED]; Wade Wall
Subject: Re: [R] Creating GUIs for R

Thanks Greg,

Greg Snow wrote:
> I am not involved in the RExcel project.  I have just had some discussions 
> with the people that are, so you should contact them for specific questions.
>
> I believe that this currently only works on windows, there was some mention 
> of possibly expanding it to OpenOffice so that it would be cross platform, 
> but I have no idea if that has made it past the "good idea" stage.
If we must away from Excel, don't you think that Gnumeric/R could be a nice 
option?

Cheers,

Ricardo


--
Ricardo Rodríguez
Your XEN ICT Team

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


[R] How to send Html using SQL Server db mail

2008-08-20 Thread Bos, Roger
All,

I have a variable called `go` and it has a single quote in the name
column of line 47 that I am trying to get rid of.  I have tried using
gsub, but I cannot get the syntax correct to tell R to remove the '
(single quote).  

> go[47,]
gvkey SymbolName   Rank MarketCap MemoDate
Action Analyst Reason SharesHeld
75 065105 BJ BJ'S WHOLESALE CLUB INC 0.9579   2258.24 
  
>

I have tried every combination I could think of, some of them being:
gsub(go, `'`, ` `)
gsub(go, "'", " ")
gsub(go, "\'S", " S")
gsub(go, "'S", "S")

I understand the problem is that R interprets the single quote as a
single quote instead of a character that I want to remove, but I don't
know how to tell R that I want to identiy the single quote and remove
it. This is probably easy for some, but to me it seems much more
difficult than it should be.

Thanks,

Roger

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


[R] How to remove white spaces

2008-08-15 Thread Bos, Roger
All,

I am storing a string of email addresses in a table and when I retrieve
them using a RODBC statement such as:

test = sqlQuery(xf, "select specialist from
roger_sector_specialist")$specialist

'test' is of mode list and includes a bunch of white space.  As a
work-around I convert 'test' to a character string, split it based on a
white space, then take the first element:

test = strsplit(as.character(test), " ")
emaillist = test[[1]][1]
   
But I am sure there is a better way.  I did help.search("trim white
space") and R didn't return anything, which I found strange.  Any
advice?

Thanks,

Roger

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


[R] Error in FUN(newX[, i], ...) : no complete element pairs in R 2.7.0 patched

2008-05-06 Thread Bos, Roger
Using R 2.6.0 patched I was able to calculate the variance of each row
of a matrix without error, even if some rows had only NAs.  I would just
get NAs back as the variance for those rows.  Now with R 2.7.0 patched I
get an error "no complete element pairs" if any one row has all NAs.
Can anyone tell if I can make R 2.7.0 patched behave as R 2.6.0 did so I
don't have to change all my code.  Or maybe suggest a simple work
around. A short example is below.  Thanks in advance. 

dat <- data.frame(aa=c(1,2,as.numeric('NA'),4),
bb=c(2,3,as.numeric('NA'),5), cc=c(3,4,as.numeric('NA'),6),
dd=c(4,5,as.numeric('NA'),7))
apply(dat, 1, var, na.rm=TRUE)


> dat
  aa bb cc dd
1  1  2  3  4
2  2  3  4  5
3 NA NA NA NA
4  4  5  6  7
> apply(dat, 1, var, na.rm=TRUE)
Error in FUN(newX[, i], ...) : no complete element pairs
> 
> 

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] How to parse XML

2008-05-02 Thread Bos, Roger
Martin,

I can't thank you enough for taking the time to help and providing the
detailed examples of how to get started.  Now I know exactly how to
proceed.

Thanks again,

Roger 

-Original Message-
From: Martin Morgan [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 02, 2008 12:02 PM
To: Bos, Roger
Cc: r-help@r-project.org
Subject: Re: [R] How to parse XML

Hi Roger --

"Bos, Roger" <[EMAIL PROTECTED]> writes:

> I would like to learn how to parse a mixed text/xml document I 
> downloaded from the sec.gov website (see example below).  I would like

I'm not sure of a more robust way to extract the XML, but from
inspection I wrote

> ftp <-
"ftp://anonymous:[EMAIL PROTECTED]/edgar/data/1317493/0001144204-08-02122
1.txt"
> txt <- readLines(ftp)
> xmlInside <- grep(" xmlTxt <- txt[seq(xmlInside[1]+1, xmlInside[2]-1)]

so that xmlTxt contains the part of the message that is XML

> to parse this to get the value for each xml tag and then access it 
> within R, but I don't know much about xml so I don't even know where 
> to

There are several ways to proceed. I personally like the xpath query
language. to do this, one might

> xml <- xmlTreeParse(xmlTxt, useInternal=TRUE) 
> head(unlist(xpathApply(xml, "//*", xmlName)))

[1] "ownershipDocument" "schemaVersion" "documentType"

[4] "periodOfReport""notSubjectToSection16" "issuer"



xpathApply takes an xml document and performs a query. The query '//*'
says find all nodes mataching any character string (that's the *) that
are located anywhere (that's the //) below the current (in this case
root) node. This gives a list of nodes; xmlName extracts the name of the
node. If I wanted all nodes not subject to section 16 (sounds
ominmous) I'd extract all the nodes (a list0

> node <- xpathApply(xml, "//notSubjectToSection16")

and then do something with them, e.g., look at them

> lapply(node, saveXML)
[[1]]
[1] "0"

(not so bad, looks like nothing is not subject to section 16, that's a
relief) and extract their value

> lapply(node, xmlValue)

In one step:

> xpathApply(xml, "//notSubjectToSection16", xmlValue)

?xpathApply is a good starting place, as is http://www.w3.org/TR/xpath,
especially

http://www.w3.org/TR/xpath#path-abbrev

Martin

> start debugging the errors I am getting in this example code.  Can 
> anyone help me get started?
>
> Thanks, Roger
>
> ftp <-
> "ftp://anonymous:[EMAIL PROTECTED]/edgar/data/1317493/0001144204-08-021
> 22
> 1.txt"
> download.file(url=ftp, destfile="test2.txt")
> xmlTreeParse("test2.txt")
>
>
> **

> * This message is for the named person's use only. It may contain 
> confidential, proprietary or legally privileged information. No right 
> to confidential or privileged treatment of this message is waived or 
> lost by any error in transmission. If you have received this message 
> in error, please immediately notify the sender by e-mail, delete the 
> message and all copies from your system and destroy any hard copies. 
> You must not, directly or indirectly, use, disclose, distribute, print

> or copy any part of this message if you are not the intended 
> recipient.
>
> __
> 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.

--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center 1100
Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


[R] How to parse XML

2008-05-02 Thread Bos, Roger
I would like to learn how to parse a mixed text/xml document I
downloaded from the sec.gov website (see example below).  I would like
to parse this to get the value for each xml tag and then access it
within R, but I don't know much about xml so I don't even know where to
start debugging the errors I am getting in this example code.  Can
anyone help me get started?

Thanks, Roger

ftp <-
"ftp://anonymous:[EMAIL PROTECTED]/edgar/data/1317493/0001144204-08-02122
1.txt"
download.file(url=ftp, destfile="test2.txt")
xmlTreeParse("test2.txt")


** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] how can i add a package that i want to use permanent

2008-01-10 Thread Bos, Roger
Another option is to modify the Rprofile.site file in the etc folder of
your R installation.  Then you don't have to save the workspace. You add
as much startup scripting as you want to the Rprofile.site file.

HTH,

Roger
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Charles Annis, P.E.
Sent: Thursday, January 10, 2008 9:11 AM
To: '???'; [EMAIL PROTECTED]
Subject: Re: [R] how can i add a package that i want to use permanent

?.First
This will explain things.  


You make a hidden program called .First like this

.First <- function() { library(lattice) }

and then save your workspace.  The next time you open R, lattice will
load automatically.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of ???
Sent: Wednesday, January 09, 2008 10:28 PM
To: [EMAIL PROTECTED]
Subject: [R] how can i add a package that i want to use permanent

I want use a package(lattice) in R to do some work but everytime when i
open R program  ,this package is not loaded, so  everytime  i have to
load it , who can tell me  how to load this package permanent

thanks!!!
--
:zND2(
TEL:15918732631
E-MAIL:[EMAIL PROTECTED]
[EMAIL PROTECTED]

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] Junk or not Junk ???

2007-12-10 Thread Bos, Roger
Ok, outlook may not be that great, but even in outlook you can create a
separate folder called "R" and create a rule so all email with "[R]" or
"[Rdevel]" etc. going into the R folder.  That way you can easily scan
your R mail separate from your regular mail and then delete everything
you don't need.  That's what I do on my work PC.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Patrick Connolly
Sent: Saturday, December 08, 2007 4:08 AM
To: Loren Engrav
Cc: r-help@r-project.org
Subject: Re: [R] Junk or not Junk ???

On Thu, 06-Dec-2007 at 04:29PM -0800, Loren Engrav wrote:

|> As for news readers
|> I found R and R.mac and R.Bio on the sites you recommend, thank you 
|> very much, they would avoid the individual emails, but then I would 
|> have to go look at them, which might be Ok
|> 
|> Deluge? Well, there are from R and Bio and R-Mac every morning 30 or 
|> 35, and
|> 10-15 more during the daytime, and ~50 deletes is painful
|> 
|> But then every morning one or two are useful so...

I find it absolutely essential to have a client that can display mail in
threads.  Deleting mail a thread at a time is an order of magnitude more
efficient.  Nabble does a fairly good job of showing threads, but I
would prefer to download every message and delete the threads I'm
ignoring.  Even on a good connexion, the delays downloading individual
messages add up.  And gmail is slower still.  Another advantage of your
own client is that you can use a monospaced font which is far easier for
reading code which is bound to happen on a list like this.

Most people I know have the misfortune of not having access to a mail
client that displays threads[1], but for anyone who has control over
such things, in the Windows world, I know Thunderbird is fairly good,
but if you're fortunate enough to be allowed to use Linux, there is Mutt
or you might like Emacs as a mail client which both do threads very well
without the need to use a mouse -- which I consider a huge bonus.

[]


|> 
|> Still would be fun to understand why some R are junk and some are not

As several have said, it's to do with your mail client and/or how mail
and spam filters are set up on your domain.  Nothing to do with this
list.

1. Read "misfortune of having to use Outlook or even Outlook Express"


best

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] R 2.6.1 & library(svIDE)

2007-11-27 Thread Bos, Roger
I get that even with R 2.6.0, but its not really a problem, just a
warning.  In other words, everything I have done in R has worked fine
despite that warning.  It would be nice if it was eventually cleaned up,
but it doesn't stop you from using R.


 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Olivier Delaigue
Sent: Tuesday, November 27, 2007 3:29 AM
To: r-help@r-project.org
Subject: [R] R 2.6.1 & library(svIDE)


Hi all,

I have installed in R 2.6.1 the svIDE package (0.9-5), but I have a
problem when I load it.


> library(svIDE)
Warning messages:
1: '\A' is an unrecognized escape in a character string
2: unrecognized escape removed from ";for Options\AutoIndent: 0=Off,
1=follow language scoping and 2=copy from previous line\n" 
3: In grep(paste("[{]TclEval ", topic, "[}]", sep = ""),
tclvalue(.Tcl("dde services TclEval {}")),  :
  argument 'useBytes = TRUE' will be ignored

Thank you,

Olivier Delaigue
--
View this message in context:
http://www.nabble.com/R-2.6.1---library%28svIDE%29-tf4880387.html#a13966
680
Sent from the R help mailing list archive at Nabble.com.

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] linking Tinn-R to a new R version

2007-10-26 Thread Bos, Roger
That is due to some tip-server that will show you the  params available
in functions, so there is a lot of overhead in parsing what you are
currently typing.  Its a nice feature, but I turned it off because of
the slowness.

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jeff Miller
Sent: Friday, October 26, 2007 2:58 PM
To: 'Bert Gunter'; 'Silvia Lomascolo'
Cc: [EMAIL PROTECTED]
Subject: Re: [R] linking Tinn-R to a new R version

While on the Tinn-R topic...

I absolutely love Tinn-R but I have noticed one quirk and am wondering
if anyone else experiences it.

In the middle typing a line of code, sometimes everything will slow
down. I will have to type a letter, wait a second, type a letter, wait a
second, etcuntil I get to the end of the line.

Sincerely,
Jeff Miller

 

Jeffrey M. Miller, PhD
AlphaPoint05, Inc.
Statistics Consultant
2792 SE 27th Ave.
Gainesville, FL 32641
H: 352.505.2798
C: 352.359.6611




Checked by AVG Free Edition. 

3:09 PM

  

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] linking Tinn-R to a new R version

2007-10-26 Thread Bos, Roger
Silvia,

Option / Main / Application then click on the 'R' tab.  At the bottom of
the window you can browse to the new location. 

HTH, Roger

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Silvia Lomascolo
Sent: Friday, October 26, 2007 2:31 PM
To: r-help@r-project.org
Subject: [R] linking Tinn-R to a new R version


Hi all,
Can anyone please tell me how to start R from Tinn-R's "Toogle
start/close Rgui" button, after I've updated to a new version of R? It
seems like Tinn-R keeps looking for the previous version of R. I have
updated R twice already since I started using Tinn-R and I haven't been
able to make that button work again.  It tells me "The specified file
was not found", probably because it's looking for R 2.4.1.

Thanks! Silvia.
--
View this message in context:
http://www.nabble.com/linking-Tinn-R-to-a-new-R-version-tf4699061.html#a
13433013
Sent from the R help mailing list archive at Nabble.com.

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


[R] How to remove non-UTF-8 characters from a string

2007-10-26 Thread Bos, Roger
All,

I am trying to post text from an XLS spread to my wiki and I need to
remove any characters that are not UTF-8.  Is there an easy gsub command
that can do this?

(I previously sent this same email to r-sig-gui.  That was a mistake and
I apologize for the duplication.)

Thanks, Roger J. Bos

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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


Re: [R] Concatenating one character vector into one string

2007-10-01 Thread Bos, Roger
Rainer,

This works: paste(x, sep="", collapse="") 

I would have thought this 'paste(x) would work, but it didn't.

Perhaps someone else can tell us why we need collapse="".  What would
break if the default was collapse="" instead of collapse=NULL?

Thanks,

Roger

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Rainer M. Krug
Sent: Monday, October 01, 2007 8:23 AM
To: r-help
Subject: [R] Concatenating one character vector into one string

Hi

I am sure this is simple - but how can I convert one charecter vector
into one string?

example:

x <- c("This ", "is ", "one ", "sentence.")

should become
"This is one entence"

Thanks

Rainer

--
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Tel:+27 - (0)21 650 5776 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[EMAIL PROTECTED]

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

** *
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient. 

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