Re: [R] unique dates per ID

2016-11-15 Thread jeremiah rounds
library(data.table)
setDT(df)
setkeyv(df, c("Subject", "dates"))
unique(df)  #gets what you want.

On Mon, Nov 14, 2016 at 11:38 PM, Jim Lemon  wrote:

> Hi Farnoosh,
> Try this:
>
> for(id in unique(df$Subject)) {
>  whichsub<-df$Subject==id
>  if(exists("newdf"))
>   newdf<-rbind(newdf,df[whichsub,][which(!duplicated(
> df$dates[whichsub])),])
>  else newdf<-df[whichsub,][which(!duplicated(df$dates[whichsub])),]
> }
>
> Jim
>
>
> On Tue, Nov 15, 2016 at 9:38 AM, Farnoosh Sheikhi via R-help
>  wrote:
> > Hi,
> > I have a data set like below:
> > Subject<- c("2", "2", "2", "3", "3", "3", "4", "4", "5", "5", "5",
> "5")dates<-c("2011-01-01", "2011-01-01", "2011-01-03" ,"2011-01-04",
> "2011-01-05", "2011-01-06" ,"2011-01-07", "2011-01-07", "2011-01-09"
> ,"2011-01-10" ,"2011-01-11" ,"2011-01-11")deps<-c("A", "B", "CC",
> "C", "CC", "A", "F", "DD", "A", "F", "FF", "D")df <- data.frame(Subject,
> dates, deps); df
> > I want to choose unique dates per ID in a way there are not duplicate
> dates per ID. I don't mind what department to pick. I really appreciate any
> help. Best,Farnoosh
> >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] ​Message from Lanzhou University, China. (Help)

2016-11-15 Thread Jue Lin-Ye
​
​
Dear Mr. Song,

S
​​
orry for the late response.

​My response to you, is that, first, y
ou are not assuming a linear relationship in your formula, because the
argument k of your smooth term s() is not 1.

​Now, ​
I cannot see figure 1, but you can obtain figure 2 from the formula that
you describe here. In order to obtain a
​plot with the ​
derivative, you have to create a ne
​w​
column in your matrix or data-frame that is the derivative of the blood
pressure, and then apply gam()
​ as in

​
​
ct=gam(
​derivative(​
Blood pressure
​)​
~s(Temp,k=5)+s(BMI,k=4)+s(Age,k=6)+s(RH,k=4)+s(Pa,k=
5)+Gender+Season,family=gaussian,data=mydata)
​
.

H
​ope that helps​
. Best regards,

Jue



On Saturday, 12 November 2016,  wrote:
>
>
> Date: Fri, 11 Nov 2016 17:31:23 +0800 (GMT+08:00)
> From: ??? 
> To: r-help@r-project.org
> Subject: [R]
> ​​
> Message from Lanzhou University, China. (Help)
> Message-ID: <6f90a404.73da.15852ba30a2.coremail.songx...@lzu.edu.cn>
> Content-Type: text/plain; charset="utf-8"
>
> Dear moderators,
> I am a student come from Lanzhou University, Gansu, China. I have two
> questions on R (mgcv), which puzzled me for a long time. I did not find
> answer in Chinese forum. I hope you could answer me in your free time or
> post it in R-help. Thank you very much.
>
>  Xuping Song
>
> 2016.11.11
> We want to investigate the association between exposure to ambient
> temperature and blood pressure. The ?mgcv? package was used to perform GAM
> analyses in R. This is the formula.
> ​​
> ct=gam(Blood pressure~s(Temp,k=5)+s(BMI,k=4)+s(Age,k=6)+s(RH,k=4)+s(Pa,k=
> 5)+Gender+Season,family=gaussian,data=mydata)
>
> I have two questions. Firstly, personal characteristic (Age, Gender, BMI
> and Season) could influence blood pressure. How to control these variables?
> BMI and Age are continuous variable. I smoothed these two variables like
> formula 1. Season (1,2,3,4) and Gender(0,1) were add to formula, which were
> assumed as linear relationship. Is that right?
>
> Secondly, I want to get plot 2, which x-axis presented ?Temperature? and
> y-axis presented ?Change in Blood Pressure for every 1?C decrease of
> temperature?. Plot 2 came from a paper published recently (see appendix).
> Therefore, I ran formula 1 in R and run ?plot(ct)?. Then I get plot 1. I
> don?t understand the meaning of ?s?Tmean?3.87?? in y-axis. Does it
> represent ?Blood pressure?? If the hypothesis is right, plot 2 is the
> derivative of plot 1. However, I don?t know the specific code. I am a
> beginner of R and this problem puzzled me for a long time. Please help me.
> Thank you very much.
> -- next part --
> A non-text attachment was scrubbed...
> Name: Paper (plot 2).pdf
> Type: application/pdf
> Size: 913655 bytes
> Desc: not available
> URL:  4c9d7aec/attachment.pdf>
> -- next part --
> A non-text attachment was scrubbed...
> Name: Plot 2.png
> Type: image/png
> Size: 37455 bytes
> Desc: not available
> URL:  4c9d7aec/attachment.png>
>
> ​

[[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] [FORGED] Re: [FORGED] How to remove box in Venn plots (Vennerable package, uses grid) - similar to bty="n" in standard plots

2016-11-15 Thread DE LAS HERAS Jose
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
__
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] openxlsx Error: length of rows and cols must be

2016-11-15 Thread G . Maubach
Hi All,

when using 

-- cut --

number_style <- openxlsx::createStyle(
  numFmt = "COMMA"
)

openxlsx::addStyle(
  wb = xlsx_workbook,
  sheet = "Kundenliste",
  style = number_style,
  rows = 2:nrow(customer_list),
  cols = 4:5
  )
--cut --

I get the error

Error in openxlsx::addStyle(wb = xlsx_workbook, sheet = "Kundenliste",  : 
  Length of rows and cols must be equal.

The customer_list can be of any arbritrary length due to subgroup 
definitons. I do not see why the argument "rows" and "cols" should be of 
the same length. This would mean that number formatting can only be done 
for rectangular areas.

What do I need to change to format my numbers in the given area correctly?

Kind regards

Georg

__
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] openxlsx Error: length of rows and cols must be

2016-11-15 Thread Jeff Newmiller
This behavior is a basic limitation of spreadsheets. This R API is 
(inappropriately) more flexible than the underlying Java API is. You have to 
apply your formatting with multiple calls to the addStyle function, just as you 
would interactively in a spreadsheet. 
-- 
Sent from my phone. Please excuse my brevity.

On November 15, 2016 4:48:50 AM PST, g.maub...@weinwolf.de wrote:
>Hi All,
>
>when using 
>
>-- cut --
>
>number_style <- openxlsx::createStyle(
>  numFmt = "COMMA"
>)
>
>openxlsx::addStyle(
>  wb = xlsx_workbook,
>  sheet = "Kundenliste",
>  style = number_style,
>  rows = 2:nrow(customer_list),
>  cols = 4:5
>  )
>--cut --
>
>I get the error
>
>Error in openxlsx::addStyle(wb = xlsx_workbook, sheet = "Kundenliste", 
>: 
>  Length of rows and cols must be equal.
>
>The customer_list can be of any arbritrary length due to subgroup 
>definitons. I do not see why the argument "rows" and "cols" should be
>of 
>the same length. This would mean that number formatting can only be
>done 
>for rectangular areas.
>
>What do I need to change to format my numbers in the given area
>correctly?
>
>Kind regards
>
>Georg
>
>__
>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-pkgs] New Package: largeVis

2016-11-15 Thread Amos Elberg
Dear R users,  

I’m please to announce the available on CRAN of new package largeVis.(*)   

largeVis offers three major features:

- A fast implementation of the LargeVis algorithm. LargeVis is for 
visualizing high-dimensional datasets, similar to (and of similar quality to) 
t-SNE. But, LargeVis runs in O(n) time, which makes it feasible to use on 
datasets with millions of rows and thousands of columns. LargeVis is also 
insensitive to hyperparameter changes, which is important when running on large 
datasets that take time to compute.  

- Very fast approximate nearest neighbor search. I believe it to be the 
fastest nearest neighbor search available for R.  

- A fast implementation of the HDBSCAN clustering algorithm. HDBSCAN is 
a density-based clustering similar to DBSCAN and OPTICS (which are also 
implemented), but HDBSCAN allows the density threshold for clusters to vary. 
This makes it insensitive to hyperparameter changes and more flexible than 
either DBSCAN or OPTICS.

There are other features as well, such as functions to visualize image 
embeddings using largeVis. 

Some examples are available here:  https://github.com/elbamos/largevis
Benchmarks comparing the speed of the nearest neighbor search to RcppAnnoy are 
here: https://github.com/elbamos/largeVis/blob/master/benchmarks.md
Examples of HDBSCAN are here:  
https://cran.r-project.org/web/packages/largeVis/vignettes/momentumandusedata.html

The package is available here:  
https://cran.r-project.org/web/packages/largeVis/index.html  and for best 
results, to take advantage of 64-bit machines and multiple cores, should be 
installed from source. 

Thank you!

(*) A prior version was available on CRAN but not announced.
[[alternative HTML version deleted]]

___
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] extracting all different items in a matrix colum or vector

2016-11-15 Thread bgnumis bgnum
Hi all,


>From many time ago, I have return to R, I have a matrix with this values.

C(jose, pepe, jose, luis, pepe, raul)

I want to "read" this matrix or element and extract all different values,
so the output matrix (that I want to download is:

c(jose, pepe, luis, raul).

There is a function to do this?

Many thanks in advance.

[[alternative HTML version deleted]]

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


[R] Project on Course Recommender using R language

2016-11-15 Thread sampada upasani
Hello,

I am a student of Georgia Tech and currently working on a project : Course
Recommender using R language. Before moving forward I wanted to clear up
things and hence posting this question. Will I be able to build this
project using the Shiny App ? (Developing web applications using R). After
reading about shiny, I came to know that it is recommended for deploying
web applications and requires no knowledge of Javascript but is not
recommended for complex web apps. I was looking for developing a web app on
similar lines due to the time constraint.

Can you please share your thoughts on is it a good idea to use this app for
developing a web application for College Course Recommender?

Thanks,
Sampada Upasani
Graduate Student
Georgia Tech

[[alternative HTML version deleted]]

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


Re: [R] extracting all different items in a matrix colum or vector

2016-11-15 Thread Sarah Goslee
Your question strongly suggests that you need to reread at least one
introductory guide to R.

But the answer to your specific question is the unique() function.

Sarah

On Tue, Nov 15, 2016 at 7:33 AM, bgnumis bgnum  wrote:
> Hi all,
>
>
> >From many time ago, I have return to R, I have a matrix with this values.
>
> C(jose, pepe, jose, luis, pepe, raul)
>
> I want to "read" this matrix or element and extract all different values,
> so the output matrix (that I want to download is:
>
> c(jose, pepe, luis, raul).
>
> There is a function to do this?
>
> Many thanks in advance.
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] Project on Course Recommender using R language

2016-11-15 Thread Jeff Newmiller
My recommendation is that you separate your algorithm development from your Web 
implementation. Once you have the algorithm working you can decide how you will 
implement it. This forum is inappropriate for both of these subjects... when 
you need help with coding in R this is a good place to ask questions. Q 
questions about Shiny should be asked on the RStudio shiny.
-- 
Sent from my phone. Please excuse my brevity.

On November 15, 2016 9:09:09 AM PST, sampada upasani 
 wrote:
>Hello,
>
>I am a student of Georgia Tech and currently working on a project :
>Course
>Recommender using R language. Before moving forward I wanted to clear
>up
>things and hence posting this question. Will I be able to build this
>project using the Shiny App ? (Developing web applications using R).
>After
>reading about shiny, I came to know that it is recommended for
>deploying
>web applications and requires no knowledge of Javascript but is not
>recommended for complex web apps. I was looking for developing a web
>app on
>similar lines due to the time constraint.
>
>Can you please share your thoughts on is it a good idea to use this app
>for
>developing a web application for College Course Recommender?
>
>Thanks,
>Sampada Upasani
>Graduate Student
>Georgia Tech
>
>   [[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] extracting all different items in a matrix colum or vector

2016-11-15 Thread bgnumis bgnum
Many Thanks Sarah

Really I´m going to do it.

If you can suggest me one complete and didactic I will be very gratefull.
Anyway many thanks for your answer.



2016-11-15 18:56 GMT+01:00 Sarah Goslee :

> Your question strongly suggests that you need to reread at least one
> introductory guide to R.
>
> But the answer to your specific question is the unique() function.
>
> Sarah
>
> On Tue, Nov 15, 2016 at 7:33 AM, bgnumis bgnum  wrote:
> > Hi all,
> >
> >
> > >From many time ago, I have return to R, I have a matrix with this
> values.
> >
> > C(jose, pepe, jose, luis, pepe, raul)
> >
> > I want to "read" this matrix or element and extract all different values,
> > so the output matrix (that I want to download is:
> >
> > c(jose, pepe, luis, raul).
> >
> > There is a function to do this?
> >
> > Many thanks in advance.
> >
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

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