Re: [R] Simple control structure issue

2017-06-23 Thread Michael Ashton
SONOFAGUN…I’m a bit embarrassed. Thanks Bill!

From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Friday, June 23, 2017 6:15 PM
To: Michael Ashton
Cc: r-help@r-project.org
Subject: Re: [R] Simple control structure issue

R is a case-sensitive language: 'if' (lowercase 'i') is a keyword and 'If' 
(uppercase 'I') is not.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jun 23, 2017 at 1:00 PM, Michael Ashton 
mailto:m.ash...@enduringinvestments.com>> 
wrote:
I am having a hard time with 'next'. I come from the "sloppy" school that 
learned BASIC with Goto.

Conceptually next seems pretty straightforward. I just can't get it to work 
correctly in my code. Here's a stripped down version:

WhichRunNow<-"Daily"
Cnums=c(0,1,"2b3")
Cpers=c("Daily","Daily","Weekly")

for (j in (1:length(Cnums))) {
 If (!identical(Cpers[j],WhichRunNow)){
   next
   }
 print(j)
}

So, this should print the number "3", which it does. It prints 3 because 
"WhichRunNow" is "Daily", and only for j=3 is Cpers[j] not identical to 
"Daily". But R seems very unhappy with how it gets there:

> WhichRunNow<-"Daily"
> Cnums=c(0,1,"2b3")
> Cpers=c("Daily","Daily","Weekly")
>
> for (j in (1:length(Cnums))) {
+ If (!identical(Cpers[j],WhichRunNow)){
Error: unexpected '{' in:
"for (j in (1:length(Cnums))) {
If (!identical(Cpers[j],WhichRunNow)){"
> next
Error: no loop for break/next, jumping to top level
> }
Error: unexpected '}' in "}"
> print(j)
[1] 3
> }
Error: unexpected '}' in "}"
>

Obviously something with my syntax, but I can't see what I'm doing wrong!


[[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] Simple control structure issue

2017-06-23 Thread William Dunlap via R-help
R is a case-sensitive language: 'if' (lowercase 'i') is a keyword and 'If'
(uppercase 'I') is not.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jun 23, 2017 at 1:00 PM, Michael Ashton <
m.ash...@enduringinvestments.com> wrote:

> I am having a hard time with 'next'. I come from the "sloppy" school that
> learned BASIC with Goto.
>
> Conceptually next seems pretty straightforward. I just can't get it to
> work correctly in my code. Here's a stripped down version:
>
> WhichRunNow<-"Daily"
> Cnums=c(0,1,"2b3")
> Cpers=c("Daily","Daily","Weekly")
>
> for (j in (1:length(Cnums))) {
>  If (!identical(Cpers[j],WhichRunNow)){
>next
>}
>  print(j)
> }
>
> So, this should print the number "3", which it does. It prints 3 because
> "WhichRunNow" is "Daily", and only for j=3 is Cpers[j] not identical to
> "Daily". But R seems very unhappy with how it gets there:
>
> > WhichRunNow<-"Daily"
> > Cnums=c(0,1,"2b3")
> > Cpers=c("Daily","Daily","Weekly")
> >
> > for (j in (1:length(Cnums))) {
> + If (!identical(Cpers[j],WhichRunNow)){
> Error: unexpected '{' in:
> "for (j in (1:length(Cnums))) {
> If (!identical(Cpers[j],WhichRunNow)){"
> > next
> Error: no loop for break/next, jumping to top level
> > }
> Error: unexpected '}' in "}"
> > print(j)
> [1] 3
> > }
> Error: unexpected '}' in "}"
> >
>
> Obviously something with my syntax, but I can't see what I'm doing wrong!
>
>
> [[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] Simple control structure issue

2017-06-23 Thread Michael Ashton
I am having a hard time with 'next'. I come from the "sloppy" school that 
learned BASIC with Goto.

Conceptually next seems pretty straightforward. I just can't get it to work 
correctly in my code. Here's a stripped down version:

WhichRunNow<-"Daily"
Cnums=c(0,1,"2b3")
Cpers=c("Daily","Daily","Weekly")

for (j in (1:length(Cnums))) {
 If (!identical(Cpers[j],WhichRunNow)){
   next
   }
 print(j)
}

So, this should print the number "3", which it does. It prints 3 because 
"WhichRunNow" is "Daily", and only for j=3 is Cpers[j] not identical to 
"Daily". But R seems very unhappy with how it gets there:

> WhichRunNow<-"Daily"
> Cnums=c(0,1,"2b3")
> Cpers=c("Daily","Daily","Weekly")
>
> for (j in (1:length(Cnums))) {
+ If (!identical(Cpers[j],WhichRunNow)){
Error: unexpected '{' in:
"for (j in (1:length(Cnums))) {
If (!identical(Cpers[j],WhichRunNow)){"
> next
Error: no loop for break/next, jumping to top level
> }
Error: unexpected '}' in "}"
> print(j)
[1] 3
> }
Error: unexpected '}' in "}"
>

Obviously something with my syntax, but I can't see what I'm doing wrong!


[[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] Comparing pooled proportions(complication and reoperation rates) of different treatment modalities

2017-06-23 Thread Jay Zola
Dear sir/madame,


Currently I am writing a meta analysis on complications and reoperations of 5 
treatment modalities after an extra-articular distal radius fracture. The 
treatment modalities are EF, IMN, KW, VPO and PC as the golden standard. We 
have included 22 studies, 10 RCTs and 12 prospective studies. All examining 
different treatment methods. We retrieved the data out of these studies and 
pooled the complication and reoperation rates(n/N). Now we want to compare the 
pooled proportion of each treatment modality to the golden standard of 
PC(plaster casting). So I want to do 4 separate comparisons using the chi 
squared method. I looked it up online and at the meta package guide(meta is the 
package I used), but wasn't able to find useful information. I first posted my 
question onto the stats.stackexchange website but was redirected to the mailing 
list of r-help. I have added a picture of the most important parts of the code 
(not the egger's regression, funnel, trim and fill and outcome.pdf parts of 
 it because it didn't fit). I have added the data in excel and spss file to my 
dropbox, and added the complete Rcode to a Word file in my dropbox as well. The 
links below will refer you to them as preferred by the posting guide. Hopefully 
someone can help me.


Thank you very much.



Excel datafile: 
https://www.dropbox.com/s/19402gt0x1agt9f/Excel%20file%20Distal%20Radius%20Fracture%20basic.xlsx?dl=0

Excel file Distal Radius Fracture 
basic.xlsx
www.dropbox.com
Shared with Dropbox



SPSS datafile: 
https://www.dropbox.com/s/h81pphxkfk74hzo/Meta-Analyse%20Complications%20and%20Reoperations.sav?dl=0

[https://cfl.dropboxstatic.com/static/images/icons128/page_white.png]

Meta-Analyse Complications and 
Reoperations.sav
www.dropbox.com
Shared with Dropbox


Rcode file Word: 
https://www.dropbox.com/s/67pnfpi10qu110v/R%20code%20voor%20forrest%20en%20funnel%20plots.rtf?dl=0

[https://cfl.dropboxstatic.com/static/images/icons128/page_white_word.png]

R code voor forrest en funnel 
plots.rtf
www.dropbox.com
Shared with Dropbox





https://stats.stackexchange.com/questions/286920/comparing-pooled-propotions-using-r-for-a-meta-analysis

[https://cdn.sstatic.net/Sites/stats/img/apple-touch-i...@2.png?v=344f57aa10cc]

Comparing pooled propotions using R for a 
meta-analysis
stats.stackexchange.com
For a meta-analysis I have pooled single proportions(complication rates) of 
several treatment methods. Now I would like to compare them(the 4 treatment 
modalities separately with the golden standar...








Van: David Winsemius 
Verzonden: vrijdag 23 juni 2017 20:18
Aan: Jay Zola
CC: r-help@r-project.org
Onderwerp: Re: [R] Comparing pooled proportions(complication and reoperation 
rates) of different treatment modalities


> On Jun 23, 2017, at 5:53 AM, Jay Zola  wrote:
>
> Dear sir/madame,
>
>
> I am currently writing a meta-analysis on the complication and reoperation 
> rates of 5 different treatment modalities after a distal radius fracture. I 
> was able to pool the rates of the 5 different rates using R. Now I have to 
> compare the pooled rates of the 4 treatment modalities with the golden 
> standard separately. I though the chi squared test would be the best method. 
> How do I do that using r. The R code I have used for the former calculation 
> are added as a Word-file attachment.

Not an acceptable format to the listserv program. Policy is set by the host 
institution. Use plain text.

> Your help would be highly appreciated.
>
>
> Yours sincerely,
>
>
> Student
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help


thz.ch/mailman/listinfo/r-help>
stat.ethz.ch
The main R mailing list, for announcements about the development of R and the 
availability of new code, questions and answers about problems and solutions 
using R ...



> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSC

Re: [R] Comparing pooled proportions(complication and reoperation rates) of different treatment modalities

2017-06-23 Thread Bert Gunter
1. You neglected to cc r-help!

2. Word files are **not** text files.


-- 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 Fri, Jun 23, 2017 at 12:23 PM, Jay Zola  wrote:

> Dear sir,
>
>
> This is the link of the page were I asked my question initially before I
> was redirected to the r-help mailing list. Hopefully someone can help me
> with my question. I read the guideline on not posting binary files and
> therefore taught it was ok to send text files like word files. I do
> apologize.
>
>
> Yours sincerely,
>
>
> Anand
>
>
>
> https://stats.stackexchange.com/questions/286920/
> comparing-pooled-propotions-using-r-for-a-meta-analysis
>
>
> 
> Comparing pooled propotions using R for a meta-analysis
> 
> stats.stackexchange.com
> For a meta-analysis I have pooled single proportions(complication rates)
> of several treatment methods. Now I would like to compare them(the 4
> treatment modalities separately with the golden standar...
>
>
>
>
>
> --
> *Van:* Bert Gunter 
> *Verzonden:* vrijdag 23 juni 2017 20:51
> *Aan:* Jay Zola
> *Onderwerp:* Re: [R] Comparing pooled proportions(complication and
> reoperation rates) of different treatment modalities
>
> Then you will have to at least read and follow the posting guide,
> which you have not done. As you have been told, your current post is
> unacceptable.
>
> -- 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 Fri, Jun 23, 2017 at 11:41 AM, Jay Zola  wrote:
> > Dear sir,
> >
> > I have posted it on stats.stackexchange. But got the answer to post it
> on this place. I added my question to r-help before it was posted later in
> the evening. Somebody checked the question and taught it was appropriate
> for r-help. Your help would be highly appreciated. And Thank you for your
> fast reply.
> >
> > Yours sincerely,
> >
> > Jay
> >
> >
>

[[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] Comparing pooled proportions(complication and reoperation rates) of different treatment modalities

2017-06-23 Thread Bert Gunter
Probably the wrong list. R-help is concerned with R programming, not
statistics methodology questions, although the intersection can be
nonempty.

I suggest you post on stats.stackexchange.com instead, which *is*
concerned with statistics methodology questions.


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 Fri, Jun 23, 2017 at 5:53 AM, Jay Zola  wrote:
> Dear sir/madame,
>
>
> I am currently writing a meta-analysis on the complication and reoperation 
> rates of 5 different treatment modalities after a distal radius fracture. I 
> was able to pool the rates of the 5 different rates using R. Now I have to 
> compare the pooled rates of the 4 treatment modalities with the golden 
> standard separately. I though the chi squared test would be the best method. 
> How do I do that using r. The R code I have used for the former calculation 
> are added as a Word-file attachment. Your help would be highly appreciated.
>
>
> Yours sincerely,
>
>
> Student
> __
> 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] DEA: BCC input oriented

2017-06-23 Thread Leslie, Lewis
Dear R users,

If anyone could give me a hand coding some airline finance data that I want to 
do a DEA on using a BCC input oriented primal code that would be much 
appreciated.

Kind regards,

Lewis Leslie

Get Outlook for iOS

[[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] MODISTools Help

2017-06-23 Thread Caroline
In case anyone else experiences the same error: 

The package creators responded and the issue was that I was using time frames 
between 14-30 days. EVI and NDVI are only calculated every 16 days so using 
that time span entailed that there was only one pixel per observation. I 
expanded my timeframe to 32 days and my analysis now works. 

I.E. changed: 

firstobs$start.date <- firstobs[,2] - as.difftime(14, unit='days') ###time 
frame now spands two weeks 

To 

firstobs$start.date <- firstobs[,2] - as.difftime(32, unit='days') ###time 
frame now stands 32 days 

Where first obs is the data set that contains the date that the data was 
collected, latitude, and longitude of collection site from one observation. I 
used the date the data was collected as the end date and transformed the date 
the data was collected to 32 days prior as the start date. 

firstobs before transformation: 

 idstart.date  end.date   latlong 
B1-1108  28-Nov-08 28-Nov-08 -25.07324 31.936 

firstobs after transformation 

 id  start.date end.date   lat  long 
B1-1108 2008-10-27 2008-11-28 -25.07324 31.936 
> On Jun 23, 2017, at 8:49 AM, Robert Baer  wrote:
> 
> 
> 
> On 6/22/2017 7:05 PM, Caroline wrote:
>> ##MODISTools example
>> library(MODISTools)
>> library(lubridate)
>> setwd('~/Documents/Modis data')
>> 
>> #MODISTools with buffalo data
>> 
>> ###Read in data rename for easier coding
>> tbdata <- read.csv('~/Desktop/All TB data for EVI, NDVI.csv')
> Since this dataset is only on your desktop it cannot help us reproduce your 
> error.  Can you supply a small dataset that cause the
> error you are talking about?
> 
> One way to do this is to use supply the results of
> dput(tbdata)
> if it is small enough.  If not, maybe create a subset of the data and then 
> use dput()
> 
> Did you get the problem when you tried with the tutorial Bert suggested?
>> firstobs <- subset(tbdata, capture.ID == 'B1-1108')
>> firstobs <- firstobs[,c(1,2,2,3,4)]
>> colnames(firstobs) <- c('id', 'start.date','end.date','lat','long')
>> 
>> ###change date format and change start date to previous 14 days
>> firstobs$start.date <- dmy(firstobs$start.date)
>> firstobs$end.date <- dmy(firstobs$end.date)
>> firstobs$start.date <- firstobs[,2] - as.difftime(14, unit='days') ###time 
>> frame now spands two weeks
>> 
>> ###define parameters
>> product <- "MOD13Q1"
>> bands <- c('250m_16_days_EVI', '250m_16_days_NDVI', 
>> '250m_16_days_VI_Quality')
>> pixel <- c(0,0)
>> 
>> ###define data
>> period <- data.frame(lat=firstobs$lat, long=firstobs$long, start.date 
>> =firstobs$start.date, end.date = firstobs$end.date, id=firstobs$id)
>> 
>> 
>> ###MODISSubsets
>> MODISSubsets(LoadDat = period, Products = product, Bands=bands, Size=pixel, 
>> SaveDir='.', StartDate=T)
>> 
>> 
>> ###MODISSummaries
>> MODISSummaries(LoadDat = period, FileSep=',',Product='MOD13Q1', Bands = 
>> '250m_16_days_EVI', ValidRange=c(-2000,1), NoDataFill=-3000, ScaleFactor 
>> = 0.0001, StartDate = TRUE, Interpolate = T, QualityScreen = TRUE, 
>> QualityThreshold = 0, QualityBand = '250m_16_days_VI_Quality')
>> 
>> 
>>> On Jun 22, 2017, at 4:50 PM, Bert Gunter  wrote:
>>> 
>>> 1. You should always cc the list unless there is a clear reason not to.
>>> 
>>> 2. You still have failed to follow the posting guide: You say you have
>>> difficulty troubleshooting your code, but you have shown us no code.
>>> You got an error message that seems explicit, but with neither code
>>> nor data, I do not know whether anyone can make sense of it. In any
>>> case, I certainly cannot.
>>> 
>>> 
>>> 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 22, 2017 at 4:41 PM, Caroline
>>>  wrote:
 Hi Bert,
 
 I have spent a lot of time searching the web for my error message and have 
 gone through multiple tutorials. I have not found anything relevant to my 
 error message which is why I posted on R-help.
 
 Caroline
 
> On Jun 22, 2017, at 4:38 PM, Bert Gunter  wrote:
> 
> This is a specialized package that fairly few of us are likely to have
> familiarity with, especialy when you have not followed the posting
> guide (below) and posted code and a reproducible example.
> 
> That said, a web search on R MODIS appeared to bring up relevant hits,
> including a MODIS tutorial. Have you tried that?
> 
> 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 22, 2017 at 2:12 PM, Caroline
>  wrote:
>> I am using MODIS Tools and am having a lot of difficulty troubleshoot

Re: [R] Missing dependencies in pkg installs

2017-06-23 Thread Conklin, Mike (GfK)
Checked all the permissions, and it appears that file_test returns a FALSE and 
system(ls -l) shows it is executable, so the problem seems to be in R and it's 
relationship to RHEL.  I tried installing R3.3.3 to see if the older version 
would install stringi and had the same problem so it doesn't appear to be R3.4 
related.  I am now reaching out to some other sources who may have installed R 
on similar systems.



From: Conklin, Mike (GfK)
Sent: Friday, June 23, 2017 8:50 AM
To: Don Cohen; Duncan Murdoch
Cc: Martin Maechler; r-help@r-project.org
Subject: RE: [R] Missing dependencies in pkg installs

I had the same thought in the shower this morning but I was disappointed to 
find that SElinux was disabled on the system.  My next step will be to install 
a previous version of R on the system.  My problem is that I am planning a 
shiny server installation and at least half of the apps on the current system 
depend on these libraries that will not install.
--
W. Michael Conklin
EVP Marketing & Data Sciences
GfK
T +1 763 417 4545 | M +1 612 567 8287

-Original Message-
From: Don Cohen [mailto:don-r-h...@isis.cs3-inc.com]
Sent: Thursday, June 22, 2017 6:18 PM
To: Duncan Murdoch
Cc: Conklin, Mike (GfK); Martin Maechler; r-help@r-project.org
Subject: Re: [R] Missing dependencies in pkg installs

Duncan Murdoch writes:
 > On 22/06/2017 5:02 PM, Conklin, Mike (GfK) wrote:
 > > I am using debug on the .install_packages function...stepping through. 
 > > Once the temporary folder is created and the tar file expanded I run 
 > > file_test and get a FALSE back indicating that the configure file is not 
 > > executable.
 >
 > I don't know what is causing this bug.  Perhaps a Linux user can  > 
 > reproduce it and fix it.
 >
 > Here's what I see:
 >
 > file_test("-x") calls file.access(filename, 1L).  That in turn calls the  > 
 > C library function access(..., X_OK).  The ... is the name of the file,  > 
 > translated into the local encoding and expanded.  As far as I can see,  > 
 > that means ... should be exactly the string below.
 > >
 > > [1] "/tmp/RtmpMM6iC1/R.INSTALLc5ca415e4310/stringi"
 >
 > The only thing I can think of is that your system is protecting you from  > 
 > executing a newly created file until some sort of virus or other check  > is 
 > done.  (This is common on Windows, but I've never heard of it before  > on 
 > Linux.)

Just a thought - are you running SELinux ?
Check the log files for refusals to run programs.

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


Re: [R] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Rathore, Saubhagya Singh
Thank you very much Mr. Gunter for making me realize the power vectorization. I 
need to work lot more to exploit this strength of R. I applied your suggested 
method to my problem where D1 and D2 has 600 observations each. The time was 
significant reduced compared to the fasted working code I had (user:61, system: 
0.01 ,  elapsed: 0.62).

Thank you again for your generous help. 
Saubhagya
  
-Original Message-
From: Bert Gunter [mailto:bgunter.4...@gmail.com] 
Sent: Friday, June 23, 2017 3:20 PM
To: Rathore, Saubhagya Singh 
Cc: r-help@r-project.org
Subject: Re: [R] R version 3.3.2, Windows 10: Applying a function to each 
possible pair of rows from two different data-frames

You appear to be trying to write C code in R. Don't do this. If you can trade 
off space for efficiency, the calculation can be easily vectorized (assuming I 
correctly understand what you want to do, of course).

set.seed(135) ## for reproducibility
D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))

D.all <-merge(D1,D2, by.x=NULL,by.y=NULL) ## Cartesian product of the two frames

D.all$distance <- sqrt(rowSums((D.all[,1:2] - D.all[,4:5])^2)) ## note use of 
rowSums D.all$difference <- (D.all[,3] - D.all[,6])^2

D.all



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 Fri, Jun 23, 2017 at 8:19 AM, Rathore, Saubhagya Singh 
 wrote:
> For certain reason, the content was not visible in the last mail, so posting 
> it again.
>
> Dear Members,
>
> I have two different dataframes with a different number of rows. I need to 
> apply a set of functions to each possible combination of rows with one row 
> coming from 1st dataframe and other from 2nd dataframe. Though I am able to 
> perform this task using for loops, I feel that there must be a more efficient 
> way to do it. An example case is given below. D1 and D2 are two dataframes. I 
> need to evaluate D3 with one column as the Euclidean distance in the x-y 
> plane and second column as squared difference of z values, of each row pair 
> from D1 and D2.
>
> D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
> D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
> D3<-data.frame(distance=integer(0),difference=integer(0))
>
> for (i in 1:nrow(D1)){
>
> for (j in 1:nrow(D2))  {
>
> temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),differenc
> e=(D1[i,3]-D2[j,3])^2)
> D3<-rbind(D3,temp)
> }
> }
>
> Thank you
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
> r-help-ow...@r-project.org
> Sent: Friday, June 23, 2017 10:47 AM
> To: Rathore, Saubhagya Singh 
> Subject: R version 3.3.2, Windows 10: Applying a function to each 
> possible pair of rows from two different data-frames
>
> The message's content type was not explicitly allowed
>
> __
> 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] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Rathore, Saubhagya Singh
Thank you very much Mr. Barradas for your suggestions. I feel embarrassed for 
not pre-allocating D3. Just pre-allocating D3 significantly reduced my run-time 
for code. My actual problem has both D1 and D2 consisting of 600 observations 
each.  Your second suggestion of using do.call proved to be better than using 
nested for loops. The run-times for my problem from both the methods are 
presented below.

1) Nested Loop with pre-allocation: 
#user  system elapsed 
# 1199.89   14.08 1215.75

2) expand.grid- do.cal
# user  system elapsed 
# 131.560.00  131.61

Thank you again for your generous help.

-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt] 
Sent: Friday, June 23, 2017 12:03 PM
To: Rathore, Saubhagya Singh ; 
r-help-ow...@r-project.org; r-help@r-project.org
Subject: Re: [R] R version 3.3.2, Windows 10: Applying a function to each 
possible pair of rows from two different data-frames

Hello,

Another way would be

n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2)))
D5 <- data.frame(distance=integer(n),difference=integer(n))

D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) 
t(sapply(seq_len(nrow(D2)), function(j){
 
c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)
}


identical(D3, D5)


In my first answer I forgot to say that constructs like 1:nrow(...) or more 
generally 1:m are error prone. If m == 0 you will have the perfectly legal loop 
for(i in 1:0) but an illegal zero index.
The solution is to use ?seq_len or ?seq_along (same help page). Like
this: for(i in seq_len(m)). In your case m is either nrow(D1) or nrow(D2).

Hope this helps,

Rui Barradas



Em 23-06-2017 16:35, Rui Barradas escreveu:
> Hello,
>
> The obvious way would be to preallocate the resulting data.frame, to 
> expand an empty one on each iteration being a time expensive operation.
>
> n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2)))
> D4 <- data.frame(distance=integer(n),difference=integer(n))
> k <- 0
> for (i in 1:nrow(D1)){
>  for (j in 1:nrow(D2))  {
>  k <- k + 1
>  D4[k, ] <-
> c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j
> ,3])^2)
>
>  }
> }
>
> identical(D3, D4)
>
> Hope this helps,
>
> Rui Barradas
>
> Em 23-06-2017 16:19, Rathore, Saubhagya Singh escreveu:
>> For certain reason, the content was not visible in the last mail, so 
>> posting it again.
>>
>> Dear Members,
>>
>> I have two different dataframes with a different number of rows. I 
>> need to apply a set of functions to each possible combination of rows 
>> with one row coming from 1st dataframe and other from 2nd dataframe.
>> Though I am able to perform this task using for loops, I feel that 
>> there must be a more efficient way to do it. An example case is given 
>> below. D1 and D2 are two dataframes. I need to evaluate D3 with one 
>> column as the Euclidean distance in the x-y plane and second column 
>> as squared difference of z values, of each row pair from D1 and D2.
>>
>> D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
>> D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
>> D3<-data.frame(distance=integer(0),difference=integer(0))
>>
>> for (i in 1:nrow(D1)){
>>
>> for (j in 1:nrow(D2))  {
>>
>> temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),differen
>> ce=(D1[i,3]-D2[j,3])^2)
>>
>> D3<-rbind(D3,temp)
>> }
>> }
>>
>> Thank you
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
>> r-help-ow...@r-project.org
>> Sent: Friday, June 23, 2017 10:47 AM
>> To: Rathore, Saubhagya Singh 
>> Subject: R version 3.3.2, Windows 10: Applying a function to each 
>> possible pair of rows from two different data-frames
>>
>> The message's content type was not explicitly allowed
>>
>> __
>> 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] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Bert Gunter
You appear to be trying to write C code in R. Don't do this. If you
can trade off space for efficiency, the calculation can be easily
vectorized (assuming I correctly understand what you want to do, of
course).

set.seed(135) ## for reproducibility
D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))

D.all <-merge(D1,D2, by.x=NULL,by.y=NULL) ## Cartesian product of the two frames

D.all$distance <- sqrt(rowSums((D.all[,1:2] - D.all[,4:5])^2)) ## note
use of rowSums
D.all$difference <- (D.all[,3] - D.all[,6])^2

D.all



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 Fri, Jun 23, 2017 at 8:19 AM, Rathore, Saubhagya Singh
 wrote:
> For certain reason, the content was not visible in the last mail, so posting 
> it again.
>
> Dear Members,
>
> I have two different dataframes with a different number of rows. I need to 
> apply a set of functions to each possible combination of rows with one row 
> coming from 1st dataframe and other from 2nd dataframe. Though I am able to 
> perform this task using for loops, I feel that there must be a more efficient 
> way to do it. An example case is given below. D1 and D2 are two dataframes. I 
> need to evaluate D3 with one column as the Euclidean distance in the x-y 
> plane and second column as squared difference of z values, of each row pair 
> from D1 and D2.
>
> D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
> D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
> D3<-data.frame(distance=integer(0),difference=integer(0))
>
> for (i in 1:nrow(D1)){
>
> for (j in 1:nrow(D2))  {
>
> temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)
> D3<-rbind(D3,temp)
> }
> }
>
> Thank you
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
> r-help-ow...@r-project.org
> Sent: Friday, June 23, 2017 10:47 AM
> To: Rathore, Saubhagya Singh 
> Subject: R version 3.3.2, Windows 10: Applying a function to each possible 
> pair of rows from two different data-frames
>
> The message's content type was not explicitly allowed
>
> __
> 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] Piecewise continuous logistic regression with one knot

2017-06-23 Thread Bert Gunter
A quick web search on "piecewise regression R" immediately brought up
(the fairly well known) package "segmented" which fits segmented
glm's.


-- 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 Fri, Jun 23, 2017 at 4:06 AM, Sorkin, John  wrote:
> How can I fit a piecewise continuous logistic regression with a single free 
> knot (i.e. the knot is not specified; the model produce an estimate of the 
> value of the knot).
>
>
> Thank you,
>
> John
>
>
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
>
>
> [[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] Comparing pooled proportions(complication and reoperation rates) of different treatment modalities

2017-06-23 Thread David Winsemius

> On Jun 23, 2017, at 5:53 AM, Jay Zola  wrote:
> 
> Dear sir/madame,
> 
> 
> I am currently writing a meta-analysis on the complication and reoperation 
> rates of 5 different treatment modalities after a distal radius fracture. I 
> was able to pool the rates of the 5 different rates using R. Now I have to 
> compare the pooled rates of the 4 treatment modalities with the golden 
> standard separately. I though the chi squared test would be the best method. 
> How do I do that using r. The R code I have used for the former calculation 
> are added as a Word-file attachment.

Not an acceptable format to the listserv program. Policy is set by the host 
institution. Use plain text.

> Your help would be highly appreciated.
> 
> 
> Yours sincerely,
> 
> 
> Student
> __
> 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.

David Winsemius
Alameda, CA, USA

__
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] Comparing pooled proportions(complication and reoperation rates) of different treatment modalities

2017-06-23 Thread Jay Zola
Dear sir/madame,


I am currently writing a meta-analysis on the complication and reoperation 
rates of 5 different treatment modalities after a distal radius fracture. I was 
able to pool the rates of the 5 different rates using R. Now I have to compare 
the pooled rates of the 4 treatment modalities with the golden standard 
separately. I though the chi squared test would be the best method. How do I do 
that using r. The R code I have used for the former calculation are added as a 
Word-file attachment. Your help would be highly appreciated.


Yours sincerely,


Student
__
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] Piecewise continuous logistic regression with one knot

2017-06-23 Thread Sorkin, John
How can I fit a piecewise continuous logistic regression with a single free 
knot (i.e. the knot is not specified; the model produce an estimate of the 
value of the knot).


Thank you,

John




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


[[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] Paired Weighted Wilcoxon test in R

2017-06-23 Thread Dreams Collector
Dear R-users,

I’m trying to perform a non-parametric statistical pairwise comparison of two 
samples "x" and "y" using the Wilcoxon test in R, but each of the pairs have a 
weight associated.

An example of my data is the following one:

set.seed(9)
x <- sample(x = c(1:100), size = 20, replace = TRUE)
y <- sample(x = c(1:100), size = 20, replace = TRUE)
weight <- runif(n = 20)
data <- data.frame(x = x, y = y, weight = weight)

I’m new with statistical tests. I’ve read this other post about a similar issue:

http://r.789695.n4.nabble.com/Weighted-Mann-Whitney-Wilcoxon-Test-td4695699.html
 


But I’m not sure if I can use the packages/works cited there.

Any help/comment would be fantastic for me.

Thank you!
[[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] [R-pkgs] New R package on CRAN: sfadv (v 1.0.1)

2017-06-23 Thread Yann Desjeux

Dear R users,


I am happy to announce that the R package 'sfadv: Advanced Methods for 
Stochastic Frontier Analysis' is now available on CRAN 
(https://CRAN.R-project.org/package=sfadv).


This package allows stochastic frontier analysis with advanced methods.
Particularly it implements newly developped method proposed by Latruffe 
et al. (2017)  considering stochastic frontier 
analysis with technical inefficiency effects and endogeneity of one input.


Best regards,

Yann

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/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] optim() has a non-consistent way to send parameter for different methods

2017-06-23 Thread Marc Girondot via R-help
When optim() is used with method="BFGS", the name of parameters within 
the vector are transmitted (see below, first example).


When method="Brent", the name of parameter (only one parameter can be 
fitted with Brent method) is not transmitted. As there is only one, of 
course, we know which parameter it is, but it makes things 
non-consistent between methods.


It would be better that same convention is used for different method.

Marc

Tested in R-3.4.0

For example, here:

@@@
Method BFGS
@@@

# The names of values in par are transmitted
fitnorm_meansd<-function(par, val) {
  print(par)
  -sum(dnorm(x=val, mean=par["mean"], sd=par["sd"], log = TRUE))
}

val <- rnorm(100, mean=20, sd=2)
p<-c(mean=20, sd=2)
result<-optim(par=p, fn=fitnorm_meansd, val=val, method="BFGS")

The print(par) shows the named vector:
> result<-optim(par=p, fn=fitnorm_meansd, val=val, method="BFGS")
mean   sd
  202
  mean sd
20.001  2.000
  mean sd
19.999  2.000
  mean sd
20.000  2.001
etc...

@@@
Method Brent
@@@

# The name of value in par is not transmitted

fitnorm_mean<-function(par, val) {
  print(par)
  -sum(dnorm(x=val, mean=par, sd=2, log = TRUE))
}

val <- rnorm(100, mean=20, sd=2)
p<-c(mean=20)
result<-optim(par=p, fn=fitnorm_mean, val=val, method="Brent", lower=10, 
upper=30)



The print(par) does not show named vector:
> result<-optim(par=p, fn=fitnorm_mean, val=val, method="Brent", 
lower=10, upper=30)

[1] 17.63932
[1] 22.36068

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


Re: [R] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Rui Barradas

Hello,

Another way would be

n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2)))
D5 <- data.frame(distance=integer(n),difference=integer(n))

D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) 
t(sapply(seq_len(nrow(D2)), function(j){
	 
c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)

}


identical(D3, D5)


In my first answer I forgot to say that constructs like 1:nrow(...) or 
more generally 1:m are error prone. If m == 0 you will have the 
perfectly legal loop for(i in 1:0) but an illegal zero index.
The solution is to use ?seq_len or ?seq_along (same help page). Like 
this: for(i in seq_len(m)). In your case m is either nrow(D1) or nrow(D2).


Hope this helps,

Rui Barradas



Em 23-06-2017 16:35, Rui Barradas escreveu:

Hello,

The obvious way would be to preallocate the resulting data.frame, to
expand an empty one on each iteration being a time expensive operation.

n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2)))
D4 <- data.frame(distance=integer(n),difference=integer(n))
k <- 0
for (i in 1:nrow(D1)){
 for (j in 1:nrow(D2))  {
 k <- k + 1
 D4[k, ] <-
c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)

 }
}

identical(D3, D4)

Hope this helps,

Rui Barradas

Em 23-06-2017 16:19, Rathore, Saubhagya Singh escreveu:

For certain reason, the content was not visible in the last mail, so
posting it again.

Dear Members,

I have two different dataframes with a different number of rows. I
need to apply a set of functions to each possible combination of rows
with one row coming from 1st dataframe and other from 2nd dataframe.
Though I am able to perform this task using for loops, I feel that
there must be a more efficient way to do it. An example case is given
below. D1 and D2 are two dataframes. I need to evaluate D3 with one
column as the Euclidean distance in the x-y plane and second column as
squared difference of z values, of each row pair from D1 and D2.

D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
D3<-data.frame(distance=integer(0),difference=integer(0))

for (i in 1:nrow(D1)){

for (j in 1:nrow(D2))  {

temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)

D3<-rbind(D3,temp)
}
}

Thank you

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
r-help-ow...@r-project.org
Sent: Friday, June 23, 2017 10:47 AM
To: Rathore, Saubhagya Singh 
Subject: R version 3.3.2, Windows 10: Applying a function to each
possible pair of rows from two different data-frames

The message's content type was not explicitly allowed

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



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


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


[R] R and Paraview

2017-06-23 Thread Erin Hodgess
Hello!

Are there any packages in R that work with the visualization tool Paraview,
please?  I looked via Google and couldn't find any but wanted to double
check before I started work on such a thing.

Thanks,
Erin


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

[[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] MODISTools Help

2017-06-23 Thread Robert Baer



On 6/22/2017 7:05 PM, Caroline wrote:

##MODISTools example
library(MODISTools)
library(lubridate)
setwd('~/Documents/Modis data')

#MODISTools with buffalo data

###Read in data rename for easier coding
tbdata <- read.csv('~/Desktop/All TB data for EVI, NDVI.csv')
Since this dataset is only on your desktop it cannot help us reproduce 
your error.  Can you supply a small dataset that cause the

error you are talking about?

One way to do this is to use supply the results of
dput(tbdata)
if it is small enough.  If not, maybe create a subset of the data and 
then use dput()


Did you get the problem when you tried with the tutorial Bert suggested?

firstobs <- subset(tbdata, capture.ID == 'B1-1108')
firstobs <- firstobs[,c(1,2,2,3,4)]
colnames(firstobs) <- c('id', 'start.date','end.date','lat','long')

###change date format and change start date to previous 14 days
firstobs$start.date <- dmy(firstobs$start.date)
firstobs$end.date <- dmy(firstobs$end.date)
firstobs$start.date <- firstobs[,2] - as.difftime(14, unit='days') ###time 
frame now spands two weeks

###define parameters
product <- "MOD13Q1"
bands <- c('250m_16_days_EVI', '250m_16_days_NDVI', '250m_16_days_VI_Quality')
pixel <- c(0,0)

###define data
period <- data.frame(lat=firstobs$lat, long=firstobs$long, start.date 
=firstobs$start.date, end.date = firstobs$end.date, id=firstobs$id)


###MODISSubsets
MODISSubsets(LoadDat = period, Products = product, Bands=bands, Size=pixel, 
SaveDir='.', StartDate=T)


###MODISSummaries
MODISSummaries(LoadDat = period, FileSep=',',Product='MOD13Q1', Bands = 
'250m_16_days_EVI', ValidRange=c(-2000,1), NoDataFill=-3000, ScaleFactor = 
0.0001, StartDate = TRUE, Interpolate = T, QualityScreen = TRUE, 
QualityThreshold = 0, QualityBand = '250m_16_days_VI_Quality')



On Jun 22, 2017, at 4:50 PM, Bert Gunter  wrote:

1. You should always cc the list unless there is a clear reason not to.

2. You still have failed to follow the posting guide: You say you have
difficulty troubleshooting your code, but you have shown us no code.
You got an error message that seems explicit, but with neither code
nor data, I do not know whether anyone can make sense of it. In any
case, I certainly cannot.


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 22, 2017 at 4:41 PM, Caroline
 wrote:

Hi Bert,

I have spent a lot of time searching the web for my error message and have gone 
through multiple tutorials. I have not found anything relevant to my error 
message which is why I posted on R-help.

Caroline


On Jun 22, 2017, at 4:38 PM, Bert Gunter  wrote:

This is a specialized package that fairly few of us are likely to have
familiarity with, especialy when you have not followed the posting
guide (below) and posted code and a reproducible example.

That said, a web search on R MODIS appeared to bring up relevant hits,
including a MODIS tutorial. Have you tried that?

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 22, 2017 at 2:12 PM, Caroline
 wrote:

I am using MODIS Tools and am having a lot of difficulty troubleshooting my 
code.

I am a PhD student studying African buffalo in Kruger National Park, South 
Africa. The study I am currently working on involves a herd of 200 African 
buffalo caught every six months for 4 years. I am trying to use EVI and NDVI to 
assess seasonal variation thus I would like mean EVI and NDVI for each 
observation (each time each buffalo was captured). I have capture date, lat and 
long for each observation.

However, when using ‘250m_16_days_pixel_reliability’ as my quality control band 
I keep getting the warning message:

Warning in MODISSummaries(LoadDat = period, FileSep = ",", Product = "MOD13Q1", 
 :
Only single data point that passed the quality screen: cannot summarise

When using ‘250m_16_days_VI_Quality’ as my quality control band I keep getting 
the warning message:

Error in QualityCheck(Data = band.time.series, QualityScores = QA.time.series,  
:
QualityScores not all in range of MOD13Q1's QC: 0-3

I seem to get this message with all subsets of my data (I have tried running 
all of my data at once and then just one data point at a time). I have also 
tried using wider date ranges as well as wider size ranges (in case the pixel 
reliability is poor within a certain area or time frame) but still get the same 
messages.
   [[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] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Rui Barradas

Hello,

The obvious way would be to preallocate the resulting data.frame, to 
expand an empty one on each iteration being a time expensive operation.


n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2)))
D4 <- data.frame(distance=integer(n),difference=integer(n))
k <- 0
for (i in 1:nrow(D1)){
for (j in 1:nrow(D2))  {
k <- k + 1
		D4[k, ] <- 
c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)

}
}

identical(D3, D4)

Hope this helps,

Rui Barradas

Em 23-06-2017 16:19, Rathore, Saubhagya Singh escreveu:

For certain reason, the content was not visible in the last mail, so posting it 
again.

Dear Members,

I have two different dataframes with a different number of rows. I need to 
apply a set of functions to each possible combination of rows with one row 
coming from 1st dataframe and other from 2nd dataframe. Though I am able to 
perform this task using for loops, I feel that there must be a more efficient 
way to do it. An example case is given below. D1 and D2 are two dataframes. I 
need to evaluate D3 with one column as the Euclidean distance in the x-y plane 
and second column as squared difference of z values, of each row pair from D1 
and D2.

D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
D3<-data.frame(distance=integer(0),difference=integer(0))

for (i in 1:nrow(D1)){

for (j in 1:nrow(D2))  {

temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)
D3<-rbind(D3,temp)
}
}

Thank you

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
r-help-ow...@r-project.org
Sent: Friday, June 23, 2017 10:47 AM
To: Rathore, Saubhagya Singh 
Subject: R version 3.3.2, Windows 10: Applying a function to each possible pair 
of rows from two different data-frames

The message's content type was not explicitly allowed

__
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] R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames

2017-06-23 Thread Rathore, Saubhagya Singh
For certain reason, the content was not visible in the last mail, so posting it 
again. 

Dear Members, 

I have two different dataframes with a different number of rows. I need to 
apply a set of functions to each possible combination of rows with one row 
coming from 1st dataframe and other from 2nd dataframe. Though I am able to 
perform this task using for loops, I feel that there must be a more efficient 
way to do it. An example case is given below. D1 and D2 are two dataframes. I 
need to evaluate D3 with one column as the Euclidean distance in the x-y plane 
and second column as squared difference of z values, of each row pair from D1 
and D2.

D1<-data.frame(x=1:5,y=6:10,z=rnorm(5))
D2<-data.frame(x=19:30,y=41:52,z=rnorm(12))
D3<-data.frame(distance=integer(0),difference=integer(0))

for (i in 1:nrow(D1)){

for (j in 1:nrow(D2))  {

temp<-data.frame(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2)
D3<-rbind(D3,temp)
}
}

Thank you

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
r-help-ow...@r-project.org
Sent: Friday, June 23, 2017 10:47 AM
To: Rathore, Saubhagya Singh 
Subject: R version 3.3.2, Windows 10: Applying a function to each possible pair 
of rows from two different data-frames

The message's content type was not explicitly allowed

__
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] MODISTools help - with reproducible examples

2017-06-23 Thread Caroline
In case anyone else experiences the same error:

The package creators responded and the issue was that I was using time frames 
between 14-30 days. EVI and NDVI are only calculated every 16 days so using 
that time span entailed that there was only one pixel per observation. I 
expanded my timeframe to 32 days and my analysis now works. 

I.E. changed:

firstobs$start.date <- firstobs[,2] - as.difftime(14, unit='days') ###time 
frame now spands two weeks

To

firstobs$start.date <- firstobs[,2] - as.difftime(32, unit='days') ###time 
frame now stands 32 days

Where first obs is the data set that contains the date that the data was 
collected, latitude, and longitude of collection site from one observation. I 
used the date the data was collected as the end date and transformed the date 
the data was collected to 32 days prior as the start date. 

firstobs before transformation:

 id start.date  end.date   lat   long
2 B1-1108  28-Nov-08 28-Nov-08 -25.07324 31.936

firstobs after transformation

 id start.date   end.date   lat   long
2 B1-1108 2008-10-27 2008-11-28 -25.07324 31.936

The key point is that the time frame used for analysis should be greater than 
or equal to 32 days. 

> On Jun 23, 2017, at 7:37 AM, Jeff Newmiller  wrote:
> 
> Please read up [1][2][3] on what constitutes reproducibility.  A sample of 
> data that triggers the problem is essential. 
> 
> [1] 
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> 
> [2] http://adv-r.had.co.nz/Reproducibility.html
> 
> [3] https://cran.r-project.org/web/packages/reprex/index.html
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On June 23, 2017 6:54:48 AM PDT, Caroline  
> wrote:
>> I have and they have not yet replied - however that was only two or
>> three days ago. 
>> 
>> I have included a code example. 
>>> On Jun 22, 2017, at 8:25 PM, David Winsemius 
>> wrote:
>>> 
 
 On Jun 22, 2017, at 4:44 PM, Caroline
>>  wrote:
 
 I am using the R-package MODISTools (different than MODIS) and am
>> having a lot of difficulty troubleshooting my code. I have spent awhile
>> going through MODISTools tutorials, searching for my error code,
>> looking at the source code. However, I have not been able to find any
>> relevant information related to my error message. 
 
 The study I am currently working on involves a herd of 200 African
>> buffalo caught every six months for 4 years. I am trying to use EVI and
>> NDVI to assess seasonal variation thus I would like mean EVI and NDVI
>> for each observation (each time each buffalo was captured). I have
>> capture date, lat and long for each observation. 
 
 However, when using ‘250m_16_days_pixel_reliability’ as my quality
>> control band I keep getting the warning message:
 
 Warning in MODISSummaries(LoadDat = period, FileSep = ",", Product =
>> "MOD13Q1",  :
 Only single data point that passed the quality screen: cannot
>> summarise
 
 When using ‘250m_16_days_VI_Quality’ as my quality control band I
>> keep getting the warning message: 
 
 Error in QualityCheck(Data = band.time.series, QualityScores =
>> QA.time.series,  : 
 QualityScores not all in range of MOD13Q1's QC: 0-3
 
 I seem to get this message with all subsets of my data (I have tried
>> running all of my data at once and then just one data point at a time).
>> I have also tried using wider date ranges as well as wider size ranges
>> (in case the pixel reliability is poor within a certain area or time
>> frame) but still get the same messages. 
 
 I have attached the data file I have been using as well as my code
>> (subsetted to just one animal so the run time is faster) 
 
 Has anyone seen this error message before/have any suggestions for
>> why I may be getting these errors?
>>> 
>>> I don't and you have not provided the accepted means to investigate
>> which would be code and data . Have you contacted the package
>> maintainer?
>>> 
>>> -- 
>>> 
>>> David Winsemius
>>> Alameda, CA, USA
>> 
>> 
>>  [[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] MODISTools help - with reproducible examples

2017-06-23 Thread Jeff Newmiller
Please read up [1][2][3] on what constitutes reproducibility.  A sample of data 
that triggers the problem is essential. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html
-- 
Sent from my phone. Please excuse my brevity.

On June 23, 2017 6:54:48 AM PDT, Caroline  
wrote:
>I have and they have not yet replied - however that was only two or
>three days ago. 
>
>I have included a code example. 
>> On Jun 22, 2017, at 8:25 PM, David Winsemius 
>wrote:
>> 
>>> 
>>> On Jun 22, 2017, at 4:44 PM, Caroline
> wrote:
>>> 
>>> I am using the R-package MODISTools (different than MODIS) and am
>having a lot of difficulty troubleshooting my code. I have spent awhile
>going through MODISTools tutorials, searching for my error code,
>looking at the source code. However, I have not been able to find any
>relevant information related to my error message. 
>>> 
>>> The study I am currently working on involves a herd of 200 African
>buffalo caught every six months for 4 years. I am trying to use EVI and
>NDVI to assess seasonal variation thus I would like mean EVI and NDVI
>for each observation (each time each buffalo was captured). I have
>capture date, lat and long for each observation. 
>>> 
>>> However, when using ‘250m_16_days_pixel_reliability’ as my quality
>control band I keep getting the warning message:
>>> 
>>> Warning in MODISSummaries(LoadDat = period, FileSep = ",", Product =
>"MOD13Q1",  :
>>> Only single data point that passed the quality screen: cannot
>summarise
>>> 
>>> When using ‘250m_16_days_VI_Quality’ as my quality control band I
>keep getting the warning message: 
>>> 
>>> Error in QualityCheck(Data = band.time.series, QualityScores =
>QA.time.series,  : 
>>> QualityScores not all in range of MOD13Q1's QC: 0-3
>>> 
>>> I seem to get this message with all subsets of my data (I have tried
>running all of my data at once and then just one data point at a time).
>I have also tried using wider date ranges as well as wider size ranges
>(in case the pixel reliability is poor within a certain area or time
>frame) but still get the same messages. 
>>> 
>>> I have attached the data file I have been using as well as my code
>(subsetted to just one animal so the run time is faster) 
>>> 
>>> Has anyone seen this error message before/have any suggestions for
>why I may be getting these errors?
>> 
>> I don't and you have not provided the accepted means to investigate
>which would be code and data . Have you contacted the package
>maintainer?
>> 
>> -- 
>> 
>> David Winsemius
>> Alameda, CA, USA
>
>
>   [[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] Plot survival curves after coxph() with frailty() random effects terms

2017-06-23 Thread Andreu Ferrero
I would like to plot a survival curves of a group with different categories
after running a Cox model with frailty() random effects terms.

I just could display a survival plot of the covariable’s mean.



Here an example:



library(survival)

fit<-coxph(Surv(time, status) ~ sex+  frailty(litter, dist='gamma',
method='em'), rats)

summary(fit )

suf<-survfit(fit)

plot(suf,  xscale=1, xlab = "Days", ylab="Survival", conf.int=FALSE)

lines(suf[1], lwd=2)

Warning message:

In `[.survfit`(suf, 1) : survfit object has only a single survival curve



#But if I use the next code I get the 2 groups.

surv_group <- survfit(Surv(time, status) ~ sex, rats)

lines(surv_group[1:2], lwd=2, conf.int=FALSE)




However, I am not sure about these 2 curves are well done, appropriate.

If any of you could help…



-- 
Andreu Ferrero Gregori

[[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] MODISTools help - with reproducible examples

2017-06-23 Thread Caroline
I have and they have not yet replied - however that was only two or three days 
ago. 

I have included a code example. 
> On Jun 22, 2017, at 8:25 PM, David Winsemius  wrote:
> 
>> 
>> On Jun 22, 2017, at 4:44 PM, Caroline  
>> wrote:
>> 
>> I am using the R-package MODISTools (different than MODIS) and am having a 
>> lot of difficulty troubleshooting my code. I have spent awhile going through 
>> MODISTools tutorials, searching for my error code, looking at the source 
>> code. However, I have not been able to find any relevant information related 
>> to my error message. 
>> 
>> The study I am currently working on involves a herd of 200 African buffalo 
>> caught every six months for 4 years. I am trying to use EVI and NDVI to 
>> assess seasonal variation thus I would like mean EVI and NDVI for each 
>> observation (each time each buffalo was captured). I have capture date, lat 
>> and long for each observation. 
>> 
>> However, when using ‘250m_16_days_pixel_reliability’ as my quality control 
>> band I keep getting the warning message:
>> 
>> Warning in MODISSummaries(LoadDat = period, FileSep = ",", Product = 
>> "MOD13Q1",  :
>> Only single data point that passed the quality screen: cannot summarise
>> 
>> When using ‘250m_16_days_VI_Quality’ as my quality control band I keep 
>> getting the warning message: 
>> 
>> Error in QualityCheck(Data = band.time.series, QualityScores = 
>> QA.time.series,  : 
>> QualityScores not all in range of MOD13Q1's QC: 0-3
>> 
>> I seem to get this message with all subsets of my data (I have tried running 
>> all of my data at once and then just one data point at a time). I have also 
>> tried using wider date ranges as well as wider size ranges (in case the 
>> pixel reliability is poor within a certain area or time frame) but still get 
>> the same messages. 
>> 
>> I have attached the data file I have been using as well as my code 
>> (subsetted to just one animal so the run time is faster) 
>> 
>> Has anyone seen this error message before/have any suggestions for why I may 
>> be getting these errors?
> 
> I don't and you have not provided the accepted means to investigate which 
> would be code and data . Have you contacted the package maintainer?
> 
> -- 
> 
> David Winsemius
> Alameda, CA, USA


[[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] Missing dependencies in pkg installs

2017-06-23 Thread Conklin, Mike (GfK)
I had the same thought in the shower this morning but I was disappointed to 
find that SElinux was disabled on the system.  My next step will be to install 
a previous version of R on the system.  My problem is that I am planning a 
shiny server installation and at least half of the apps on the current system 
depend on these libraries that will not install.
--
W. Michael Conklin
EVP Marketing & Data Sciences
GfK 
T +1 763 417 4545 | M +1 612 567 8287 

-Original Message-
From: Don Cohen [mailto:don-r-h...@isis.cs3-inc.com] 
Sent: Thursday, June 22, 2017 6:18 PM
To: Duncan Murdoch
Cc: Conklin, Mike (GfK); Martin Maechler; r-help@r-project.org
Subject: Re: [R] Missing dependencies in pkg installs

Duncan Murdoch writes:
 > On 22/06/2017 5:02 PM, Conklin, Mike (GfK) wrote:
 > > I am using debug on the .install_packages function...stepping through. 
 > > Once the temporary folder is created and the tar file expanded I run 
 > > file_test and get a FALSE back indicating that the configure file is not 
 > > executable.
 >
 > I don't know what is causing this bug.  Perhaps a Linux user can  > 
 > reproduce it and fix it.
 >
 > Here's what I see:
 >
 > file_test("-x") calls file.access(filename, 1L).  That in turn calls the  > 
 > C library function access(..., X_OK).  The ... is the name of the file,  > 
 > translated into the local encoding and expanded.  As far as I can see,  > 
 > that means ... should be exactly the string below.
 > >
 > > [1] "/tmp/RtmpMM6iC1/R.INSTALLc5ca415e4310/stringi"
 >
 > The only thing I can think of is that your system is protecting you from  > 
 > executing a newly created file until some sort of virus or other check  > is 
 > done.  (This is common on Windows, but I've never heard of it before  > on 
 > Linux.)

Just a thought - are you running SELinux ?
Check the log files for refusals to run programs.

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


Re: [R] getting error while trying to make dendogram based on gene expression

2017-06-23 Thread Martin Maechler
> Yogesh Gupta 
> on Wed, 21 Jun 2017 13:42:15 +0900 writes:

> I am trying to make dendogram based on gene expression matrix , but 
getting
> some error:

> I
> countMatrix = read.table("count.row.txt",header=T,sep='\t',check.names=F)

> colnames(countMatrix)

> count_matrix <- countMatrix[,-1]   #  remove first column
> (gene names)
> rownames(count_matrix) <- countMatrix[,1] #added first column gene
> names as rownames)

>> nonzero_row <- count_matrix[rowSums(count_matrix) > 0, # removed row sum
> 0 across all sample

>> x1= as.matrix(nonzero_row)# converted data into 
matrix

>> x=log2(x1+1)  # converted into
> log value
>> d <- dist(x, method="euclidean")

>> h <- hclust(d, method="complete")


> *Error:*

> *** caught segfault ***
> address 0x7fa39060af28, cause 'memory not mapped'

> Traceback:
> 1: hclust(d, method = "complete")

> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
> Selection:

This looks like a problem that should not happen.
Though it could be that it's just too large a problem (for your
hardware, or "in general").
However, we cannot reproduce what you show above.

To help us help you please provide (to this mailing list!)

   - a (minimal) reproducible example
   - sessionInfo()

It is best to take time to carefully read
   https://www.r-proejct.org/help.html

and/or then just search "reproducible example R" :
   http://lmgtfy.com/?q=reproducible+example+R

Martin


> Thanks
> Yogesh

__
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] Help: ifelse selection for x,y coordinates

2017-06-23 Thread Céline Lüscher
Hi Peter !

Thanks for your answer ! Indeed it is really better without the empty rows. 
Unfortunately I did’nt archieve to do it with your propositions, but with this 
one :

> kk<- function(x.Koordinate, y.Koordinate, data=data) 
+ { 
+   coordx<-data$x.Koordinate[data$G==24]
+   coordy<-data$y.Koordinate[data$G==24]
+   x<- ifelse(data$x.Koordinate>coordx-51 & data$G>15,data$x.Koordinate,NA)
+   y<-ifelse(data$y.Koordinate>coordy-51 & data$G>15,data$y.Koordinate,NA)
+   xy<-as.data.frame(list(x,y))
+   names(xy)<-c("x","y")
+   return(xy)
+ }
> kk1<-kk(x.Koordinate, y.Koordinate, data=data)
> kk1<-kk1[rowSums(is.na(kk1)) != ncol(kk1),]
> kk1
x  y
6  205550 NA
7  205550 604100
9  205600 604150
10 205600 604100


Now it looks great 😊

Regards,
C.


Gesendet von Mail für Windows 10

Von: Anthoni, Peter (IMK)
Gesendet: vendredi, 23 juin 2017 07:39
An: Céline Lüscher
Cc: r-help@r-project.org
Betreff: Re: [R] Help: ifelse selection for x,y coordinates

Hi Celine,

what about removing the unwanted after you made the x and y 
x<-x[x>0]  # or x<-x[x>0&&y>0], ditto for y, x[x!=""] in your ifelse (... ,"") 
case

if x and y will not have the same length afterwards you need to make that list 
thingy.

cheers
Peter


On 23. Jun 2017, at 07:30, Céline Lüscher  wrote:

Hi Jim,

Thank you very much for the answer ! The result is really better with this 😊

Here is the code :

kk<- function(x.Koordinate, y.Koordinate, data=data) 
+ { 
+   coordx<-data$x.Koordinate[data$G==24]
+   coordy<-data$y.Koordinate[data$G==24]
+   x <- ifelse(data$x.Koordinate>coordx-51 & data$G>15,data$x.Koordinate," ")
+   y<-ifelse(data$y.Koordinate>coordy-51 & data$G>15,data$y.Koordinate," ")
+   xy<-as.data.frame(list(x,y))
+   names(xy)<-c("x","y")
+   return(xy)
+ }

kk(x.Koordinate, y.Koordinate, data=data)
   x  y
1   
2   
3   
4   
5   
6  205550   
7  205550 604100
8   
9  205600 604150
10 205600 604100

Best regards,
C.


Gesendet von Mail für Windows 10

Von: Jim Lemon
Gesendet: vendredi, 23 juin 2017 05:28
An: Céline Lüscher
Cc: r-help@r-project.org
Betreff: Re: [R] Help: ifelse selection for x,y coordinates

Hi Celine,
Perhaps if you modify your return value like this:

xy<-as.data.frame(list(x,y))
names(xy)<-c("x","y")
return(xy)

Jim

On Thu, Jun 22, 2017 at 6:48 PM, Céline Lüscher  wrote:

Hi everyone,
My database has 3 columns : the x coordinates, the y coordinates and the value 
of G for every individual (20 in total). I would like to have the x,y 
coordinates of individuals, Under these conditions : the distance to the 
reference coordinates must be under or equal to 50 meters + the value of G must 
be bigger or equal to 16.

Here’s what I’ve done first :


kk<- function(x, y)
+ {
+   coordx<-data$x.Koordinate[data$G==24]
+   coordy<-data$y.Koordinate[data$G==24]
+   x <- ifelse(data$x.Koordinate>coordx-51 & data$G>15,data$x.Koordinate,0)
+   y<-ifelse(data$y.Koordinate>coordy-51 & data$G>15,data$y.Koordinate,0)
+   return(c(x,y))
+ }

kk(data$x.Koordinate, data$y.Koordinate)
[1]  0  0  0  0  0 205550 205550  0 205600 205600  
0  0  0  0  0  0  0
[18] 604100  0 604150 604100  0

The problem here is that we can not clearly see the difference between the 
coordinates for x and the ones for y.

Then I tried this :

kk<- function(x, y)
+ {
+   coordx<-data$x.Koordinate[data$G==24]
+   coordy<-data$y.Koordinate[data$G==24]
+   x <- ifelse(data$x.Koordinate>coordx-51 & data$G>15,data$x.Koordinate," ")
+   y<-ifelse(data$y.Koordinate>coordy-51 & data$G>15,data$y.Koordinate," ")
+   return(list(x,y))
+ }

kk(data$x.Koordinate, data$y.Koordinate)
[[1]]
[1] " "  " "  " "  " "  " "  "205550" "205550" " "  
"205600" "205600" " "

[[2]]
[1] " "  " "  " "  " "  " "  " "  "604100" " "  
"604150" "604100" " "




Where we can see better the two levels related to the x and y coordinates.

My question is simple : Is it possible for this function to return the values 
in a form like x,y or x y ? (without any 0, or « », or space) Or should I use 
another R function to obtain this result ?

Thank you for your help, and sorry for the English mistakes,
C.


Gesendet von Mail für Windows 10


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

Re: [R] encoding/locale problem with ssh -X

2017-06-23 Thread Andreas Leha
Hi Paul,

Thanks for following this up!

It used to be R version 3.3.1

I updated to R version 3.4.0

Now everything seems to work!

Many thanks!

Best,
Andreas



On 23/06/17 03:02, Paul Murrell wrote:
> Hi
> 
> What version of R do you have (on the remote machine) ?
> 
> I can replicate this with ...
> 
> x11(type="Xlib")
> library(grid)
> convertHeight(stringDescent("größe"), "in")
> 
> ... on R 3.2.5, but not on, e.g., R 3.4.0 (just running R locally in
> both cases).
> 
> Paul
> 
> On 21/06/17 20:05, Andreas Leha wrote:
>> Hi all,
>>
>> I am struggling with remote R sessions and a (I suspect) locale related
>> encoding problem:  Using the X11 device (X11forwarding enabled),
>> whenever I try to plot something containing umlauts using ggplot2, I am
>> seeing sth like
>>
>> ,
>> | Error in grid.Call(L_stringMetric, as.graphicsAnnot(x$label)) :
>> |   invalid use of -61 < 0 in 'X11_MetricInfo'
>> `
>>
>> Using base graphics is fine as is plotting to another device (pdf, say).
>>
>> Here is some code to reproduce:
>>
>> ,
>> | plot(1:10, 1:10, main = "größe")
>> | ## this works
>> |
>> | library("ggplot2")
>> | qplot(1:10, 1:10)
>> | ## this works still
>> |
>> | qplot(1:10, 1:10) + xlab("größe")
>> | ## ERROR
>> `
>>
>>
>> My setup:
>> - locally:
>>Linux (Debian GNU/Linux 9)
>> - remotely
>>Linux (RHEL Server release 7.3 (Maipo)
>>
>> (Maybe) relevant bits of my .ssh/config:
>>
>> ,
>> | Host theserver
>> |  HostName XXX.XXX.XXX.XXX
>> |  ForwardX11 yes
>> |  ForwardX11Timeout 596h
>> |  IdentityFile ~/.ssh/id_rsa
>> |  IdentitiesOnly yes
>> |  ForwardAgent yes
>> |  ServerAliveInterval 300
>> `
>>
>> Thanks in advance for your help!
>>
>> Best,
>> Andreas
>>
>> __
>> 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.