[R] bnlearn and cpquery

2017-07-12 Thread Ross Chapman
Hi all

 

I have built a Bayesian network using discrete data using the bnlearn
package.

 

When I try to run the cpquery function on this data it returns NaN for some
some cases.

 

Running the cpquery in debug mode for such a case (n=10^5, method="lw")
creates the following output:

 

generated a grand total of 1e+05 samples.

  > event has a probability mass of 14982.37 out of NaN (p = NaN).

[1] NaN

 

 

The cpquery command takes the following structure:

 

cpquery(fullFitted,event=(C1_class=="Med"),

evidence=list(GK_class = "ModHi",

  GTh_class = "Lo",

  GU_class = "Lo",

  El_class = "Hi",

  E50_class = "Med",

  E150_class = "Med"

) ,

n=10^5,   method =  "lw", debug=TRUE)

 

Similarly, when I try to run the predict method on the same data, it returns
the following warning:

 

Warning message:
In map.prediction(node = node, fitted = object, data = data, n =
extra.args$n,  :
  dropping 38073 observations because generated samples are NAs.

 

 

Could you advise me why these queries are generating NaN values, and how
they might be resolved.

 

The session info is as follows:

 

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
 
Matrix products: default
 
locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C   LC_TIME=English_Australia.1252
 
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 
 
other attached packages:
[1] bnlearn_4.2
 
loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1   

 

 

Many thanks in advance

 

Ross

 


[[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] Quadratic function with interaction terms for the PLS fitting model?

2017-07-12 Thread Ng, Kelvin Sai-cheong
Dear all,

I am using the pls package of R to perform partial least square on a set of
multivariate data.  Instead of fitting a linear model, I want to fit my
data with a quadratic function with interaction terms.  But I am not sure
how.  I will use an example to illustrate my problem:

Following the example in the PLS manual:
## Read data
 data(gasoline)
gasTrain <- gasoline[1:50,]
## Perform PLS
gas1 <- plsr(octane ~ NIR, ncomp = 10, data = gasTrain, validation = "LOO")

where octane ~ NIR is the model that this example is fitting with.

NIR is a collective of variables, i.e. NIR spectra consists of 401 diffuse
reflectance measurements from 900 to 1700 nm.

Instead of fitting with predict.octane[i] = a[0] * NIR[0,i] + a[1] *
NIR[1,i] + ...
I want to fit the data with:
predict.octane[i] = a[0] * NIR[0,i] + a[1] * NIR[1,i] + ... +
b[0]*NIR[0,i]*NIR[0,i] + b[1] * NIR[0,i]*NIR[1,i] + ...

i.e. quadratic with interaction terms.

But I don't know how to formulate this.

May I have some help please?

Thanks,

Kelvin

[[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] about plotting a special case

2017-07-12 Thread Jim Lemon
values A and B have different ranges. Therefore you would want
horizontal error bars for the B mean. The dispersion function doesn't
do horizontal error bars, so you can use plotCI also in plotrix. Here
is an example with two databases:

DF2<-read.table(text="A  B  C
 62 22 54
 69 24 55
 51 28 56
 47 25 53
 70 21 52
 61 23 50
 40 19 51
 58 18 57
 38 24 58
 37 27 53",header=TRUE)
plot(DF1$A,DF1$B,xlim=range(c(DF1$A,DF2$A)),
 ylim=range(c(DF1$B,DF2$B)),pch=19,col="red")
meanA<-mean(DF1$A)
meanB<-mean(DF1$B)
points(meanA,meanB,pch=18,col="red")
q1090<-quantile(DF1$B,probs=c(0.1,0.9))
plotCI(meanA,meanB,ui=q1090[2],li=q1090[1],err="x",
  add=TRUE,col="red")
points(DF2$A,DF2$B,pch=19,col="green")
meanA<-mean(DF2$A)
meanB<-mean(DF2$B)
points(meanA,meanB,pch=18,col="green")
q1090<-quantile(DF2$B,probs=c(0.1,0.9))
plotCI(meanA,meanB,ui=q1090[2],li=q1090[1],err="x",
 add=TRUE,col="red")
# click at the upper left corner of the legend
legend(locator(1),legend=c("DF1","DF2"),pch=19,
 col=c("red","green"))

Jim

On Thu, Jul 13, 2017 at 1:32 PM, lily li  wrote:
> Thanks, Jim. The code works, but I don't understand why you use q1090 <-
> quantile(DF1$B, probs=c()), rather than DF1$A? Also, how to add a legend for
> both points DF1 and DF2?
>
> On Wed, Jul 12, 2017 at 8:25 PM, Jim Lemon  wrote:
>>
>> Hi lily,
>> Here is the first plot:
>>
>> plot(DF1$A,DF1$B,pch=19,col="red")
>> meanA<-mean(DF1$A)
>> meanB<-mean(DF1$B)
>> points(meanA,meanB,pch=18,col="red")
>> q1090<-quantile(DF1$B,probs=c(0.1,0.9))
>> library(plotrix)
>> dispersion(meanA,meanB,q1090[2],q1090[1],
>>  intervals=FALSE,col="red")
>>
>> The same code will work for a second data frame, except that you would
>> use "points" instead of "plot" and change the color. You may also have
>> to specify xlim and ylim in the first call to "plot" so that all
>> values are on the plot.
>>
>> Jim
>>
>>
>>
>> On Thu, Jul 13, 2017 at 11:46 AM, lily li  wrote:
>> > Hi R users,
>> >
>> > I have a question about plotting. There is the dataframe below, while
>> > each
>> > row represents a record. If I want to plot on a A-B plot, i.e., x-axis
>> > represents A, while y-axis represents B values. However, I want to plot
>> > the
>> > mean value from records 1-10 as one point, while the 10th and 90th
>> > percentiles represent the error bars, such as one point in the attached
>> > example. I don't know how to do this, and then add a legend.
>> > After the above step, if I have a dataframe DF2 with the same structure
>> > but
>> > different values than DF1, how to show the point on the same figure, but
>> > use different colors or symbols? Thanks for any advices.
>> >
>> > DF1
>> >
>> > A  B  C
>> > 1 65 21 54
>> > 2 66 23 55
>> > 3 54 24 56
>> > 4 44 23 53
>> > 5 67 22 52
>> > 6 66 21 50
>> > 7 45 20 51
>> > 8 56 19 57
>> > 9 40 25 58
>> > 10   39 24 53
>> >
>> > __
>> > 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] about plotting a special case

2017-07-12 Thread lily li
Thanks, Jim. The code works, but I don't understand why you use q1090 <-
quantile(DF1$B, probs=c()), rather than DF1$A? Also, how to add a legend
for both points DF1 and DF2?

On Wed, Jul 12, 2017 at 8:25 PM, Jim Lemon  wrote:

> Hi lily,
> Here is the first plot:
>
> plot(DF1$A,DF1$B,pch=19,col="red")
> meanA<-mean(DF1$A)
> meanB<-mean(DF1$B)
> points(meanA,meanB,pch=18,col="red")
> q1090<-quantile(DF1$B,probs=c(0.1,0.9))
> library(plotrix)
> dispersion(meanA,meanB,q1090[2],q1090[1],
>  intervals=FALSE,col="red")
>
> The same code will work for a second data frame, except that you would
> use "points" instead of "plot" and change the color. You may also have
> to specify xlim and ylim in the first call to "plot" so that all
> values are on the plot.
>
> Jim
>
>
>
> On Thu, Jul 13, 2017 at 11:46 AM, lily li  wrote:
> > Hi R users,
> >
> > I have a question about plotting. There is the dataframe below, while
> each
> > row represents a record. If I want to plot on a A-B plot, i.e., x-axis
> > represents A, while y-axis represents B values. However, I want to plot
> the
> > mean value from records 1-10 as one point, while the 10th and 90th
> > percentiles represent the error bars, such as one point in the attached
> > example. I don't know how to do this, and then add a legend.
> > After the above step, if I have a dataframe DF2 with the same structure
> but
> > different values than DF1, how to show the point on the same figure, but
> > use different colors or symbols? Thanks for any advices.
> >
> > DF1
> >
> > A  B  C
> > 1 65 21 54
> > 2 66 23 55
> > 3 54 24 56
> > 4 44 23 53
> > 5 67 22 52
> > 6 66 21 50
> > 7 45 20 51
> > 8 56 19 57
> > 9 40 25 58
> > 10   39 24 53
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] about plotting a special case

2017-07-12 Thread Jim Lemon
Hi lily,
Here is the first plot:

plot(DF1$A,DF1$B,pch=19,col="red")
meanA<-mean(DF1$A)
meanB<-mean(DF1$B)
points(meanA,meanB,pch=18,col="red")
q1090<-quantile(DF1$B,probs=c(0.1,0.9))
library(plotrix)
dispersion(meanA,meanB,q1090[2],q1090[1],
 intervals=FALSE,col="red")

The same code will work for a second data frame, except that you would
use "points" instead of "plot" and change the color. You may also have
to specify xlim and ylim in the first call to "plot" so that all
values are on the plot.

Jim



On Thu, Jul 13, 2017 at 11:46 AM, lily li  wrote:
> Hi R users,
>
> I have a question about plotting. There is the dataframe below, while each
> row represents a record. If I want to plot on a A-B plot, i.e., x-axis
> represents A, while y-axis represents B values. However, I want to plot the
> mean value from records 1-10 as one point, while the 10th and 90th
> percentiles represent the error bars, such as one point in the attached
> example. I don't know how to do this, and then add a legend.
> After the above step, if I have a dataframe DF2 with the same structure but
> different values than DF1, how to show the point on the same figure, but
> use different colors or symbols? Thanks for any advices.
>
> DF1
>
> A  B  C
> 1 65 21 54
> 2 66 23 55
> 3 54 24 56
> 4 44 23 53
> 5 67 22 52
> 6 66 21 50
> 7 45 20 51
> 8 56 19 57
> 9 40 25 58
> 10   39 24 53
>
> __
> 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] about plotting a special case

2017-07-12 Thread lily li
Hi R users,

I have a question about plotting. There is the dataframe below, while each
row represents a record. If I want to plot on a A-B plot, i.e., x-axis
represents A, while y-axis represents B values. However, I want to plot the
mean value from records 1-10 as one point, while the 10th and 90th
percentiles represent the error bars, such as one point in the attached
example. I don't know how to do this, and then add a legend.
After the above step, if I have a dataframe DF2 with the same structure but
different values than DF1, how to show the point on the same figure, but
use different colors or symbols? Thanks for any advices.

DF1

A  B  C
1 65 21 54
2 66 23 55
3 54 24 56
4 44 23 53
5 67 22 52
6 66 21 50
7 45 20 51
8 56 19 57
9 40 25 58
10   39 24 53


sample.pdf
Description: Adobe PDF document
__
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] How to make a figure plotting p-values by range of different adjustment values?

2017-07-12 Thread Jim Lemon
Hi Kirsten,
Perhaps this will help:

set.seed(3)
kmdf<-data.frame(group=rep(1:4,each=20),
 prop=c(runif(20,0.25,1),runif(20,0.2,0.92),
 runif(20,0.15,0.84),runif(20,0.1,0.77)))
km.glm<-glm(prop~group,kmdf,family=quasibinomial(link="logit"))
summary(km.glm)
pval<-0.00845
padjs<-NA
npadj<-1
# assume you have five comparisons in this family
for(method in p.adjust.methods) {
 padjs[npadj]<-p.adjust(pval,method=method,n=5)
 npadj<-npadj+1
}
plot(padjs,xaxt="n",main="P plot",xlab="Method",ylab="adjusted p values")
abline(h=0.05,col="lightgray")
library(plotrix)
staxlab(1,at=1:8,labels=p.adjust.methods)

Jim


On Thu, Jul 13, 2017 at 12:53 AM, Kirsten Morehouse
 wrote:
> Hi all,
>
> Thank you for taking the time to read my message. I'm trying to make a
> figure that plots p-values by a range of different adjustment values.
>
> (Using the **logit** function in package **car**)
>
> My Statistical analyses were conducted on probability estimates ranging
> from 0% to 100%. As it's not ideal to run linear models on percentages that
> are bounded between 0 and 1, these estimates were logit transformed.
>
> However, this introduces a researcher degree of freedom. In Package
> **Car**, the logit transformation code is
>
> logit(p = doc$value, adjust = 0.025)
>
> logit definition/Description
>
> Compute the logit transformation of proportions or percentages.
>
> Usage
>
>  logit(p, percents=range.p[2] > 1, adjust)
>
> Arguments
>
> p  a numeric vector or array of proportions or percentages.
> percents TRUE for percentages.
> adjust   adjustment factor to avoid proportions of 0 or 1; defaults to
> 0 if there are no such proportions in the data, and to .025 if there are.)
>
> I chose the default adjustment factor of .025, but I need to determine at
> what point my values are greater than .05 to show I did not choose an
> ajustment value that makes my results significant.
>
> Ultimately, I want to find the range of adjustment factors do we get P <
> 0.05?And at what point do we get P > 0.05?
>
> ## The final product I'm looking for is a figure with the following
> features:
>   ## 1) Adjustment factor on the x-axis
>   ## 2) P value on the y-axis
>
> Does anyone know how to do this? Thank you so much in advance.
>
> [[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] Question on Simultaneous Equations & Forecasting

2017-07-12 Thread OseiBonsu, Frances
Hello,

I have estimated a simultaneous equation model (similar to Klein's model) in R 
using the system.fit package.

I have an identity equation, along with three other equations. Do you know how 
to explicitly identify the identity equation in R?

I am also trying to forecast the dependent variables in the simultaneous 
equation model, while incorporating the identity equation in the forecasts. Is 
there a way to do this in R?

The only way that I have been able to forecast the dependent variables has been 
by getting the predictions of each variable, converting them to time series 
uni-variables, and forecasting each variable individually.

Any help would be appreciated.

Best Regards,

Frances Osei-Bonsu
Summer Analyst, Research and Strategy
LaSalle Investment Management
333 West Wacker Drive, Suite 2300, Chicago IL 60606
Email frances.oseibo...@lasalle.com
Tel +1 312 897 4024
lasalle.com



This email is for the use of the intended recipient(s) only. If you have 
received this email in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this email without the author's prior permission. 
We have taken precautions to minimize the risk of transmitting software 
viruses, but we advise you to carry out your own virus checks on any attachment 
to this message. We cannot accept liability for any loss or damage caused by 
software viruses. The information contained in this communication may be 
confidential and may be subject to the attorney-client privilege. If you are 
the intended recipient and you do not wish to receive similar electronic 
messages from us in the future then please respond to the sender to this effect.

[[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] metRology package

2017-07-12 Thread mark . hogue
I'm having trouble with a simple application with metRology. I need to 
estimate the uncertainty of the density thickness of seven sheets of film. 
This is calculated from measurements of mass, length and width of 
rectangular samples of film.

It's not too hard to calculate the whole thing with a little Monte Carlo 
loop. I get about 0.07 with this:

#sample area
L<-5*2.54 #cm
W<-8*2.54 #cm
#sample mass
m<-0.2543*1000 #mg
#uncertainties
L.u<-(1/16)*2.54 #cm (nearest 16th inch)
W.u<-(1/16)*2.54 #cm 
m.u<-0.006*1000 #mg scale calibration data 

denth<-c(0,0,0)
singth<-c(0,0,0)
for(i in 1:1e5) {
  #denth[i]<-7*dt+sum(rnorm(7,0,dt.u))
  for(j in 1:7)
 singth[j]<-(m+rnorm(1,0,m.u))/((L+rnorm(1,0,L.u))*(W+rnorm(1,0,W.u)))
  denth[i]<-sum(singth)
}
sd(denth) #0.07279882

Now with the metRology package, I get a much higher number, which is 
actually the seven times the uncertainty of one layer:

require(metRology)
d.set<-list(mass=m,Length=L,Width=W)
d.set.u<-list(m.u,L.u,W.u)

dent<-expression(7*(mass/(Length*Width)))
uncert(obj=dent, x=d.set, u=d.set.u, method="GUM")

I've tried other ways of defining the expression and every method option. 
I suspect the expression is the problem area, but if so, I really need to 
know how to get it right for harder problems. Thanks in advance for any 
suggestions.

- Mark

[[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] How to make a figure plotting p-values by range of different adjustment values?

2017-07-12 Thread Kirsten Morehouse
Hi all,

Thank you for taking the time to read my message. I'm trying to make a
figure that plots p-values by a range of different adjustment values.

(Using the **logit** function in package **car**)

My Statistical analyses were conducted on probability estimates ranging
from 0% to 100%. As it's not ideal to run linear models on percentages that
are bounded between 0 and 1, these estimates were logit transformed.

However, this introduces a researcher degree of freedom. In Package
**Car**, the logit transformation code is

logit(p = doc$value, adjust = 0.025)

logit definition/Description

Compute the logit transformation of proportions or percentages.

Usage

 logit(p, percents=range.p[2] > 1, adjust)

Arguments

p  a numeric vector or array of proportions or percentages.
percents TRUE for percentages.
adjust   adjustment factor to avoid proportions of 0 or 1; defaults to
0 if there are no such proportions in the data, and to .025 if there are.)

I chose the default adjustment factor of .025, but I need to determine at
what point my values are greater than .05 to show I did not choose an
ajustment value that makes my results significant.

Ultimately, I want to find the range of adjustment factors do we get P <
0.05?And at what point do we get P > 0.05?

## The final product I'm looking for is a figure with the following
features:
  ## 1) Adjustment factor on the x-axis
  ## 2) P value on the y-axis

Does anyone know how to do this? Thank you so much in advance.

[[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-es] consulta por varTypes de sqlSave en RODBC

2017-07-12 Thread Javier Marcuzzi
Estimado José Ramirez Costa

Yo tengo un archivo donde guarde lo que realizaba cuándo aprendía, habría que 
ver si actualmente es así o hay cambios, por lo que usted dice creo que usa sql 
server, si no es así busco el archivo para otras bases de datos. Si es 
sqlserver se podría realizar con la ayuda de visual studio, hay una integración 
al respecto.

Le copio y pego la forma que utilicé para aprender, espero que le sea útil.


cn <- odbcDriverConnect(connection="Driver={SQL Server Native Client 11.0};
server=localhost;
database=far;
trusted_connection=yes;")
# DESKTOP-HEO7TLB
cosa <- sqlFetch(cn,'cosa')
cosa

A <- c(1,2,3,4)
B <- c(4,5,6,7)
dat <- data.frame(A,B)
colnames(dat) <- c("A", "B")
sqlSave(cn, dat, tablename = "tblTest", rownames=FALSE, append=TRUE)

cosa <- c("auto", "bici", "libro")
cantidad <- c(2,4,7)
dat <- data.frame(cosa, cantidad)

colnames(dat) <- c("A", "B")
sqlSave(cn, dat, tablename = "cosa",
rownames=FALSE, 
colnames=TRUE, 
append=TRUE,
addPK=TRUE,
fast=TRUE)

# http://stackoverflow.com/questions/36202414/r-download-image-using-rvest
# https://www.r-bloggers.com/parameterized-sql-queries/
# 
https://cran.r-project.org/web/packages/RODBCext/vignettes/Parameterized_SQL_queries.html

library(RODBCext)
filterData <- data.frame('cosa'= c('libros'))
data <- sqlExecute(cn, "SELECT * FROM prueba WHERE cosa = ?", filterData, fetch 
= TRUE)
if(length(data$id) == 0)
{
  print ("no hay elementos")
} else
{
  print ('hay elementos')
}

# generar lo que se inserta o actualiza
id <- 1
cosa <- "casa"
cantidad <- 3
valor <- 4.5
dfDato <- data.frame(id,cosa, cantidad,valor)
colnames(dfDato) <- c("id", "cosa","cantidad","valor")
print(dfDato)
insertar <- function(dfDato) {
  dfNuevoDato <- data.frame(dfDato$cosa, dfDato$cantidad, dfDato$valor)
  colnames(dfNuevoDato) <- c("cosa","cantidad","valor")
  # Parameterized query
   sqlExecute(cn, "INSERT INTO prueba
  (cosa
,cantidad
,valor)
  VALUES (?,?,?)", dfNuevoDato)
  print(dfNuevoDato)
}

# comprobar si existe el id
filterId <- data.frame('id'= dfDato$id)
data <- sqlExecute(cn, "SELECT * FROM prueba WHERE id = ?", filterId, fetch = 
TRUE)
if(length(data$id) == 0)
{
  print ('no existe el id')
  insertar(dfDato)
}else{
  print('Existe el id')
  # buscar la palabra si existe
  filterPalabra <- data.frame('cosa'=dfDato$cosa)
  data <- sqlExecute(cn, "SELECT * FROM prueba WHERE cosa like ?", 
filterPalabra, fetch = TRUE)
  print(data)
if(length(data$cosa) > 0)
{
  print ('existe debo actualizar')
 # query <- "UPDATE cakes SET price = ? WHERE cake = ?"
   query <- "UPDATE prueba
   SET cosa = ?
   ,cantidad = ?
   ,valor = ?
   WHERE id = ?"
   sqlExecute(cn, query, dfDato)
  print(dfDato)
}else{
  print ('puedo insertar')
  insertar(dfDato)
}
  }
#http://finzi.psych.upenn.edu/R/library/RODBC/html/sqlSave.html

Javier Rubén Marcuzzi

De: Jose Ramirez Costa
Enviado: miércoles, 12 de julio de 2017 12:33
Para: r-help-es
Asunto: [R-es] consulta por varTypes de sqlSave en RODBC

Buen dia compañerxs de R, les traigo una pregunta bastante especifica.

En el trabajo me estan requiriendo el uso de SQL, asi q estoy aprendiendo a
usarlo desde R, con el paquete RODBC.

Mi problema puntual es que al crear una tabla en el servidor SQL a partir
de un data frame en R (usando la funcion sqlSave) no puedo definir el tipo
de variables que quiero usar en el data frame.

Segun entiendo esto se deberia poder hacer con el parametro vartypes, pero
hasta ahora solo he podido cargar un vector q dice el tipo de variables
(varchar, int, o numeric) pero no he podido indicarle el ancho q tiene cad
variable.

Esto en SQL se escribiria algo asi:
[ACTA] int,
[APENAC] varchar(25),
[PESONAC] numeric(4,0),

Alguien uso vartypes de esta forma?

Desde ya gracias por el tiempo y un abrazo a todxs.

-- 
"*“Que tudo pesado se torne leve, todo corpo, dançarino, e todo espírito,
pássaro.” *
*Nietzsche, "Assim Falou Zaratustra”.*

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-12 Thread Robert McGehee
Hi Paul,
Sounds like you have your answer, but for fun I thought I'd try solving your 
problem using only a regular expression query and base R. I believe this works:
 
> txt <- "Patient had stage IV breast cancer. Nothing matches this sentence. 
> Metastatic and breast match this sentence. French bike champion takes stage 
> IV victory in Tour de France."

> pattern <- "([^.?!]*(?=[^.?!]*\\bbreast\\b)(?=[^.?!]*\\b(metastatic|stage 
> IV)\\b)(?=[\\s.?!])[^.?!]*[.?!])"

> regmatches(txt, gregexpr(pattern, txt, perl=TRUE, ignore.case=TRUE))[[1]]
[1] "Patient had stage IV breast cancer."
[2] " Metastatic and breast match this sentence."

Cheers, Robert

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul Miller via 
R-help
Sent: Wednesday, July 12, 2017 8:49 AM
To: Bert Gunter 
Cc: R-help 
Subject: Re: [R] Extracting sentences with combinations of target words/terms 
from cancer patient text medical records

Hi Bert,

Thanks for your reply. It appears that I didn't replace the variable name 
"sampletxt" with the argument "x" in my function. I've corrected that and now 
my code seems to be working fine.

Paul


From: Bert Gunter 

Cc: R-help 
Sent: Tuesday, July 11, 2017 2:00 PM
Subject: Re: [R] Extracting sentences with combinations of target words/terms 
from cancer patient text medical records



Have you looked at the CRAN Natural Language Processing Task View? If not, why 
not? If so, why were the resources described there inadequate?

Bert


On Jul 11, 2017 10:49 AM, "Paul Miller via R-help"  wrote:

Hello All,
>
>I need some help figuring out how to extract combinations of target 
>words/terms from cancer patient text medical records. I've provided some 
>sample data and code below to illustrate what I'm trying to do. At the moment, 
>I'm trying to extract sentences that contain the word "breast" plus either 
>"metastatic" or "stage IV".
>
>It's been some time since I used R and I feel a bit rusty. I wrote a function 
>called "sentence_match" that seemed to work well when applied to a single 
>piece of text. You can see that by running the section titled
>
>"Working code". I thought that it might be possible easily to apply my 
>function to a data set (tibble or df) but that doesn't seem to be the case. My 
>unsuccessful attempt to do this appears in the section titled "Non-working 
>code".
>
>If someone could help me get my code up and running, that would be greatly 
>appreciated. I'm using a lot of functions from Hadley Wickham's packages, but 
>that's not particularly necessary. Although I have only a few entries in my 
>sample data, my actual data are pretty large. Currently, I'm working with over 
>a million records. Some records contain only a single sentence, but many have 
>several paragraphs. One concern I had was that, even if I could get my code 
>working, it would be too inefficient to handle that volume of data.
>
>Thanks,
>
>Paul
>
>
>library(tidyverse)
>library(stringr)
>library(lubridate)
>
>sentence_match <- function(x){
>  sentence_extract <- str_extract_all(sampletxt, boundary("sentence"), 
> simplify = TRUE)
>  sentence_number <- intersect(str_which(sentence_ extract, "breast"), 
> str_which(sentence_extract, "metastatic|stage IV"))
>  sentence_match <- str_c(sentence_number, ": ", sentence_extract[sentence_ 
> number], collapse = "")
>  sentence_match
>}
>
> Working code 
>
>sampletxt <- "This sentence contains the word metastatic and the word breast. 
>This sentence contains no target words."
>
>sentence_match(sampletxt)
>
> Non-working code 
>
>sampletxt <-
>  structure(
>list(
>  PTNO = c(1, 2, 2, 2),
>  DATE = structure(c(16436, 16436, 16832, 16845), class = "Date"),
>  TYPE = c("Progress note", "CAT scan", "Progress note", "Progress note"),
>  TVAR = c(
>"This sentence contains the word metastatic. This sentence contains 
> the term stage IV.",
>"This sentence contains no target words. This sentence also contains 
> no target words.",
>"This sentence contains the word metastatic and the word breast. This 
> sentence contains no target words.",
>"This sentence contains the words breast and the term metastatic. This
>sentence contains the word breast and the term stage IV."
>  )
>),
>.Names = c("PTNO", "DATE", "TYPE", "TVAR"),
>class = c("tbl_df",
>  "tbl", "data.frame"),
>row.names = c(NA,-4L)
>  )
>
>sampletxt2 <- group_by_at(sampletxt, vars(PTNO, DATE, TYPE))
>sampletxt2 <-
>  sampletxt2 %>%
>  mutate(
>EXTRACTED = sentence_match(TVAR)
>  )
>
>__ 
>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

[R-es] consulta por varTypes de sqlSave en RODBC

2017-07-12 Thread Jose Ramirez Costa
Buen dia compañerxs de R, les traigo una pregunta bastante especifica.

En el trabajo me estan requiriendo el uso de SQL, asi q estoy aprendiendo a
usarlo desde R, con el paquete RODBC.

Mi problema puntual es que al crear una tabla en el servidor SQL a partir
de un data frame en R (usando la funcion sqlSave) no puedo definir el tipo
de variables que quiero usar en el data frame.

Segun entiendo esto se deberia poder hacer con el parametro vartypes, pero
hasta ahora solo he podido cargar un vector q dice el tipo de variables
(varchar, int, o numeric) pero no he podido indicarle el ancho q tiene cad
variable.

Esto en SQL se escribiria algo asi:
[ACTA] int,
[APENAC] varchar(25),
[PESONAC] numeric(4,0),

Alguien uso vartypes de esta forma?

Desde ya gracias por el tiempo y un abrazo a todxs.

-- 
"*“Que tudo pesado se torne leve, todo corpo, dançarino, e todo espírito,
pássaro.” *
*Nietzsche, "Assim Falou Zaratustra”.*

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread John Kane via R-help
What is cbplatte? Where do we find it?



On Wednesday, July 12, 2017, 6:20:38 AM EDT, Shanu Singh 
 wrote:

Please solve the problem. on which R Version works cbplatte?


Regards
Shanu

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-12 Thread Paul Miller via R-help
Hi Bert,

Thanks for your reply. It appears that I didn't replace the variable name 
"sampletxt" with the argument "x" in my function. I've corrected that and now 
my code seems to be working fine.

Paul


From: Bert Gunter 

Cc: R-help 
Sent: Tuesday, July 11, 2017 2:00 PM
Subject: Re: [R] Extracting sentences with combinations of target words/terms 
from cancer patient text medical records



Have you looked at the CRAN Natural Language Processing Task View? If not, why 
not? If so, why were the resources described there inadequate?

Bert


On Jul 11, 2017 10:49 AM, "Paul Miller via R-help"  wrote:

Hello All,
>
>I need some help figuring out how to extract combinations of target 
>words/terms from cancer patient text medical records. I've provided some 
>sample data and code below to illustrate what I'm trying to do. At the moment, 
>I'm trying to extract sentences that contain the word "breast" plus either 
>"metastatic" or "stage IV".
>
>It's been some time since I used R and I feel a bit rusty. I wrote a function 
>called "sentence_match" that seemed to work well when applied to a single 
>piece of text. You can see that by running the section titled
>
>"Working code". I thought that it might be possible easily to apply my 
>function to a data set (tibble or df) but that doesn't seem to be the case. My 
>unsuccessful attempt to do this appears in the section titled "Non-working 
>code".
>
>If someone could help me get my code up and running, that would be greatly 
>appreciated. I'm using a lot of functions from Hadley Wickham's packages, but 
>that's not particularly necessary. Although I have only a few entries in my 
>sample data, my actual data are pretty large. Currently, I'm working with over 
>a million records. Some records contain only a single sentence, but many have 
>several paragraphs. One concern I had was that, even if I could get my code 
>working, it would be too inefficient to handle that volume of data.
>
>Thanks,
>
>Paul
>
>
>library(tidyverse)
>library(stringr)
>library(lubridate)
>
>sentence_match <- function(x){
>  sentence_extract <- str_extract_all(sampletxt, boundary("sentence"), 
> simplify = TRUE)
>  sentence_number <- intersect(str_which(sentence_ extract, "breast"), 
> str_which(sentence_extract, "metastatic|stage IV"))
>  sentence_match <- str_c(sentence_number, ": ", sentence_extract[sentence_ 
> number], collapse = "")
>  sentence_match
>}
>
> Working code 
>
>sampletxt <- "This sentence contains the word metastatic and the word breast. 
>This sentence contains no target words."
>
>sentence_match(sampletxt)
>
> Non-working code 
>
>sampletxt <-
>  structure(
>list(
>  PTNO = c(1, 2, 2, 2),
>  DATE = structure(c(16436, 16436, 16832, 16845), class = "Date"),
>  TYPE = c("Progress note", "CAT scan", "Progress note", "Progress note"),
>  TVAR = c(
>"This sentence contains the word metastatic. This sentence contains 
> the term stage IV.",
>"This sentence contains no target words. This sentence also contains 
> no target words.",
>"This sentence contains the word metastatic and the word breast. This 
> sentence contains no target words.",
>"This sentence contains the words breast and the term metastatic. This
>sentence contains the word breast and the term stage IV."
>  )
>),
>.Names = c("PTNO", "DATE", "TYPE", "TVAR"),
>class = c("tbl_df",
>  "tbl", "data.frame"),
>row.names = c(NA,-4L)
>  )
>
>sampletxt2 <- group_by_at(sampletxt, vars(PTNO, DATE, TYPE))
>sampletxt2 <-
>  sampletxt2 %>%
>  mutate(
>EXTRACTED = sentence_match(TVAR)
>  )
>
>__ 
>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] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Rui Barradas

Hello,

Google is your friend.
The only reference to cbPalette I've found is in

http://www.cookbook-r.com/Graphs/Colors_%28ggplot2%29/

and it is defined as:

A colorblind-friendly palette

These are color-blind-friendly palettes, one with gray, and one with black.

To use with ggplot2, it is possible to store the palette in a variable, 
then use it later.


# The palette with grey:
cbPalette <- c("#99", "#E69F00", "#56B4E9", "#009E73", "#F0E442", 
"#0072B2", "#D55E00", "#CC79A7")


# The palette with black:
cbbPalette <- c("#00", "#E69F00", "#56B4E9", "#009E73", "#F0E442", 
"#0072B2", "#D55E00", "#CC79A7")



The above is a copy and paste from that web page.

Hope this helps,

Rui Barradas


Em 12-07-2017 11:38, Uwe Ligges escreveu:



On 12.07.2017 12:35, Shanu Singh wrote:

Hi John,

Thanks for reply ! Sorry It was my mistake. It is *cbPalette. *Basically
its a R package.


Come on.
- Where do you want to get thsi from?
- What have you tried to do so?

Please re-read the posting guide that helps to ask good questions.

Best,
Uwe Ligges






Shanu

On Wed, Jul 12, 2017 at 3:57 PM, John Kane  wrote:


What is cbplatte? Where do we find it?



On Wednesday, July 12, 2017, 6:20:38 AM EDT, Shanu Singh <
singh.shanu1...@gmail.com> wrote:


Please solve the problem. on which R Version works cbplatte?


Regards
Shanu

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
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] Importing Big data to R

2017-07-12 Thread Peter Dalgaard

> On 12 Jul 2017, at 08:44 , Mangalani Peter Makananisa 
>  wrote:
> 
> Dear R-Gurus,
> 
> I am trying to read in data with 24,349,113 rows to R-3.3.3 (64 bit) and have 
> used  the library   "data.table"  and It managed to read 23,347,070 rows  and 
> the remainder was 2,043 rows only.

I make that 1002043 rows... (typo?). One possibility is that you are skipping 
lines because of something like quote characters in data or some input lines 
being one field short. You might also simply be running out of memory.

However,

1) data.table is a contributed package. Its maintainer may be a better point of 
contact.

2) if you hope to get advice from the R community at large, it would be useful 
to tell us what you did, what kind of data you try to read using which command, 
etc. And, as Jim Holtman already said: error messages, if any. 

-pd

> 
> Could you please advise me as to which library/R-commands is suitable to read 
> the full data in to R?
> 
> Kind regards,
> 
> Mangalani Peter Makananisa (5786)
> South African Revenue Service (SARS)
> +2782 456 4669 / +2712 422 7357
> 
> Please Note: This email and its contents are subject to our email legal 
> notice which can be viewed at 
> http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> 
>   [[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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Importing Big data to R

2017-07-12 Thread jim holtman
A little more information would be useful.  Why did it stop? Was there an
error message?  Can you show the commands/console log of what you did.
Provide information on how much memory your computer has on it.  When the
operation completed, how much memory was used.  An important aspect is how
many columns did the data have.  How big was the file on disk.  What other
objects were in memory at the same time.  The list can go on and on, so
more information would be useful to understand the problem.


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Wed, Jul 12, 2017 at 2:44 AM, Mangalani Peter Makananisa <
pmakanan...@sars.gov.za> wrote:

> Dear R-Gurus,
>
> I am trying to read in data with 24,349,113 rows to R-3.3.3 (64 bit) and
> have used  the library   "data.table"  and It managed to read 23,347,070
> rows  and the remainder was 2,043 rows only.
>
> Could you please advise me as to which library/R-commands is suitable to
> read the full data in to R?
>
> Kind regards,
>
> Mangalani Peter Makananisa (5786)
> South African Revenue Service (SARS)
> +2782 456 4669 / +2712 422 7357
>
> Please Note: This email and its contents are subject to our email legal
> notice which can be viewed at http://www.sars.gov.za/Pages/
> Email-disclaimer.aspx
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Uwe Ligges



On 12.07.2017 12:35, Shanu Singh wrote:

Hi John,

Thanks for reply ! Sorry It was my mistake. It is *cbPalette. *Basically
its a R package.


Come on.
- Where do you want to get thsi from?
- What have you tried to do so?

Please re-read the posting guide that helps to ask good questions.

Best,
Uwe Ligges






Shanu

On Wed, Jul 12, 2017 at 3:57 PM, John Kane  wrote:


What is cbplatte? Where do we find it?



On Wednesday, July 12, 2017, 6:20:38 AM EDT, Shanu Singh <
singh.shanu1...@gmail.com> wrote:


Please solve the problem. on which R Version works cbplatte?


Regards
Shanu

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
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] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Shanu Singh
Thanks for reply! sorry my my mistake It is *cbPalette*


*Shanu*

On Wed, Jul 12, 2017 at 4:04 PM, Uwe Ligges  wrote:

>
>
> On 12.07.2017 12:03, Shanu Singh wrote:
>
>> Please solve the problem. on which R Version works cbplatte?
>>
>
> What is cbPlatte  or cbplatte (case matters).
>
> Best,
> Uwe Ligges
>
>
>>
>> Regards
>> Shanu
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Shanu Singh
Hi John,

Thanks for reply ! Sorry It was my mistake. It is *cbPalette. *Basically
its a R package.


Shanu

On Wed, Jul 12, 2017 at 3:57 PM, John Kane  wrote:

> What is cbplatte? Where do we find it?
>
>
>
> On Wednesday, July 12, 2017, 6:20:38 AM EDT, Shanu Singh <
> singh.shanu1...@gmail.com> wrote:
>
>
> Please solve the problem. on which R Version works cbplatte?
>
>
> Regards
> Shanu
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Uwe Ligges



On 12.07.2017 12:03, Shanu Singh wrote:

Please solve the problem. on which R Version works cbplatte?


What is cbPlatte  or cbplatte (case matters).

Best,
Uwe Ligges




Regards
Shanu

[[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] devtools::check "hangs"

2017-07-12 Thread Uwe Ligges



On 12.07.2017 10:31, Sigbert Klinke wrote:

Hi,

checking my package with check from devtools leads to the output

Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking examples ...


Take a look in the example log files in the corresponding check dir.

Best,
Uwe Ligges






and that is the last thing I get. Since I write shiny apps, it may 
happen that somewhere an example expects some input/interactivity and is 
not in \dontrun environment. How I can see which example currently is 
checked?


Thanks in advance

Sigbert



__
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 for installing cbPlatte on R Version 3.4.1

2017-07-12 Thread Shanu Singh
Please solve the problem. on which R Version works cbplatte?


Regards
Shanu

[[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] How to formulate quadratic function with interaction terms for the PLS fitting model?

2017-07-12 Thread Ng, Kelvin Sai-cheong
Dear all,

I am using the pls package of R to perform partial least square on a set of
multivariate data.  Instead of fitting a linear model, I want to fit my
data with a quadratic function with interaction terms.  But I am not sure
how.  I will use an example to illustrate my problem:

Following the example in the PLS manual:
## Read data
 data(gasoline)
gasTrain <- gasoline[1:50,]
## Perform PLS
gas1 <- plsr(octane ~ NIR, ncomp = 10, data = gasTrain, validation = "LOO")

where octane ~ NIR is the model that this example is fitting with.

NIR is a collective of variables, i.e. NIR spectra consists of 401 diffuse
reflectance measurements from 900 to 1700 nm.

Instead of fitting with octane[i] = a[0] * NIR[0,i] + a[1] * NIR[1,i] + ...
I want to fit the data with:
octane[i] = a[0] * NIR[0,i] + a[1] * NIR[1,i] + ... +
b[0]*NIR[0,i]*NIR[0,i] + b[1] * NIR[0,i]*NIR[1,i] + ...

i.e. quadratic with interaction terms.

But I don't know how to formulate this.

May I have some help please?

Thanks,

Kelvin

[[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] Importing Big data to R

2017-07-12 Thread Mangalani Peter Makananisa
Dear R-Gurus,

I am trying to read in data with 24,349,113 rows to R-3.3.3 (64 bit) and have 
used  the library   "data.table"  and It managed to read 23,347,070 rows  and 
the remainder was 2,043 rows only.

Could you please advise me as to which library/R-commands is suitable to read 
the full data in to R?

Kind regards,

Mangalani Peter Makananisa (5786)
South African Revenue Service (SARS)
+2782 456 4669 / +2712 422 7357

Please Note: This email and its contents are subject to our email legal notice 
which can be viewed at http://www.sars.gov.za/Pages/Email-disclaimer.aspx

[[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] devtools::check "hangs"

2017-07-12 Thread Sigbert Klinke

Hi,

checking my package with check from devtools leads to the output

Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking examples ...

and that is the last thing I get. Since I write shiny apps, it may 
happen that somewhere an example expects some input/interactivity and is 
not in \dontrun environment. How I can see which example currently is 
checked?


Thanks in advance

Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] submitting R scripts with command_line_arguments to PBS HPC clusters

2017-07-12 Thread Bogdan Tanasa
Dear Peter, that is very very helpful, many thanks for your suggestions ;) !

On Tue, Jul 11, 2017 at 11:34 PM, Anthoni, Peter (IMK) <
peter.anth...@kit.edu> wrote:

> Hi,
>
> The problem is most likely, you need to call a R CMD BATCH with your
> arguments and the R-script inside of a shell script that you submit to your
> qsub.
> Unfortunately we don't use qsub anymore so can't test it, but it should be
> as follows:
>
> R-script eg. test.R:
> > ##First read in the arguments listed at the command line
> > args=(commandArgs(TRUE))
> >
> > ##args is now a list of character vectors
> > ## First check to see if arguments are passed.
> > if(length(args)==0){
> >   stop("no args specified")
> > }
> > ## Then cycle through each element of the list and evaluate the
> expressions.
> > for(i in 1:length(args)){
> >   print(args[[i]])
> >   eval(parse(text=args[[i]]))
> > }
> > print(TUMOR)
> > print(GERMLINE)
> > print(CHR)
>
>
> qsub shell script test.sh:
> > #!/bin/bash
> >
> > #Note: the single quote '...' around the --args ... "..." "..." is
> important!
> > R CMD BATCH --no-save --no-restore '--args TUMOR="tumor.bam"
> GERMLINE="germline.bam" CHR="chr22"' test.R test.Rout
>
> then you submit with a qsub with all the options you specified the test.sh
> qsub  test.sh
>
> cheers
> Peter
>
>
>
> > On 12. Jul 2017, at 03:01, Jeff Newmiller 
> wrote:
> >
> > This sounds like an operating system specific question, in that "submit
> the R script to a PBS HPC scheduler" would be the kind of action that would
> run R with very different environment variables and possibly different
> access credentials than your usual interactive terminal.  A thorough
> reading of the "Installation and Administration Guide" and some study of
> your HPC documentation are in order.
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> > On July 11, 2017 5:25:20 PM PDT, Bogdan Tanasa  wrote:
> >> Dear all,
> >>
> >> please could you advise me on the following : I've written a R script
> >> that
> >> reads 3 arguments from the command line, i.e. :
> >>
> >> " args <- commandArgs(TRUE)
> >> TUMOR <- args[1]
> >> GERMLINE <- args[2]
> >> CHR <- args[3] ".
> >>
> >> when I submit the R script to a PBS HPC scheduler, I do the following
> >> (below), but ... I am getting an error message.
> >> (I am not posting the error message, because the R script I wrote works
> >> fine when it is run from a regular terminal ..)
> >>
> >> Please may I ask, how do you usually submit the R scripts with command
> >> line
> >> arguments to PBS HPC schedulers ?
> >>
> >> qsub -d $PWD -l nodes=1:ppn=4 -l vmem=10gb -m bea -M tan...@gmail.com \
> >> -v TUMOR="tumor.bam",GERMLINE="germline.bam",CHR="chr22" \
> >> -e script.efile.chr22 \
> >> -o script.ofile.chr22 \
> >> script.R
> >>
> >> Thank you very very much  !
> >>
> >> -- bogdan
> >>
> >>  [[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.
>
>

[[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] submitting R scripts with command_line_arguments to PBS HPC clusters

2017-07-12 Thread Anthoni, Peter (IMK)
Hi,

The problem is most likely, you need to call a R CMD BATCH with your arguments 
and the R-script inside of a shell script that you submit to your qsub.
Unfortunately we don't use qsub anymore so can't test it, but it should be as 
follows:

R-script eg. test.R:
> ##First read in the arguments listed at the command line
> args=(commandArgs(TRUE))
> 
> ##args is now a list of character vectors
> ## First check to see if arguments are passed.
> if(length(args)==0){
>   stop("no args specified")
> }
> ## Then cycle through each element of the list and evaluate the expressions.
> for(i in 1:length(args)){
>   print(args[[i]])
>   eval(parse(text=args[[i]]))
> }
> print(TUMOR)
> print(GERMLINE)
> print(CHR)


qsub shell script test.sh:  
> #!/bin/bash
> 
> #Note: the single quote '...' around the --args ... "..." "..." is important!
> R CMD BATCH --no-save --no-restore '--args TUMOR="tumor.bam" 
> GERMLINE="germline.bam" CHR="chr22"' test.R test.Rout

then you submit with a qsub with all the options you specified the test.sh
qsub  test.sh

cheers
Peter



> On 12. Jul 2017, at 03:01, Jeff Newmiller  wrote:
> 
> This sounds like an operating system specific question, in that "submit the R 
> script to a PBS HPC scheduler" would be the kind of action that would run R 
> with very different environment variables and possibly different access 
> credentials than your usual interactive terminal.  A thorough reading of the 
> "Installation and Administration Guide" and some study of your HPC 
> documentation are in order. 
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On July 11, 2017 5:25:20 PM PDT, Bogdan Tanasa  wrote:
>> Dear all,
>> 
>> please could you advise me on the following : I've written a R script
>> that
>> reads 3 arguments from the command line, i.e. :
>> 
>> " args <- commandArgs(TRUE)
>> TUMOR <- args[1]
>> GERMLINE <- args[2]
>> CHR <- args[3] ".
>> 
>> when I submit the R script to a PBS HPC scheduler, I do the following
>> (below), but ... I am getting an error message.
>> (I am not posting the error message, because the R script I wrote works
>> fine when it is run from a regular terminal ..)
>> 
>> Please may I ask, how do you usually submit the R scripts with command
>> line
>> arguments to PBS HPC schedulers ?
>> 
>> qsub -d $PWD -l nodes=1:ppn=4 -l vmem=10gb -m bea -M tan...@gmail.com \
>> -v TUMOR="tumor.bam",GERMLINE="germline.bam",CHR="chr22" \
>> -e script.efile.chr22 \
>> -o script.ofile.chr22 \
>> script.R
>> 
>> Thank you very very much  !
>> 
>> -- bogdan
>> 
>>  [[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-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.