Re: [R] not common records

2016-06-02 Thread Jeff Newmiller
?merge

Pay attention to the all-whatever parameters. 
-- 
Sent from my phone. Please excuse my brevity.

On June 2, 2016 7:04:47 PM PDT, Ashta  wrote:
>I have 2 data sets.  File1 and File2. Some records are common to both
>data sets. For those common records I want get the difference between
>d_x1z1= z1-x1   and d_x2z2= z2-x2.
>
>File1<- data.frame(var = c(561,752,800,900),  x1= c(23,35,40,15), x2=
>c(125,284,280,347))
>File2<- data.frame(var = c(561,752,800,1001), z1= c(43,45,40,65), z2=
>c(185,299,280,310))
>
>Record  900  15347   appears only in File1
>Record   100165310  appears only in File2
>
>File3 should look like as follows
>
>File3
>var  x1 x2 z1z2d_x1z1   d_x2z2
>561  23125  43165 20 40
>752  35284  45299  8  15
>800  40280  40280  0   0
>900  15347  NA   NA  NA   NA
>1001 NA  NA   65310 NA  NA
>
>How do I get those record not common in both data sets ?
>merge( File1,File2) gave me only for common "var"
>
>__
>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] not common records

2016-06-02 Thread Ashta
I have 2 data sets.  File1 and File2. Some records are common to both
data sets. For those common records I want get the difference between
d_x1z1= z1-x1   and d_x2z2= z2-x2.

File1<- data.frame(var = c(561,752,800,900),  x1= c(23,35,40,15), x2=
c(125,284,280,347))
File2<- data.frame(var = c(561,752,800,1001), z1= c(43,45,40,65), z2=
c(185,299,280,310))

Record  900  15347   appears only in File1
Record   100165310  appears only in File2

File3 should look like as follows

File3
var  x1 x2 z1z2d_x1z1   d_x2z2
561  23125  43165 20 40
752  35284  45299  8  15
800  40280  40280  0   0
900  15347  NA   NA  NA   NA
1001 NA  NA   65310 NA  NA

How do I get those record not common in both data sets ?
merge( File1,File2) gave me only for common "var"

__
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] bnlearn cpquery

2016-06-02 Thread ross.chapman
Hi all

 

I have created a Bayes network with 14 nodes  using the bnlearn package and
want to explore the conditional probabilities for specific node with a given
set of evidence using the cpquery() command.

 

I find that repeating the command gives very different results for the same
set of evidence.

 

Below are four examples of the same query that gives three very different
outputs.

 

> cpquery(expNetFitted, event=(out>=24), evidence=(RN>2900 & EST=="K1" &
SMG=="C" & BN>1000 & FRT>460 & HI>13 >450 & FRT.2>450 & RN.1 > 2500 &
RN.2 > 2400 &  HI.1>13 &  HI.2>13 & FFB.1 >19 & FFB.2 >20 ))

[1] 0.6

> cpquery(expNetFitted, event=(out>=24), evidence=(RN>2900 & EST=="K1" &
SMG=="C" & BN>1000 & FRT>460 & HI>13 >450 & FRT.2>450 & RN.1 > 2500 &
RN.2 > 2400 &  HI.1>13 &  HI.2>13 & FFB.1 >19 & FFB.2 >20 ))

[1] 0.1428571

> cpquery(expNetFitted, event=(out>=24), evidence=(RN>2900 & EST=="K1" &
SMG=="C" & BN>1000 & FRT>460 & HI>13 >450 & FRT.2>450 & RN.1 > 2500 &
RN.2 > 2400 &  HI.1>13 &  HI.2>13 & FFB.1 >19 & FFB.2 >20 ))

[1] 0.4285714

> cpquery(expNetFitted, event=(out>=24), evidence=(RN>2900 & EST=="K1" &
SMG=="C" & BN>1000 & FRT>460 & HI>13 >450 & FRT.2>450 & RN.1 > 2500 &
RN.2 > 2400 &  HI.1>13 &  HI.2>13 & FFB.1 >19 & FFB.2 >20 ))

[1] 0.167

Can you please advise me what is happening with these queries and why the
results is so variable and if there are other options for generating
conditional probabilities with bnlearn.

 

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.


Re: [R] problems compiling packages | 3.3.0 | Linux

2016-06-02 Thread Marc Schwartz
On Jun 2, 2016, at 10:35 AM, Evan Cooch  wrote:
> 
> Updated my R install on my GNU/Linux boxes (running RHEL 6.xx), using latest 
> from CRAN (i.e., not compiling from source), and while said upgrade seemed to 
> go fine, am having all sorts of problems with getting some packages to 
> compile (either during an initial install attempt, or upgrade to existing 
> packages).


Just for clarification, if you were NOT installing from source, you were NOT 
installing from CRAN. Precompiled RH RPM binaries of R have not been available 
from CRAN for quite some time.

Presumably you used 'yum' and were installing via the EPEL using their 
precompiled binary RPMs? Those would be configured for your specific RHEL 
distribution to have dependencies that are compatible.

The RPMS there would include both "base" R and the additional "recommended" 
packages, which are part of the default R distribution and includes nlme.

More below.

> 
> For example, if I try to update nlme, I get the following errors, which are 
> pretty well fatal:
> 
> gcc: error: /builddir/build/BUILD/R-3.3.0/zlib-1.2.8/target/usr/lib64/libz.a: 
> No such file or directory
> gcc: error: 
> /builddir/build/BUILD/R-3.3.0/bzip2-1.0.6/target/usr/lib64/libbz2.a: No such 
> file or directory
> gcc: error: 
> /builddir/build/BUILD/R-3.3.0/xz-5.2.2/target/usr/lib64/liblzma.a: No such 
> file or directory
> gcc: error: 
> /builddir/build/BUILD/R-3.3.0/pcre-8.38/target/usr/lib64/libpcre.a: No such 
> file or directory
> gcc: error: 
> /builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64/libcurl.a: No such 
> file or directory
> 
> 
> I think the clue is the version of the libs the installer seems to be looking 
> for. For example, zlib-1.2.8. RHEL only supports zlib-1.2.3-29 (RHEL, like 
> most 'enterprise distros', is typically 1 step back from 'bleeding edge').
> 
> Any way I can force R CMD (or some such) to use system libs, instead of 
> looking for specific, newer versions? Or, any other suggestions?
> 
> Serious pain in the butt. R 3.2.5 was working perfectly -- upgrade pretty 
> much gummed things up, as far as compiling some packages.
> 
> Thanks in advance.
> 
> p.s. wasn't sure if this should go to r-help, or r-packages.


Neither one.

You should be posting to R-SIG-Fedora:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

Please re-post there as both RH/Fedora users and the RH RPM maintainers read 
that list, should there be issues with the EPEL RPMs relative to dependencies.

Regards,

Marc Schwartz

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


[R] problems compiling packages | 3.3.0 | Linux

2016-06-02 Thread Evan Cooch
Updated my R install on my GNU/Linux boxes (running RHEL 6.xx), using 
latest from CRAN (i.e., not compiling from source), and while said 
upgrade seemed to go fine, am having all sorts of problems with getting 
some packages to compile (either during an initial install attempt, or 
upgrade to existing packages).


For example, if I try to update nlme, I get the following errors, which 
are pretty well fatal:


gcc: error: 
/builddir/build/BUILD/R-3.3.0/zlib-1.2.8/target/usr/lib64/libz.a: No 
such file or directory
gcc: error: 
/builddir/build/BUILD/R-3.3.0/bzip2-1.0.6/target/usr/lib64/libbz2.a: No 
such file or directory
gcc: error: 
/builddir/build/BUILD/R-3.3.0/xz-5.2.2/target/usr/lib64/liblzma.a: No 
such file or directory
gcc: error: 
/builddir/build/BUILD/R-3.3.0/pcre-8.38/target/usr/lib64/libpcre.a: No 
such file or directory
gcc: error: 
/builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64/libcurl.a: No 
such file or directory



I think the clue is the version of the libs the installer seems to be 
looking for. For example, zlib-1.2.8. RHEL only supports zlib-1.2.3-29 
(RHEL, like most 'enterprise distros', is typically 1 step back from 
'bleeding edge').


Any way I can force R CMD (or some such) to use system libs, instead of 
looking for specific, newer versions? Or, any other suggestions?


Serious pain in the butt. R 3.2.5 was working perfectly -- upgrade 
pretty much gummed things up, as far as compiling some packages.


Thanks in advance.

p.s. wasn't sure if this should go to r-help, or r-packages.

__
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] R integration with Hive with Kerberos enabled

2016-06-02 Thread Arti Wadhwani
Hi,

I have a question regarding R integration with Hive in kerberized mode. Is it 
supported? It works fine without kerberos however fails with below error in a 
kerberized cluster:

java.lang.RuntimeException: org.apache.thrift.transport.TTransportException: 
Peer indicated failure: GSS initiate failed

Further debugging reveals : The R script uses common packages(rjdbc, rjava) 
which are not specific to any Hadoop distribution. We need to understand why R 
script does not read the ticket cache at run time.


Thanks,
Arti Wadhwani
Hortonworks, Inc.
Technical Support Engineer (India)



[[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] Need help getting plotly to run on R

2016-06-02 Thread KMNanus
I signed up with plotly on their own site - https://plot.ly/  
- and got a username and password.

When I installed the package in R, I got the following error msg - 
"Storing 'username' as the environment variable 'plotly_username'
Error in Sys.setenv(plotly_username = username) : 
  wrong length for argument”

So I called signup("knanus", "kmna...@gmail.com”) and received :
Error: Aw, snap! Either you've already signed-up with this username or this 
username has been taken. If you think you've already signed up, you can view 
your API key at https://plot.ly/api/key and sign in:
>>> p <- plotly(username="knanus", key=api_key)

I called p<- plolty exactly as instructed above (I did not enter the api_key on 
this email for confidentiality) and received
Storing 'username' as the environment variable 'plotly_username'
Storing 'key' as the environment variable 'plotly_api_key'
Error in Sys.setenv(plotly_api_key = key) : object ‘XX' not found

So I detached and deleted plotly from my library and tried - 

install.packages("devtools")
library(devtools)

I received the “DONE” response, but when I called library(plotly) I received 
the same “Storing ‘username…” error msg as before.

What am I doing wrong?


Ken
kmna...@gmail.com
914-450-0816 (tel)
347-730-4813 (fax)



__
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] reading data into nested frames

2016-06-02 Thread Ulrik Stervbo
Hi Ed,

I'm not sure I understand, but can't you rwad the files one by one and
create one data.frane using rbind?

Is easy to put do in a loop too.

Best wishes,

Ulrik

On Thu, 2 Jun 2016, 20:23 Ed Siefker,  wrote:

> I have many data files named like this:
>
> E11.5-021415-dko-1-1-masked-bottom-area.tsv
> E11.5-021415-dko-1-1-masked-top-area.tsv
> E11.5-021415-dko-1-2-masked-bottom-area.tsv
> E11.5-021415-dko-1-2-masked-top-area.tsv
> E11.5-021415-dko-1-3-masked-bottom-area.tsv
> E11.5-021415-dko-1-3-masked-top-area.tsv
>
> age-date-genotype-num-slicenum-filler-position-data
>
> An individual sample is an age-date-geno-num, each sample has two
> parts, and is composed of around 10 slices.  Each row of the tsv is an
> area which will be summed for the total area.
>
> What I want is a dataframe, with a row for each sample and a column
> for bottom and top.  Under bottom and top, I want each element to be a
> dataframe with a row for each slice and a column for the area.
>
> So I can lapply over this list of files, use strsplit to pull out the
> slice num and put the area into the correct row of a dataframe easily
> enough.  But I have a line for every datapoint, not sample, and there
> would be a dataframe for each area.
>
> How can I merge all the data for the slices into one data frame?  Does
> this make sense?
> Thanks
> -Ed
>
> __
> 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] reading data into nested frames

2016-06-02 Thread Ed Siefker
I have many data files named like this:

E11.5-021415-dko-1-1-masked-bottom-area.tsv
E11.5-021415-dko-1-1-masked-top-area.tsv
E11.5-021415-dko-1-2-masked-bottom-area.tsv
E11.5-021415-dko-1-2-masked-top-area.tsv
E11.5-021415-dko-1-3-masked-bottom-area.tsv
E11.5-021415-dko-1-3-masked-top-area.tsv

age-date-genotype-num-slicenum-filler-position-data

An individual sample is an age-date-geno-num, each sample has two
parts, and is composed of around 10 slices.  Each row of the tsv is an
area which will be summed for the total area.

What I want is a dataframe, with a row for each sample and a column
for bottom and top.  Under bottom and top, I want each element to be a
dataframe with a row for each slice and a column for the area.

So I can lapply over this list of files, use strsplit to pull out the
slice num and put the area into the correct row of a dataframe easily
enough.  But I have a line for every datapoint, not sample, and there
would be a dataframe for each area.

How can I merge all the data for the slices into one data frame?  Does
this make sense?
Thanks
-Ed

__
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] Struggling trying to plot points on boxplot

2016-06-02 Thread Thomas Adams
Bill,

Thank you!! With some tweaking, this approach was exactly what I needed.
Previously, I had been using bxp and had my code for it, but my data was
structured completely differently from what I have now. I figured something
like groupedX <- with(d, split(x, group)) existed, but how to find it??
This was the key for me and it's so powerful!

Thanks to all for the suggestions!

Tom

On Thu, Jun 2, 2016 at 10:52 AM, William Dunlap  wrote:

> Does using zz<-bxp(boxplot(data,plot=FALSE)) do what you want?  E.g.,
>
> d <- transform(data.frame(t=1:15), x = sin(t)+log2(t), group =
> paste("Group", t%/%4))
> groupedX <- with(d, split(x, group))
> zz <- bxp(boxplot(groupedX, plot=FALSE)) # bxp returns the x positions of
> the boxes
> points(col="blue", pch=15, zz, vapply(splitX, FUN=mean, FUN.VALUE=0))
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Thu, Jun 2, 2016 at 8:36 AM, Thomas Adams  wrote:
>
>> Hello all:
>>
>> I've been beating my head on this for over a day and I have done a lot of
>> Google'ing with no luck.
>>
>> I have generated a 'time-series' of boxplots (227), covering more than a
>> 30-day period at 6-hour intervals, which summarize an ensemble forecast.
>> What I want to do is over-plot the observed values over a portion of the
>> forecast period to serve as a basis of comparison; so, there would be a
>> boxplot and a single point value plotted at each 6-hour interval.
>>
>> The boxplots are generated:
>>
>> zz<-boxplot(ens$value ~ ens$valid_time,xlab="Date/Time
>> (UTC)",ylab="Flow(cfs)",boxfill="cyan")
>>
>> which works fine, but the observed points will not display using:
>>
>> points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)
>>
>> I've tried many variations of the latter, where either nothing happens and
>> no error is returned or I have also gotten that x and y have different
>> lengths. I suspect I am using the wrong 'x' type. I have observation
>> values
>> beginning with the first in the series of boxplots, which then end, with
>> the most recent ensemble forecast. So, I always expect the number of
>> observed values to be less than the number of boxplots. I have done this
>> previously, years ago, but can not find my notes and can not reconstruct
>> what I did.
>>
>> Help is appreciated.
>>
>> Regards,
>> Tom
>>
>> [[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.
>>
>
>


-- 
Thomas E Adams, III
2330 Jack Warner PKWY, #334
Tuscaloosa, AL 35401

1 (513) 739-9512 (cell)

[[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] Gráficos con apply

2016-06-02 Thread Carlos Ortega
Hola,

En vez de "names(x)", pon "colnames(x)"...

Gracias,
Carlos Ortega
www.qualityexcellence.es

El 2 de junio de 2016, 18:23, Jesús Para Fernández <
j.para.fernan...@hotmail.com> escribió:

> Buenas
>
> Quiero crear 8 histogramas. Hasta ahora los hacia con el bucle for, y
> ahora quiero hacerlos con apply para ver como se haria.
>
> Para ello, tengo un data.frame, llamado datos, con 8 variables, v1,v2
>
> Con el for hacía
>
> par(mfrow=c(4,2))
> for(i in 1:8){
> plot(datos[,i],main=names(datos[i]))
> }
> y obtenia el grafico con el titulo de cada variable.
>
> Al intentar hacer lo mismo con el apply, lo que no consigo es poner el
> titulo de cada variable
>
> apply(datos,2,function(x){c(plot(x,col=8,main=names(x)))})
>
> ¿Alguna idea??
>
> Gracias de nuevo!!!
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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


[R-es] Gráficos con apply

2016-06-02 Thread Jesús Para Fernández
Buenas 

Quiero crear 8 histogramas. Hasta ahora los hacia con el bucle for, y ahora 
quiero hacerlos con apply para ver como se haria. 

Para ello, tengo un data.frame, llamado datos, con 8 variables, v1,v2

Con el for hac�a

par(mfrow=c(4,2))
for(i in 1:8){
plot(datos[,i],main=names(datos[i]))
}
y obtenia el grafico con el titulo de cada variable.

Al intentar hacer lo mismo con el apply, lo que no consigo es poner el titulo 
de cada variable

apply(datos,2,function(x){c(plot(x,col=8,main=names(x)))})

�Alguna idea??

Gracias de nuevo!!!
  
[[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] Trouble getting rms::survplot(..., n.risk=TRUE) to behave properly

2016-06-02 Thread Steve Lianoglou
Ah!

Sorry ... should have dug deeper into the examples section to notice that.

Thank you for the quick reply,
-steve


On Thu, Jun 2, 2016 at 8:59 AM, Frank Harrell  wrote:
> This happens when you have not strat variables in the model.
>
>
> --
> Frank E Harrell Jr  Professor and Chairman  School of Medicine
>
> Department of *Biostatistics*  *Vanderbilt University*
>
> On Thu, Jun 2, 2016 at 10:55 AM, Steve Lianoglou 
> wrote:
>
>> Hello foks,
>>
>> I'm trying to plot the number of patients at-risk by setting the
>> `n.risk` parameter to `TRUE` in the rms::survplot function, however it
>> looks as if the numbers presented in the rows for each category are
>> just summing up the total number of patients at risk in all groups for
>> each timepoint -- which is to say that the numbers are equal in each
>> category down the rows, and they don't seem to be the numbers specific
>> to each group.
>>
>> You can reproduce the observed behavior by simply running the code in
>> the Examples section of ?survplot, which I'll paste below for
>> convenience.
>>
>> Is the error between the chair and the keyboard, here, or is this perhaps
>> a bug?
>>
>> === code ===
>> library(rms)
>> n <- 1000
>> set.seed(731)
>> age <- 50 + 12*rnorm(n)
>> label(age) <- "Age"
>> sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
>> cens <- 15*runif(n)
>> h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
>> dt <- -log(runif(n))/h
>> label(dt) <- 'Follow-up Time'
>> e <- ifelse(dt <= cens,1,0)
>> dt <- pmin(dt, cens)
>> units(dt) <- "Year"
>> dd <- datadist(age, sex)
>> options(datadist='dd')
>> S <- Surv(dt,e)
>>
>> f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
>> survplot(f, sex, n.risk=TRUE)
>> ===
>>
>> I'm using the latest version of rms (4.5-0) running on R 3.3.0-patched.
>>
>> === Output o sessionInfo() ===
>> R version 3.3.0 Patched (2016-05-26 r70671)
>> Platform: x86_64-apple-darwin13.4.0 (64-bit)
>> Running under: OS X 10.11.4 (El Capitan)
>>
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>> other attached packages:
>> [1] rms_4.5-0   SparseM_1.7 Hmisc_3.17-4ggplot2_2.1.0
>> [5] Formula_1.2-1   survival_2.39-4 lattice_0.20-33
>>
>> loaded via a namespace (and not attached):
>>  [1] Rcpp_0.12.5 cluster_2.0.4   MASS_7.3-45
>>  [4] splines_3.3.0   munsell_0.4.3   colorspace_1.2-6
>>  [7] multcomp_1.4-5  plyr_1.8.3  nnet_7.3-12
>> [10] grid_3.3.0  data.table_1.9.6gtable_0.2.0
>> [13] nlme_3.1-128quantreg_5.24   TH.data_1.0-7
>> [16] latticeExtra_0.6-28 MatrixModels_0.4-1  polspline_1.1.12
>> [19] Matrix_1.2-6gridExtra_2.2.1 RColorBrewer_1.1-2
>> [22] codetools_0.2-14acepack_1.3-3.3 rpart_4.1-10
>> [25] sandwich_2.3-4  scales_0.4.0mvtnorm_1.0-5
>> [28] foreign_0.8-66  chron_2.3-47zoo_1.7-13
>> ===
>>
>>
>> Thanks,
>> -steve
>>
>>
>> --
>> Steve Lianoglou
>> Computational Biologist
>> Genentech
>>
>
> [[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.



-- 
Steve Lianoglou
Computational Biologist
Genentech

__
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] Trouble getting rms::survplot(..., n.risk=TRUE) to behave properly

2016-06-02 Thread Frank Harrell
This happens when you have not strat variables in the model.


--
Frank E Harrell Jr  Professor and Chairman  School of Medicine

Department of *Biostatistics*  *Vanderbilt University*

On Thu, Jun 2, 2016 at 10:55 AM, Steve Lianoglou 
wrote:

> Hello foks,
>
> I'm trying to plot the number of patients at-risk by setting the
> `n.risk` parameter to `TRUE` in the rms::survplot function, however it
> looks as if the numbers presented in the rows for each category are
> just summing up the total number of patients at risk in all groups for
> each timepoint -- which is to say that the numbers are equal in each
> category down the rows, and they don't seem to be the numbers specific
> to each group.
>
> You can reproduce the observed behavior by simply running the code in
> the Examples section of ?survplot, which I'll paste below for
> convenience.
>
> Is the error between the chair and the keyboard, here, or is this perhaps
> a bug?
>
> === code ===
> library(rms)
> n <- 1000
> set.seed(731)
> age <- 50 + 12*rnorm(n)
> label(age) <- "Age"
> sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
> cens <- 15*runif(n)
> h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
> dt <- -log(runif(n))/h
> label(dt) <- 'Follow-up Time'
> e <- ifelse(dt <= cens,1,0)
> dt <- pmin(dt, cens)
> units(dt) <- "Year"
> dd <- datadist(age, sex)
> options(datadist='dd')
> S <- Surv(dt,e)
>
> f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
> survplot(f, sex, n.risk=TRUE)
> ===
>
> I'm using the latest version of rms (4.5-0) running on R 3.3.0-patched.
>
> === Output o sessionInfo() ===
> R version 3.3.0 Patched (2016-05-26 r70671)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X 10.11.4 (El Capitan)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] rms_4.5-0   SparseM_1.7 Hmisc_3.17-4ggplot2_2.1.0
> [5] Formula_1.2-1   survival_2.39-4 lattice_0.20-33
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_0.12.5 cluster_2.0.4   MASS_7.3-45
>  [4] splines_3.3.0   munsell_0.4.3   colorspace_1.2-6
>  [7] multcomp_1.4-5  plyr_1.8.3  nnet_7.3-12
> [10] grid_3.3.0  data.table_1.9.6gtable_0.2.0
> [13] nlme_3.1-128quantreg_5.24   TH.data_1.0-7
> [16] latticeExtra_0.6-28 MatrixModels_0.4-1  polspline_1.1.12
> [19] Matrix_1.2-6gridExtra_2.2.1 RColorBrewer_1.1-2
> [22] codetools_0.2-14acepack_1.3-3.3 rpart_4.1-10
> [25] sandwich_2.3-4  scales_0.4.0mvtnorm_1.0-5
> [28] foreign_0.8-66  chron_2.3-47zoo_1.7-13
> ===
>
>
> Thanks,
> -steve
>
>
> --
> Steve Lianoglou
> Computational Biologist
> Genentech
>

[[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] Trouble getting rms::survplot(..., n.risk=TRUE) to behave properly

2016-06-02 Thread Steve Lianoglou
Hello foks,

I'm trying to plot the number of patients at-risk by setting the
`n.risk` parameter to `TRUE` in the rms::survplot function, however it
looks as if the numbers presented in the rows for each category are
just summing up the total number of patients at risk in all groups for
each timepoint -- which is to say that the numbers are equal in each
category down the rows, and they don't seem to be the numbers specific
to each group.

You can reproduce the observed behavior by simply running the code in
the Examples section of ?survplot, which I'll paste below for
convenience.

Is the error between the chair and the keyboard, here, or is this perhaps a bug?

=== code ===
library(rms)
n <- 1000
set.seed(731)
age <- 50 + 12*rnorm(n)
label(age) <- "Age"
sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt <- -log(runif(n))/h
label(dt) <- 'Follow-up Time'
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
dd <- datadist(age, sex)
options(datadist='dd')
S <- Surv(dt,e)

f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
survplot(f, sex, n.risk=TRUE)
===

I'm using the latest version of rms (4.5-0) running on R 3.3.0-patched.

=== Output o sessionInfo() ===
R version 3.3.0 Patched (2016-05-26 r70671)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.4 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] rms_4.5-0   SparseM_1.7 Hmisc_3.17-4ggplot2_2.1.0
[5] Formula_1.2-1   survival_2.39-4 lattice_0.20-33

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5 cluster_2.0.4   MASS_7.3-45
 [4] splines_3.3.0   munsell_0.4.3   colorspace_1.2-6
 [7] multcomp_1.4-5  plyr_1.8.3  nnet_7.3-12
[10] grid_3.3.0  data.table_1.9.6gtable_0.2.0
[13] nlme_3.1-128quantreg_5.24   TH.data_1.0-7
[16] latticeExtra_0.6-28 MatrixModels_0.4-1  polspline_1.1.12
[19] Matrix_1.2-6gridExtra_2.2.1 RColorBrewer_1.1-2
[22] codetools_0.2-14acepack_1.3-3.3 rpart_4.1-10
[25] sandwich_2.3-4  scales_0.4.0mvtnorm_1.0-5
[28] foreign_0.8-66  chron_2.3-47zoo_1.7-13
===


Thanks,
-steve


-- 
Steve Lianoglou
Computational Biologist
Genentech

__
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] Struggling trying to plot points on boxplot

2016-06-02 Thread William Dunlap via R-help
Does using zz<-bxp(boxplot(data,plot=FALSE)) do what you want?  E.g.,

d <- transform(data.frame(t=1:15), x = sin(t)+log2(t), group =
paste("Group", t%/%4))
groupedX <- with(d, split(x, group))
zz <- bxp(boxplot(groupedX, plot=FALSE)) # bxp returns the x positions of
the boxes
points(col="blue", pch=15, zz, vapply(splitX, FUN=mean, FUN.VALUE=0))


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Jun 2, 2016 at 8:36 AM, Thomas Adams  wrote:

> Hello all:
>
> I've been beating my head on this for over a day and I have done a lot of
> Google'ing with no luck.
>
> I have generated a 'time-series' of boxplots (227), covering more than a
> 30-day period at 6-hour intervals, which summarize an ensemble forecast.
> What I want to do is over-plot the observed values over a portion of the
> forecast period to serve as a basis of comparison; so, there would be a
> boxplot and a single point value plotted at each 6-hour interval.
>
> The boxplots are generated:
>
> zz<-boxplot(ens$value ~ ens$valid_time,xlab="Date/Time
> (UTC)",ylab="Flow(cfs)",boxfill="cyan")
>
> which works fine, but the observed points will not display using:
>
> points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)
>
> I've tried many variations of the latter, where either nothing happens and
> no error is returned or I have also gotten that x and y have different
> lengths. I suspect I am using the wrong 'x' type. I have observation values
> beginning with the first in the series of boxplots, which then end, with
> the most recent ensemble forecast. So, I always expect the number of
> observed values to be less than the number of boxplots. I have done this
> previously, years ago, but can not find my notes and can not reconstruct
> what I did.
>
> Help is appreciated.
>
> Regards,
> Tom
>
> [[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] Struggling trying to plot points on boxplot

2016-06-02 Thread RICHARD M. HEIBERGER
something like this

points(zz[1:length(obs$value)], obs$value,lty=3,lwd=1,col="red",pch=19)

Sent from my iPhone

> On Jun 2, 2016, at 11:36, Thomas Adams  wrote:
> 
> points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)

__
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] Struggling trying to plot points on boxplot

2016-06-02 Thread Sarah Goslee
boxplot() turns the x variable into a factor, if it isn't already, so
the x axis is calibrated as seq_len(nvalues). Whatever you're trying
to do with using your boxplot object as the x variable in points won't
work: zz is a list of length 6.

There's an example in ?boxplot of adding points to a boxplot.

Without a reproducible example, it's impossible to give you working
code, but here's another example besides the one in ?boxplot:

zz <- boxplot(runif(100) ~ sample(c(4, 9, 15), size=100, replace=TRUE))
points(seq_len(3), c(.8, .82, .9), col="red", pch=2)

Notice that even though the boxplot labels are 4, 9, 15 the plot
coordinates are 1, 2, 3.

Sarah

On Thu, Jun 2, 2016 at 11:36 AM, Thomas Adams  wrote:
> Hello all:
>
> I've been beating my head on this for over a day and I have done a lot of
> Google'ing with no luck.
>
> I have generated a 'time-series' of boxplots (227), covering more than a
> 30-day period at 6-hour intervals, which summarize an ensemble forecast.
> What I want to do is over-plot the observed values over a portion of the
> forecast period to serve as a basis of comparison; so, there would be a
> boxplot and a single point value plotted at each 6-hour interval.
>
> The boxplots are generated:
>
> zz<-boxplot(ens$value ~ ens$valid_time,xlab="Date/Time
> (UTC)",ylab="Flow(cfs)",boxfill="cyan")
>
> which works fine, but the observed points will not display using:
>
> points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)
>
> I've tried many variations of the latter, where either nothing happens and
> no error is returned or I have also gotten that x and y have different
> lengths. I suspect I am using the wrong 'x' type. I have observation values
> beginning with the first in the series of boxplots, which then end, with
> the most recent ensemble forecast. So, I always expect the number of
> observed values to be less than the number of boxplots. I have done this
> previously, years ago, but can not find my notes and can not reconstruct
> what I did.
>
> Help is appreciated.
>
> Regards,
> Tom

__
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] Struggling trying to plot points on boxplot

2016-06-02 Thread Thomas Adams
Hello all:

I've been beating my head on this for over a day and I have done a lot of
Google'ing with no luck.

I have generated a 'time-series' of boxplots (227), covering more than a
30-day period at 6-hour intervals, which summarize an ensemble forecast.
What I want to do is over-plot the observed values over a portion of the
forecast period to serve as a basis of comparison; so, there would be a
boxplot and a single point value plotted at each 6-hour interval.

The boxplots are generated:

zz<-boxplot(ens$value ~ ens$valid_time,xlab="Date/Time
(UTC)",ylab="Flow(cfs)",boxfill="cyan")

which works fine, but the observed points will not display using:

points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)

I've tried many variations of the latter, where either nothing happens and
no error is returned or I have also gotten that x and y have different
lengths. I suspect I am using the wrong 'x' type. I have observation values
beginning with the first in the series of boxplots, which then end, with
the most recent ensemble forecast. So, I always expect the number of
observed values to be less than the number of boxplots. I have done this
previously, years ago, but can not find my notes and can not reconstruct
what I did.

Help is appreciated.

Regards,
Tom

[[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] coxph: no convergence with completely tied data with 'exact'-method

2016-06-02 Thread Johannes Hengelbrock
Dear users,

I'm trying to estimate a conditional logistic model using the 
coxph()-function from the survival package. Somehow, the model does not 
converge if time is set to the same value for all observations:

 library(survival)
 set.seed(12345)
 n <- 3000
 a <- rbinom(n, 1, 0.5)
 b <- rbinom(n, 1, 0.5)
 coxph(formula = Surv(rep(1, 3000), a) ~ b, method = "exact")

Error in fitter(X, Y, strats, offset, init, control, weights = weights, 
: NA/NaN/Inf in foreign function call (arg 5) In addition: Warning 
message: In fitter(X, Y, strats, offset, init, control, weights = 
weights, :Ran out of iterations and did not converge

Changing iter.max does not help, aparently. Strangely, the exact same 
model converges in SAS.

I know that I could estimate the model differently (via glm), but I 
would like to understand why the model does converge in SAS but not in R.

Thanks,
Johannes

-- 
__
Johannes Hengelbrock
Universitätsklinikum Hamburg-Eppendorf
Institut f. Medizinische Biometrie und Epidemiologie
Martinistr. 52, 20246 Hamburg

Tel. 040-7410-53517 / Fax: 040-7410-57790

mailto:j.hengelbr...@uke.de
https://www.uke.de/kliniken-institute/institute/medizinische-biometrie-und-epidemiologie/team/index.html
__

--

_

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr. Dr. Uwe 
Koch-Gromus, Joachim Prölß, Rainer Schoppik
_

SAVE PAPER - THINK BEFORE PRINTING

[[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] FW: How to read multiple raster and serial correlation between series of rasters

2016-06-02 Thread Waseem Ali



Dear members,
With little effort in producing the code to read all nc files for Carbon 
dioxide variables I have produced the following code:
library(ncdf)ncfiles <- list.files("C:/site-download/AIRS/", pattern='\\.nc$', 
full.names = TRUE)ncfilesncfname <- ncfiles[1]ncfnamedname <- 
"mole_fraction_of_carbon_dioxide_in_free_troposphere"ncin <- 
open.ncdf(ncfname)print(ncin)lon <- get.var.ncdf(ncin, "Longitude")nlon <- 
dim(lon)head(lon)lat <- get.var.ncdf(ncin, "Latitude")nlat <- 
dim(lat)head(lat)print(c(nlon, nlat))co2array <- get.var.ncdf(ncin, 
"mole_fraction_of_carbon_dioxide_in_free_troposphere")fillvalue <- 
att.get.ncdf(ncin, "mole_fraction_of_carbon_dioxide_in_free_troposphere", 
"Missval")fillvalueco2array[co2array == fillvalue] <- 
NAlibrary(RColorBrewer)image(co2array, col = rev(brewer.pal(10, "RdBu")))grid 
<- expand.grid(lon = lon, lat = lat)lonlat <- expand.grid(lon, 
lat)lonlathead(lonlat)m <- 1co2.vec <- 
as.vector(co2array)length(co2.vec)co2.df01 <- data.frame(cbind(lonlat, 
co2.vec*100))names(co2.df01) <- c("lon", "lat", paste("co2", 
as.character(m), sep = "_"))head(na.omit(co2.df01), 20)csvfile <- 
"co20020901.csv"write.table(na.omit(co2.df01), csvfile, row.names = FALSE, sep 
= ",")With the help of this code I can dump the values of Carbon dioxide 
variables in latitude and longitude wise. sample of the csv file is as under:   
   lon  latco2_126  -117.5 89.5 381.802050   -57.5 89.5 373.8030147 -175.0 
88.0 382.7285148 -172.5 88.0 373.6800152 -162.5 88.0 371.6560153 -160.0 88.0 
373.4450154 -157.5 88.0 374.3705I need help to tune code to do this with 
iterative code for whole 120 raster to write it into csv file. Column names 
should be like as 200301, 200302up to 200312. This starts from the January 
of 2003 till December of 2003 and so on for the next year.   My next task to do 
the same for LST variable retrievable from MODIS LST product of 0.05 degree 
resolution which is in hdf file formate [I am trying to write the code to 
interpret the variable ]. I want to resample it first to have on same spatial 
resolution as my first raster then write to the another csv file in the same 
way before. After writing it into the csv files I want to correlate the both 
variables and serial correlation. Please guide to do it using R or any other 
way to deal with the situations I have briefly explained. Also suggest for 
interpolation for carbon dioxide variable first to make the raster layer. It 
may have missing some values.
Waseem Ali 

From: w1ma...@hotmail.com
To: r-help@r-project.org
Subject: How to real multiple raster and serial correlation between series of 
rasters
Date: Sun, 29 May 2016 23:39:18 +0500







Hi,
I have 120 raster (10 years) files
in tif format of one variable (say X1) and same numbers for second variables 
(Say
X2). Each raster consists the mean monthly values of corresponding variables. I
want to write a script in R which operates the following operations:

·
First reads the one by one
raster from folder and save into the objects. 

·
Resample/aggregate the both
raster over same spatial resolution 2˚ x 2.5˚.

·
After resampling the all
raster over same resolution, conversions of all raster to points by using the
rasterToPoint() function of raster library.

·
After retrieving the same
monthly raster values (like month of January for X1 and X2) into data frame, I
want to compute regression and correlation values for all 120 raster for both
variables (X1 and X2) and save into the data frame.

Is there any way out to deal with
such task.


library(raster)

x <- list.files("C:/site-download/",
pattern = "*.tif", full.names = TRUE)

x1 <- raster(x1)

p <- as(x1, 'SpatialPixels')

plot(x1)

points(p)
Resultant figure has been attached for you for only x1 variable. I have also 
attached the X1 and X2 variable tif raster for January 2002 for computation 
purpose. I need to operate it through loop for reading all these rasters and 
computing the correlation of each pairs. My next step to compute the Lag -1 
correlations which is Serial Correlation for both variables.
Waseem Ali 
  
  
__
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] Making an if condition variable ?

2016-06-02 Thread Bert Gunter
You need to rethink. You'll do better in the long -- and probably
short, too -- run working within the language's paradigms rather than
resisting them.

(It's not that R's paradigms are in any sense "the best"; other
languages have different paradigms and you would do better in those
languages with their paradigms rather than with R's).

For example, you could have a single function that returns the
conditional function of your choice by calling the overall function
with an appropriate keyword.  Etc.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Jun 2, 2016 at 7:50 AM, ce  wrote:
>
> well, not that simple. My original condition and changes are more complicated 
> than I post in r-help for simplicity purposes . Original condition is 
> something like :
>
>  if (   a > 0  & ( b[1] > b[2] ) |  c == TRUE )
>
> and I might change it to
>
> if ( a == 0 &  ( b[1] < b[2] ) & d > 10 )
>
> then I need to have a bunch of functions and I will forget which function I 
> used.
>
> -Original Message-
> From: "Rainer M Krug" [rai...@krugs.de]
> Date: 06/02/2016 09:08 AM
> To: "ce" 
> CC: "Jeff Newmiller" , r-help@r-project.org
> Subject: Re: Making an if condition variable ?
>
> "ce"  writes:
>
>> Thank you all for wisdom :)
>> Problem is that I change the condition often and then I forget it. I
>> wanted to put it at the beginning of the program with the other
>> parameters so I wouldn't miss it.
>
> In this case - why not use a function instead of the condition?
>
> cond <- function(x){x>0}
> and than
>
> if (cond(4)) {...}
>
> might be the easiest in this case?
>
> or, more flexible,
>
> cond <- function(...){x>0}
>
> if (cond(x=3)) {...}
>
> Cheers,
>
> Rainer
>
>>
>> ce
>>
>>
>> -Original Message-
>> From: "Rainer M Krug" [rai...@krugs.de]
>> Date: 06/02/2016 04:00 AM
>> To: "Jeff Newmiller" 
>> CC: r-help@r-project.org
>> Subject: Re: Making an if condition variable ?
>>
>> Jeff Newmiller  writes:
>>
>>> Beware of getting too "meta" in your programming... it is rarely worth
>>> it. Just write the code and move on with life. That is the beauty of a
>>> scripting language.
>>
>> +1
>>
>> I think this a very common pitfall (I know it from own experience...)
>> and I would say a candidate for a fortune?
>>
>> Rainer
>
> --
> Rainer M. Krug
> email: Rainerkrugsde
> PGP: 0x0F52F982
>
> __
> 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] Convert ncdf data to dataframe

2016-06-02 Thread MacQueen, Don
There's a pretty good chance this question has been previously asked and
answered on the R-sig-geo mailing list (though I don't know for sure).

In addition, entering

  "R convert ncdf to data frame"

in a web search returned some possibilities, the first of which (for me)
was

  http://geog.uoregon.edu/bartlein/courses/geog607/Rmd/netCDF_01.htm

and partway down that page is an entry,

  "Get a single time slice of the data, create an R data frame, and write
a .csv file"

which does indeed have some examples of how to convert to a data frame.


-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 6/2/16, 1:42 AM, "R-help on behalf of Miluji Sb"
 wrote:

>Dear all,
>
>I have used the following code to read in a ncdf file
>
>library(chron)
>library(lattice)
>library(ncdf4)
>library(data.table)
>
>ncname <- ("/file_path")
>ncfname <- paste(ncname, ".nc", sep = "")
>dname <- "ssl"  # note: tmp means temperature (not temporary)
>
>ncin <- nc_open(ncfname)
>print(ncin)
>
>The attributes of the file are:
>
> 4 variables (excluding dimension variables):
>double longitude[row]
>long_name: longitude
>units: degrees_east
>standard_name: longitude
>double latitude[row]
>long_name: latitude
>units: degrees_north
>standard_name: latitude
>double ssl[col,row]
>long_name: storm surge level
>units: m
>_FillValue: -9
>scale_factor: 1
>add_offset: 1
>float RP[col]
>long_name: return period
>units: yr
>Contents: The RPs have been estimated following the Peak Over
>Threshold Method (see reference below)
>Starting date: 01-Dec-2009
>End date: 30-Nov-2099 21:00:00
> 2 dimensions:
>col  Size:8
>row  Size:2242
>
>I would like to convert the data into a dataframe by longitude and
>latitude. Is that possible? Thank you!
>
>Sincerely,
>
>Milu
>
>   [[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] Making an if condition variable ?

2016-06-02 Thread ce

well, not that simple. My original condition and changes are more complicated 
than I post in r-help for simplicity purposes . Original condition is something 
like :

 if (   a > 0  & ( b[1] > b[2] ) |  c == TRUE ) 

and I might change it to

if ( a == 0 &  ( b[1] < b[2] ) & d > 10 ) 

then I need to have a bunch of functions and I will forget which function I 
used. 

-Original Message-
From: "Rainer M Krug" [rai...@krugs.de]
Date: 06/02/2016 09:08 AM
To: "ce" 
CC: "Jeff Newmiller" , r-help@r-project.org
Subject: Re: Making an if condition variable ?

"ce"  writes:

> Thank you all for wisdom :)
> Problem is that I change the condition often and then I forget it. I
> wanted to put it at the beginning of the program with the other
> parameters so I wouldn't miss it.

In this case - why not use a function instead of the condition?

cond <- function(x){x>0}
and than

if (cond(4)) {...}

might be the easiest in this case?

or, more flexible,

cond <- function(...){x>0}

if (cond(x=3)) {...}

Cheers,

Rainer

>
> ce
>
>
> -Original Message-
> From: "Rainer M Krug" [rai...@krugs.de]
> Date: 06/02/2016 04:00 AM
> To: "Jeff Newmiller" 
> CC: r-help@r-project.org
> Subject: Re: Making an if condition variable ?
>
> Jeff Newmiller  writes:
>
>> Beware of getting too "meta" in your programming... it is rarely worth
>> it. Just write the code and move on with life. That is the beauty of a
>> scripting language.
>
> +1
>
> I think this a very common pitfall (I know it from own experience...)
> and I would say a candidate for a fortune?
>
> Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982

__
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] Ayuda con R Sweave

2016-06-02 Thread Carlos Ortega
En el menú de RStudio...

Help -> CheatSheets -> R Markdown Cheat Sheet / R Markdown Reference Guide

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 2 de junio de 2016, 15:59, Jorge I Velez 
escribió:

> Hola Jesús,
> Revisa las opciones en http://yihui.name/knitr/options/  Necesitas
> los argumentos fig.width y fig.height.
> Saludos,
> Jorge.-
>
>
>
> 2016-06-02 8:56 GMT-05:00 Jesús Para Fernández <
> j.para.fernan...@hotmail.com
> >:
>
> >
> > Gracias por las respuestas
> >
> > La verdad es qeu estoy trabjando con Rstudio + Knitr, lo unico que en R
> > studio le doy a crear nuevo Sweave, pero is me carga la libreria knitr.
> >
> > Solucioné el problema que os comenté, era por un fallo tonto, a la hora
> de
> > poner datos$A, puse dats$A, es decir, le faltaba la o
> >
> > Ahora una duda que no se como resolver es la de los gráficos. No consigo
> > reducir su tamaño...
> >
> > 

Re: [R] Convert ncdf data to dataframe

2016-06-02 Thread Jeff Newmiller
The answer to your question is "yes".

You probably need to make your example reproducible by including (or 
referencing by URL) sample data if you want a more complete response. 
-- 
Sent from my phone. Please excuse my brevity.

On June 2, 2016 1:42:55 AM PDT, Miluji Sb  wrote:
>Dear all,
>
>I have used the following code to read in a ncdf file
>
>library(chron)
>library(lattice)
>library(ncdf4)
>library(data.table)
>
>ncname <- ("/file_path")
>ncfname <- paste(ncname, ".nc", sep = "")
>dname <- "ssl"  # note: tmp means temperature (not temporary)
>
>ncin <- nc_open(ncfname)
>print(ncin)
>
>The attributes of the file are:
>
> 4 variables (excluding dimension variables):
>double longitude[row]
>long_name: longitude
>units: degrees_east
>standard_name: longitude
>double latitude[row]
>long_name: latitude
>units: degrees_north
>standard_name: latitude
>double ssl[col,row]
>long_name: storm surge level
>units: m
>_FillValue: -9
>scale_factor: 1
>add_offset: 1
>float RP[col]
>long_name: return period
>units: yr
>  Contents: The RPs have been estimated following the Peak Over
>Threshold Method (see reference below)
>Starting date: 01-Dec-2009
>End date: 30-Nov-2099 21:00:00
> 2 dimensions:
>col  Size:8
>row  Size:2242
>
>I would like to convert the data into a dataframe by longitude and
>latitude. Is that possible? Thank you!
>
>Sincerely,
>
>Milu
>
>   [[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-es] Ayuda con R Sweave

2016-06-02 Thread Jorge I Velez
Hola Jesús,
Revisa las opciones en http://yihui.name/knitr/options/  Necesitas
los argumentos fig.width y fig.height.
Saludos,
Jorge.-



2016-06-02 8:56 GMT-05:00 Jesús Para Fernández :

>
> Gracias por las respuestas
>
> La verdad es qeu estoy trabjando con Rstudio + Knitr, lo unico que en R
> studio le doy a crear nuevo Sweave, pero is me carga la libreria knitr.
>
> Solucioné el problema que os comenté, era por un fallo tonto, a la hora de
> poner datos$A, puse dats$A, es decir, le faltaba la o
>
> Ahora una duda que no se como resolver es la de los gráficos. No consigo
> reducir su tamaño...
>
> 

Re: [R-es] Ayuda con R Sweave

2016-06-02 Thread Jesús Para Fernández

Gracias por las respuestas

La verdad es qeu estoy trabjando con Rstudio + Knitr, lo unico que en R studio 
le doy a crear nuevo Sweave, pero is me carga la libreria knitr.

Solucion� el problema que os coment�, era por un fallo tonto, a la hora de 
poner datos$A, puse dats$A, es decir, le faltaba la o

Ahora una duda que no se como resolver es la de los gr�ficos. No consigo 
reducir su tama�o...


Re: [R-es] Ayuda con R Sweave

2016-06-02 Thread Jorge I Velez
Buenos dias Jesús,
 Existe alguna razón especial para no trabajar en RStudio + knitr?  IMO,
es mucho mas fácil y flexible.  Más información en
http://yihui.name/knitr/demo/rstudio/
Saludos,
Jorge.-



2016-06-02 6:10 GMT-05:00 Jesús Para Fernández :

> >Buenas,
>
> Estoy empezando a utilizar latex y hay un par de cosas que no se muy bien
> como hacer ni como buscar en google.
>
> Tengo un data.frame llamado datos con 3 variables, A,B y C
>
> Si pongo
> <<>>
> datos$A
> @
>
> me devuelve error
>
> sin embargo si lo hago con
> <<>>=
> datos[,1]
> @
> me da correctamente. No puedo con Sneave al interior de un data frame
> usando el nombre de las variables con el $???
>
> Gracias!
>
> [[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-es] Ayuda con R Sweave

2016-06-02 Thread Javier Marcuzzi
Estimados

Hay un libro y material al respecto en 
https://github.com/christophergandrud/Rep-Res-Book


Javier Rubén Marcuzzi

De: Carlos Ortega
Enviado: jueves, 2 de junio de 2016 8:45
Para: Jesús Para Fernández
CC: r-help-es@r-project.org
Asunto: Re: [R-es] Ayuda con R Sweave

Hola,

¿No te interesa trabajar todo esto directamente sobre RStudio con
rmarkdown/knitr...?

http://kbroman.org/knitr_knutshell/

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 2 de junio de 2016, 13:10, Jesús Para Fernández <
j.para.fernan...@hotmail.com> escribió:

> >Buenas,
>
> Estoy empezando a utilizar latex y hay un par de cosas que no se muy bien
> como hacer ni como buscar en google.
>
> Tengo un data.frame llamado datos con 3 variables, A,B y C
>
> Si pongo
> <<>>
> datos$A
> @
>
> me devuelve error
>
> sin embargo si lo hago con
> <<>>=
> datos[,1]
> @
> me da correctamente. No puedo con Sneave al interior de un data frame
> usando el nombre de las variables con el $???
>
> Gracias!
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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


[[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] Making an if condition variable ?

2016-06-02 Thread Rainer M Krug
"ce"  writes:

> Thank you all for wisdom :)
> Problem is that I change the condition often and then I forget it. I
> wanted to put it at the beginning of the program with the other
> parameters so I wouldn't miss it.

In this case - why not use a function instead of the condition?

cond <- function(x){x>0}
and than

if (cond(4)) {...}

might be the easiest in this case?

or, more flexible,

cond <- function(...){x>0}

if (cond(x=3)) {...}

Cheers,

Rainer

>
> ce
>
>
> -Original Message-
> From: "Rainer M Krug" [rai...@krugs.de]
> Date: 06/02/2016 04:00 AM
> To: "Jeff Newmiller" 
> CC: r-help@r-project.org
> Subject: Re: Making an if condition variable ?
>
> Jeff Newmiller  writes:
>
>> Beware of getting too "meta" in your programming... it is rarely worth
>> it. Just write the code and move on with life. That is the beauty of a
>> scripting language.
>
> +1
>
> I think this a very common pitfall (I know it from own experience...)
> and I would say a candidate for a fortune?
>
> Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature
__
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] Making an if condition variable ?

2016-06-02 Thread ce

Thank you all for wisdom :)
Problem is that I change the condition often and then I forget it. I wanted to 
put it at the beginning of the program with the other parameters so I wouldn't 
miss it. 

ce


-Original Message-
From: "Rainer M Krug" [rai...@krugs.de]
Date: 06/02/2016 04:00 AM
To: "Jeff Newmiller" 
CC: r-help@r-project.org
Subject: Re: Making an if condition variable ?

Jeff Newmiller  writes:

> Beware of getting too "meta" in your programming... it is rarely worth
> it. Just write the code and move on with life. That is the beauty of a
> scripting language.

+1

I think this a very common pitfall (I know it from own experience...)
and I would say a candidate for a fortune?

Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982

__
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] SEM GFI

2016-06-02 Thread Fox, John
Dear Vinay and Burt,

I didn't see Vinay's original posting -- sorry about that.

Vinay: There's still not enough information here to tell why the results are 
different, and posting in HTML makes the code very hard to read. 

To elaborate slightly: You don't provide the data, so it's not possible to 
replicate your results. You also don't show the command or results from SAS, so 
it's not possible to know how the results differ. Your original message seems 
to imply that the results are identical accept for the value of GFI and one 
coefficient standard error. That seems unlikely. My guess: you inadvertently 
fit different models in SAS and sem.

Additionally, you'd probably find it easier, and less error prone, to specify 
the model in sem() using specifyEquations() rather than specifyModel(), as the 
message printed by the latter tells you.

I hope this helps,
 John

-
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox




> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of VINAY
> KULKARNI via R-help
> Sent: June 1, 2016 1:42 PM
> To: Bert Gunter 
> Cc: r-help@r-project.org
> Subject: Re: [R] SEM GFI
> 
> Hi,
> Please find below the code:
> Thanks,Vinay
> >library(sem) >data1=read.csv("data_1.csv") >corr=cor(data1)
> >model1<-specifyModel()brand1_Pric_ind->
> >Val_brand1,lamb1,NADist_brand1   ->
> >Val_brand1,lamb2,NAbrand1_like_me ->
> >Val_brand1,lamb3,NAbrand2_Def_Drink -
> >   Val_brand1,lamb4,NAbrand2_Like
> >-> brand2_Def_Drink,lamb5,NAbrand2_Pleasure ->
> >brand2_Def_Drink,lamb6,NAbrand1_Like ->
> >brand1_like_me,lamb7,NAbrand1_Love ->
> >brand1_like_me,lamb8,NAbrand1_P4WC ->
> brand1_Like,lamb9,NAbrand1_P4WC
> >-> brand1_Love,lamb10,NAbrand1_Energy ->
> >brand1_P4WC,lamb11,NAbrand1_Different ->
> >brand1_P4WC,lamb12,NAbrand1_Pric_ind <->
> >brand1_Pric_ind,the1,NADist_brand1 <->
> >Dist_brand1,the2,NAbrand1_like_me  <->
> >brand1_like_me,the3,NAbrand2_Def_Drink <->
> >brand2_Def_Drink,the4,NAbrand2_Like <->
> >brand2_Like,the5,NAbrand2_Pleasure <->
> >brand2_Pleasure,the6,NAbrand1_Like <-> brand1_Like,the7,NAbrand1_Love
> ><-> brand1_Love,the8,NAbrand1_P4WC <->
> brand1_P4WC,the9,NAbrand1_Energy
> ><-> brand1_Energy,the10,NAbrand1_Different <->
> >brand1_Different,the11,NAbrand1_like_me  <->
> >brand2_Def_Drink,the12,NAbrand1_Like <->
> brand1_Love,the13,NAVal_brand1
> ><-> Val_brand1,1,NA  > opt <- options(fit.indices = c("GFI", "AGFI",
> >"RMSEA", "NFI", "NNFI", "CFI", "RNI", "IFI", "SRMR", "AIC", "AICc",
> >"BIC", "CAIC")) > sem.model1<-sem(model1,corr,36)
> > summary(sem.model1)
> 
> 
> 
> 
>   From: Bert Gunter 
>  To: VINAY KULKARNI 
> Cc: "r-help@r-project.org" 
>  Sent: Wednesday, 1 June 2016 2:16 AM
>  Subject: Re: [R] SEM GFI
> 
> Probably impossible to answer without your following the posting guide and
> posting your code, etc.
> 
> Cheers,
> 
> Bert
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Tue, May 31, 2016 at 11:28 AM, VINAY KULKARNI via R-help  project.org> wrote:
> > Hi,
> > I am exactly replicating the SEM model which was done in SAS using Proc
> Calis in R.
> > Used sem package in R but not getting the GFI as same as in SAS
> > (approximately 15% difference) and also one link is insignificant but in SAS
> am getting significant.
> > Searched through online in different blogs but not able to get the solution.
> > Please let me know what might be the reason.
> > Thanks,Vinay
> >
> >
> >
> >        [[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-es] Ayuda con R Sweave

2016-06-02 Thread Carlos Ortega
Hola,

¿No te interesa trabajar todo esto directamente sobre RStudio con
rmarkdown/knitr...?

http://kbroman.org/knitr_knutshell/

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 2 de junio de 2016, 13:10, Jesús Para Fernández <
j.para.fernan...@hotmail.com> escribió:

> >Buenas,
>
> Estoy empezando a utilizar latex y hay un par de cosas que no se muy bien
> como hacer ni como buscar en google.
>
> Tengo un data.frame llamado datos con 3 variables, A,B y C
>
> Si pongo
> <<>>
> datos$A
> @
>
> me devuelve error
>
> sin embargo si lo hago con
> <<>>=
> datos[,1]
> @
> me da correctamente. No puedo con Sneave al interior de un data frame
> usando el nombre de las variables con el $???
>
> Gracias!
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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-es] Ayuda con R Sweave

2016-06-02 Thread Álvaro Hernández

Buenas,

¿no será que falta el igual después de <<>>? Este código a mí me funciona:

<<>>=
datos$A
@

Saludos, Álvaro

El 02/06/16 a las 13:10, Jesús Para Fernández escribió:

Buenas,

Estoy empezando a utilizar latex y hay un par de cosas que no se muy bien como 
hacer ni como buscar en google.

Tengo un data.frame llamado datos con 3 variables, A,B y C

Si pongo
<<>>
datos$A
@

me devuelve error

sin embargo si lo hago con
<<>>=
datos[,1]
@
me da correctamente. No puedo con Sneave al interior de un data frame usando el 
nombre de las variables con el $???

Gracias!

[[alternative HTML version deleted]]

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


--
Álvaro Hernández Vicente
Sección de Apoyo Estadístico (SAE)
Servicio de Apoyo a la Investigación (SAI)
Vicerrectorado de Investigación
Universidad de Murcia, Murcia, Spain

Edificio SACE, Campus de Espinardo, 30100, Murcia
Email: alvar...@um.es
Telf:  +34 868 88 42 42
Web:   www.um.es/web/sai  www.um.es/ae
Blog:  www.sae.saiblogs.inf.um.es
---

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


Re: [R] httr package syntax (PUT)

2016-06-02 Thread Hadley Wickham
On Wed, Jun 1, 2016 at 7:16 PM, Jared Rodecker  wrote:
> Greetings fellow R users.
>
> I'm struggling with the syntax of submitting a PUT request
>
> I'm trying to insert a few PUT requests into some legacy R code that I have
> that performs daily ETL on a small database. These requests will add users
> to an email mailing list in MailChimp.
>
>
> I have been able to get my GET requests formatted into syntax that R
> (specifically the httr package) accepts:
>
> GET("
> https://us10.api.mailchimp.com/3.0/lists/list_id_X/members/MEMBER_HASH_###;,
> query = list(apikey = 'XX'))
>
>
> However when I try to do something similar for PUT requests this simple
> syntax isn't working - you can't just pass the API KEY and/or requested
> parameters directly through the URL. I get a 401 error if I use the same
> syntax I used for GET.
>
>
> I believe that I need to use the CONFIG option to pass the API key (either
> using AUTHENTICATE or ADD_HEADERS) and the requested parameters in the BODY
> to get the PUT request to work but I can't get the syntax to work - this
> gives a 400 error:
>
>
> auth <- authenticate("anystring", "XX", type = "basic")
>
> parms <- '[{"email_address" : "some_u...@domain.com", "status_if_new" :
> "subscribed"}]'
>
> PUT("
> https://us10.api.mailchimp.com/3.0/lists/list_id_X/members/MEMBER_HASH_###
> ",config=auth,body=parms,encode="json")
>
>
> If anyone can point me to a more flushed out example that would be
> amazing...but even just some tips on how to get more info on my error
> message to help me troubleshoot my syntax would also be a big help.  I've
> also been trying to get httpput (from the RCurl package) but also
> struggling with the syntax there.

If you use verbose() you should be able to see what the problem is -
httr does the json encoding for you. You want:

params <- list(email_address = "some_u...@domain.com", status_if_new =
"subscribed")
PUT("https://us10.api.mailchimp.com/3.0/lists/list_id_X/members/MEMBER_HASH_###;,
   config = auth,
   body = params,
   encode = "json"
)

Hadley

-- 
http://hadley.nz

__
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] translating function td of package tempdisagg to FORTRAN

2016-06-02 Thread MAURICE Jean - externe
Ouaouh !

Thanks a lot
Jean



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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-es] Ayuda con R Sweave

2016-06-02 Thread Jesús Para Fernández
>Buenas, 

Estoy empezando a utilizar latex y hay un par de cosas que no se muy bien como 
hacer ni como buscar en google.

Tengo un data.frame llamado datos con 3 variables, A,B y C

Si pongo 
<<>>
datos$A
@

me devuelve error

sin embargo si lo hago con 
<<>>=
datos[,1]
@
me da correctamente. No puedo con Sneave al interior de un data frame usando el 
nombre de las variables con el $???

Gracias!
  
[[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] translating function td of package tempdisagg to FORTRAN

2016-06-02 Thread Berend Hasselman

> On 2 Jun 2016, at 12:41, MAURICE Jean - externe  
> wrote:
> 
> I am (still) translating long R scripts to FORTRAN to improve speed. My 
> client deals with river's flow.
> 
> He has datas for each day of a week, we need to 'disaggregate' them to an 
> hourly base (is that clear ?) . In R, he uses function td of library 
> tempdisagg with the 'denton-cholette' algorithm. I would like to translate 
> this function in FORTRAN.
> 
> I searched for denton-cholette on internet but only found 'mathematical 
> answers' I am not able to understand.
> 
> I would like to have some  informations about this function :
>  Is it only a 'wrapper' to a C or Fortran library or is it a true R function ?
>  Is the source (R, Fortran, C, ...) available somewhere ?
> 

It is R.
Source of the tempdisagg package can be found on CRAN: 
https://cran.r-project.org
Follow the link "Packages" and  then "Table of available packages, sorted by 
name".

Direct address for tempdisagg: 
https://cran.r-project.org/web/packages/tempdisagg/index.html
The source for the full package  will be in the .tar.gz file.

Berend Hasselman

> Thanks in advance for all information you can give me !
> Jean in France
> 
> PS please can you send a copy of your response directly to my address 
> 'jean-externe.maur...@edf.fr'
> 

Done automatically if one uses Reply to All?

__
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] translating function td of package tempdisagg to FORTRAN

2016-06-02 Thread MAURICE Jean - externe
I am (still) translating long R scripts to FORTRAN to improve speed. My client 
deals with river's flow.

He has datas for each day of a week, we need to 'disaggregate' them to an 
hourly base (is that clear ?) . In R, he uses function td of library tempdisagg 
with the 'denton-cholette' algorithm. I would like to translate this function 
in FORTRAN.

I searched for denton-cholette on internet but only found 'mathematical 
answers' I am not able to understand.

I would like to have some  informations about this function :
  Is it only a 'wrapper' to a C or Fortran library or is it a true R function ?
  Is the source (R, Fortran, C, ...) available somewhere ?

Thanks in advance for all information you can give me !
Jean in France

PS please can you send a copy of your response directly to my address 
'jean-externe.maur...@edf.fr'



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à 
l'intention exclusive des destinataires et les informations qui y figurent sont 
strictement confidentielles. Toute utilisation de ce Message non conforme à sa 
destination, toute diffusion ou toute publication totale ou partielle, est 
interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le 
copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si 
vous avez reçu ce Message par erreur, merci de le supprimer de votre système, 
ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support 
que ce soit. Nous vous remercions également d'en avertir immédiatement 
l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie 
électronique arrivent en temps utile, sont sécurisées ou dénuées de toute 
erreur ou virus.


This message and any attachments (the 'Message') are intended solely for the 
addressees. The information contained in this Message is confidential. Any use 
of information contained in this Message not in accord with its purpose, any 
dissemination or disclosure, either whole or partial, is prohibited except 
formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any 
part of it. If you have received this message in error, please delete it and 
all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or 
virus-free.
__
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] Map of Italy data filled at the level of the province

2016-06-02 Thread boB Rudis
This should help you get started:

  library(maptools)
  library(ggplot2)
  library(ggalt)
  library(ggthemes)
  library(tibble)
  library(viridis)

  # get italy region map
  italy_map <- map_data("italy")

  # your data will need to have these region names
  print(unique(italy_map$region))

  # we'll simulate some data for this
  set.seed(1492)
  choro_dat <- data_frame(region=unique(italy_map$region),
  value=sample(100, length(region)))

  # we'll use this in a bit
  italy_proj <- "+proj=aea +lat_1=38.15040684902542
+lat_2=44.925490198742295 +lon_0=12.7880859375"

  gg <- ggplot()

  # lay down the base layer
  gg <- gg + geom_map(data=italy_map, map=italy_map,
  aes(long, lat, map_id=region),
  color="#b2b2b2", size=0.1, fill=NA)

  # fill in the regions with the data
  gg <- gg + geom_map(data=choro_dat, map=italy_map,
  aes(fill=value, map_id=region),
  color="#b2b2b2", size=0.1)

  # great color palette (use a better legend title)
  gg <- gg + scale_fill_viridis(name="Scale title")

  # decent map projection for italy choropleth
  gg <- gg + coord_proj(italy_proj)

  # good base theme for most maps
  gg <- gg + theme_map()

  # move the legend
  gg <- gg + theme(legend.position=c(0.95, 0.3))

  gg

This uses a continuous color palette for the region fill. You may want
to consider binning data and using a discrete fill (IMO that's usually
a better choice for most choropleths).

-Bob

On Thu, Jun 2, 2016 at 5:37 AM, francesca Pancotto
 wrote:
> Dear Users
> I am very new to the use of ggplot. I am supposed to make a plot of
> Italian provinces in which I have to fill the color of some provinces
> with the values of a variable(I do not provide the data because it is 
> irrelevant which data to use).
>
> Right now I explored the function map in maps package thanks to which I 
> managed to plot
> the map of Italy with provinces borders and select only those provinces 
> contained in the
> vector nomi(which is just a list of character elements with the names of the 
> provinces which are
> just like counties in the US).
>
> map("italy",col=1:20, regions=nomi)
>
> The problem is to fill the provinces level with the values of a variable that 
> is the variable of interest:
> I found a series of examples based on US data extracted from very hard to get 
> databases.
>
> Can anyone provide an easy example where to start from?
>
> Thanks in advance
> Francesca
>
> --
> Francesca Pancotto
> Professore Associato di Politica Economica
> Università degli Studi di Modena e Reggio Emilia
> Palazzo Dossetti - Viale Allegri, 9 - 42121 Reggio Emilia
> Office: +39 0522 523264
> Web: https://sites.google.com/site/francescapancotto/
> --
>
>
> [[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] Map of Italy data filled at the level of the province

2016-06-02 Thread francesca Pancotto
Dear Users
I am very new to the use of ggplot. I am supposed to make a plot of 
Italian provinces in which I have to fill the color of some provinces 
with the values of a variable(I do not provide the data because it is 
irrelevant which data to use).

Right now I explored the function map in maps package thanks to which I managed 
to plot
the map of Italy with provinces borders and select only those provinces 
contained in the 
vector nomi(which is just a list of character elements with the names of the 
provinces which are 
just like counties in the US).

map("italy",col=1:20, regions=nomi)

The problem is to fill the provinces level with the values of a variable that 
is the variable of interest:
I found a series of examples based on US data extracted from very hard to get 
databases.

Can anyone provide an easy example where to start from?

Thanks in advance
Francesca

--
Francesca Pancotto
Professore Associato di Politica Economica
Università degli Studi di Modena e Reggio Emilia
Palazzo Dossetti - Viale Allegri, 9 - 42121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--


[[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] Convert ncdf data to dataframe

2016-06-02 Thread Miluji Sb
Dear all,

I have used the following code to read in a ncdf file

library(chron)
library(lattice)
library(ncdf4)
library(data.table)

ncname <- ("/file_path")
ncfname <- paste(ncname, ".nc", sep = "")
dname <- "ssl"  # note: tmp means temperature (not temporary)

ncin <- nc_open(ncfname)
print(ncin)

The attributes of the file are:

 4 variables (excluding dimension variables):
double longitude[row]
long_name: longitude
units: degrees_east
standard_name: longitude
double latitude[row]
long_name: latitude
units: degrees_north
standard_name: latitude
double ssl[col,row]
long_name: storm surge level
units: m
_FillValue: -9
scale_factor: 1
add_offset: 1
float RP[col]
long_name: return period
units: yr
Contents: The RPs have been estimated following the Peak Over
Threshold Method (see reference below)
Starting date: 01-Dec-2009
End date: 30-Nov-2099 21:00:00
 2 dimensions:
col  Size:8
row  Size:2242

I would like to convert the data into a dataframe by longitude and
latitude. Is that possible? Thank you!

Sincerely,

Milu

[[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] Making an if condition variable ?

2016-06-02 Thread Rainer M Krug
Jeff Newmiller  writes:

> Beware of getting too "meta" in your programming... it is rarely worth
> it. Just write the code and move on with life. That is the beauty of a
> scripting language.

+1

I think this a very common pitfall (I know it from own experience...)
and I would say a candidate for a fortune?

Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature
__
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] Unable to update R software to 3.3.0

2016-06-02 Thread Loris Bennett
Loris Bennett  writes:

> Loris Bennett  writes:
>
>> Hi Sunish,
>>
>> Sunish Kumar Bilandi  writes:
>>
>>> Hi Team,
>>>
>>> I am using RedHat 5 and installed R using YUM, (R version 3.2.3) Now I
>>> want to update R version tp 3.3.0, but I am unable to do that, Is
>>> there any alternate to do this?
>>>
>>> Hope to hear from your side.
>>>
>>> Regards,
>>>
>>>
>>> Sunish Bilandi
>>> Business Analyst, CIDA-01
>>> Evalueserve
>>
>> You don't say what the problem is, but I'm running Scientific Linux 6.7,
>> which is based on the corresponding version of Red Hat, and have found
>> that I cannot install R 3.3.0, because the version of zlib available is
>> too old.  R 3.3.0 requires zlib >= 1.2.5, whereas the version in the SL
>> repositories is 1.2.3.
>>
>> So if this is the problem, then you either have to install newer version
>> of zlib from source or switch to RH7, which comes with zlib 1.2.7.
>
> I forgot to say that for RH7, R 3.3.0 is available from the EPEL
> repository, whereas for RH5 or RH6 you will have to install R from
> source.

I wrote too soon:  Today an update to R 3.3.0 for SL6 has been made
available.

Cheers,

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
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] Making an if condition variable ?

2016-06-02 Thread Martin Maechler
> Jim Lemon 
> on Thu, 2 Jun 2016 13:03:01 +1000 writes:

> Hi ce,

> a<-10
> condition<-expression("a>0")
> if(eval(parse(text=condition))) cat("a>0\n")

While this may answer the question asked,
the above is *not* good advice, excuse me, Jim :

> fortune(106)

If the answer is parse() you should usually rethink the question.
   -- Thomas Lumley
  R-help (February 2005)

> fortune(181)

Personally I have never regretted trying not to underestimate my own future 
stupidity.
   -- Greg Snow (explaining why eval(parse(...)) is often suboptimal, answering 
a question
  triggered by the infamous fortune(106))
  R-help (January 2007)

-

Good advice would emphasize to use  expressions rather than
strings and yes that's a bit more sophistication.

But it's worth it.
Martin


> 
> Jim

> On Thu, Jun 2, 2016 at 12:30 PM, ce  wrote:
>> 
>> Dear all,
>> 
>> I want to make an if condition variable like :
>> 
>> a = 10
>> CONDITION = " a > 0 "
>> 
>> if ( CONDITION ) print(" a is bigger" )
>> 
>> I tried get , getElement , eval without success ?
>> 
>> Thanks
>> 
>> __
>> 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] Unable to update R software to 3.3.0

2016-06-02 Thread Loris Bennett
Loris Bennett  writes:

> Hi Sunish,
>
> Sunish Kumar Bilandi  writes:
>
>> Hi Team,
>>
>> I am using RedHat 5 and installed R using YUM, (R version 3.2.3) Now I
>> want to update R version tp 3.3.0, but I am unable to do that, Is
>> there any alternate to do this?
>>
>> Hope to hear from your side.
>>
>> Regards,
>>
>>
>> Sunish Bilandi
>> Business Analyst, CIDA-01
>> Evalueserve
>
> You don't say what the problem is, but I'm running Scientific Linux 6.7,
> which is based on the corresponding version of Red Hat, and have found
> that I cannot install R 3.3.0, because the version of zlib available is
> too old.  R 3.3.0 requires zlib >= 1.2.5, whereas the version in the SL
> repositories is 1.2.3.
>
> So if this is the problem, then you either have to install newer version
> of zlib from source or switch to RH7, which comes with zlib 1.2.7.

I forgot to say that for RH7, R 3.3.0 is available from the EPEL
repository, whereas for RH5 or RH6 you will have to install R from
source.

Cheers,

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
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] Unable to update R software to 3.3.0

2016-06-02 Thread Loris Bennett
Hi Sunish,

Sunish Kumar Bilandi  writes:

> Hi Team,
>
> I am using RedHat 5 and installed R using YUM, (R version 3.2.3) Now I
> want to update R version tp 3.3.0, but I am unable to do that, Is
> there any alternate to do this?
>
> Hope to hear from your side.
>
> Regards,
>
>
> Sunish Bilandi
> Business Analyst, CIDA-01
> Evalueserve

You don't say what the problem is, but I'm running Scientific Linux 6.7,
which is based on the corresponding version of Red Hat, and have found
that I cannot install R 3.3.0, because the version of zlib available is
too old.  R 3.3.0 requires zlib >= 1.2.5, whereas the version in the SL
repositories is 1.2.3.

So if this is the problem, then you either have to install newer version
of zlib from source or switch to RH7, which comes with zlib 1.2.7.

Cheers,

Loris

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin Email loris.benn...@fu-berlin.de

__
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] httr package syntax (PUT)

2016-06-02 Thread Jared Rodecker
Greetings fellow R users.

I'm struggling with the syntax of submitting a PUT request

I'm trying to insert a few PUT requests into some legacy R code that I have
that performs daily ETL on a small database. These requests will add users
to an email mailing list in MailChimp.


I have been able to get my GET requests formatted into syntax that R
(specifically the httr package) accepts:

GET("
https://us10.api.mailchimp.com/3.0/lists/list_id_X/members/MEMBER_HASH_###;,
query = list(apikey = 'XX'))


However when I try to do something similar for PUT requests this simple
syntax isn't working - you can't just pass the API KEY and/or requested
parameters directly through the URL. I get a 401 error if I use the same
syntax I used for GET.


I believe that I need to use the CONFIG option to pass the API key (either
using AUTHENTICATE or ADD_HEADERS) and the requested parameters in the BODY
to get the PUT request to work but I can't get the syntax to work - this
gives a 400 error:


auth <- authenticate("anystring", "XX", type = "basic")

parms <- '[{"email_address" : "some_u...@domain.com", "status_if_new" :
"subscribed"}]'

PUT("
https://us10.api.mailchimp.com/3.0/lists/list_id_X/members/MEMBER_HASH_###
",config=auth,body=parms,encode="json")


If anyone can point me to a more flushed out example that would be
amazing...but even just some tips on how to get more info on my error
message to help me troubleshoot my syntax would also be a big help.  I've
also been trying to get httpput (from the RCurl package) but also
struggling with the syntax there.


Thanks!


Jared

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