[R-es] Incluir símbolo matemático en data frame

2017-10-08 Thread Manuel Spínola
Estimados miembros de la lista,

Cómo se puede incluir. por ejemplo, el símbolo de menor o igual en un
data.frame para luego hacer un cuadro (table con kable in rmarkadown)?

columna1 <- c("a", "b", "c")
columna2 <- c(<= 0.3, 0.5, 0.8)
columna3 <- c(>=0.5, 0.6, 0.9)

cuadro <- data.frame(columna1, columna2, columna3)

kable(cuadro)

Manuel

-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río 
Institutional website: ICOMVIS 

[[alternative HTML version deleted]]

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


Re: [R] how to overlay 2d pdf atop scatter plot using ggplot2

2017-10-08 Thread Ulrik Stervbo
How about geom_contour()?

Am So., 8. Okt. 2017, 20:52 schrieb Ranjan Maitra :

> Hi,
>
> I am no expert on ggplot2 and I do not know the answer to your question. I
> looked around a bit but could not find an answer right away. But one
> possibility could be, if a direct approach is not possible, to draw
> ellipses corresponding to the confidence regions of the multivariate t
> density and use geom_polygon to draw this successively?
>
> I will wait for a couple of days to see if there is a better answer posted
> and then write some code, unless you get to it first.
>
> Thanks,
> Ranjan
>
>
> On Sun, 8 Oct 2017 09:30:30 -0500 Big Floppy Dog 
> wrote:
>
> > Note: I have posted this on SO also but while the question has been
> > upvoted, there has been no answer yet.
> >
> >
> https://stackoverflow.com/questions/46622243/ggplot-plot-2d-probability-density-function-on-top-of-points-on-ggplot
> >
> > Apologies for those who have seen it there also but I thought that this
> > list of experts may have someone who knows the answer.
> >
> > I have the following example code:
> >
> >
> >
> > require(mvtnorm)
> > require(ggplot2)
> > set.seed(1234)
> > xx <- data.frame(rmvt(100, df = c(13, 13)))
> > ggplot(data = xx,  aes(x = X1, y= X2)) + geom_point() + geom_density2d()
> >
> >
> >
> > It yields a scatterplot of X2 against X1 and a KDE contour plot of the
> > density (as it should).
> >
> > My question is: is it possible to change the contour plot to display
> > the contours
> >
> > of a two-dimensional density function (say dmvt), using ggplot2?
> >
> > The remaining figures in my document are in ggplot2 and therefore I
> > am looking for a ggplot2 solution.
> >
> > Thanks in advance!
> >
> > BFD
> >
> >   [[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.
> >
>
>
> --
> Important Notice: This mailbox is ignored: e-mails are set to be deleted
> on receipt. Please respond to the mailing list if appropriate. For those
> needing to send personal or professional e-mail, please use appropriate
> addresses.
>
> __
> 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] how to overlay 2d pdf atop scatter plot using ggplot2

2017-10-08 Thread Ranjan Maitra
Hi,

I am no expert on ggplot2 and I do not know the answer to your question. I 
looked around a bit but could not find an answer right away. But one 
possibility could be, if a direct approach is not possible, to draw ellipses 
corresponding to the confidence regions of the multivariate t density and use 
geom_polygon to draw this successively? 

I will wait for a couple of days to see if there is a better answer posted and 
then write some code, unless you get to it first.

Thanks,
Ranjan


On Sun, 8 Oct 2017 09:30:30 -0500 Big Floppy Dog  wrote:

> Note: I have posted this on SO also but while the question has been
> upvoted, there has been no answer yet.
> 
> https://stackoverflow.com/questions/46622243/ggplot-plot-2d-probability-density-function-on-top-of-points-on-ggplot
> 
> Apologies for those who have seen it there also but I thought that this
> list of experts may have someone who knows the answer.
> 
> I have the following example code:
> 
> 
> 
> require(mvtnorm)
> require(ggplot2)
> set.seed(1234)
> xx <- data.frame(rmvt(100, df = c(13, 13)))
> ggplot(data = xx,  aes(x = X1, y= X2)) + geom_point() + geom_density2d()
> 
> 
> 
> It yields a scatterplot of X2 against X1 and a KDE contour plot of the
> density (as it should).
> 
> My question is: is it possible to change the contour plot to display
> the contours
> 
> of a two-dimensional density function (say dmvt), using ggplot2?
> 
> The remaining figures in my document are in ggplot2 and therefore I
> am looking for a ggplot2 solution.
> 
> Thanks in advance!
> 
> BFD
> 
>   [[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.
> 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on 
receipt. Please respond to the mailing list if appropriate. For those needing 
to send personal or professional e-mail, please use appropriate addresses.

__
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] multi variable analysis

2017-10-08 Thread Ranjan Maitra
Arun,

I would suggest either getting enrolled in a multivariate statistics class and 
the pre-requisites for this or going back to your boss and asking him or her to 
hire a MS-level statistician since this is clearly beyond your current state of 
knowledge. 

Don't expect R-help to be a free consulting service. And of course, your query 
has nothing to do with R.

Thanks,
Ranjan

On Sun, 8 Oct 2017 19:57:11 +0530 Arun Kumar  wrote:

> Hi All,
> 
> I have been given three raw data csv files related to an advertising
> campaign. Impressions, clicks and conversion. They asked me to suggest
> optimisation suggestions using uni variable and multi variable analysis.
> The clicks or conversions are spread across various parameters like device,
> country, city, ad type, browser, postal code etc. How do I approach the
> analysis and modelling in this regard.
> 
> Thanks,
> Arun
> 
>   [[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.
> 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on 
receipt. Please respond to the mailing list if appropriate. For those needing 
to send personal or professional e-mail, please use appropriate addresses.

__
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] Manipulations with CO2 dataset on R

2017-10-08 Thread Ranjan Maitra
Hello Ludovico,

What is your goal in taking this class? If you are expecting someone else to do 
your homework for you, you should really consider whether you should waste your 
time and your  funding source's money to take this class.

In any case, HW questions are off-topic for this list.

So, Ride the Bus, Go to Class, Call your Mom/Dad.

HTH!

On Sun, 8 Oct 2017 14:39:55 + Ludovico Piccolo  
wrote:

> Hi,
> 
> 
> 
> I just started a new course this semester on R, I never used it in my life 
> and i'm stuck on these questions from 3 days, it would be really nice if 
> someone could explain me the answers with the relative commands.
> 
> thanks a lot in advance
> 
> The following 7 questions are based on the CO2 dataset of R.
> 
> 1) How many of the plants in CO2 are Mc2 for Plant?
> 
> 2) How many are either Mc2 or Mn2?
> 
> 3) How many are Quebec for Type and nonchilled for Treatment?
> 
> 4) How many have a concentration (conc) of 350 or bigger?
> 
> 5) How many have a concentration between 350 and 435 (inclusive)?
> 
> 6) How many have a concentration between 300 and 450 (inclusive) and are 
> nonchilled?
> 
> 7)How many have an uptake that is less than 1/10 of the concentration (in the 
> units reported)?
> 
> 
> 
>   [[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.
> 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on 
receipt. Please respond to the mailing list if appropriate. For those needing 
to send personal or professional e-mail, please use appropriate addresses.

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


[R-es] enigma con regresión de Fine & Gray y variable dependiente del tiempo

2017-10-08 Thread Alberto Carmona Bayonas
Hola, necesito ayuda de la comunidad sobre una duda acerca de una regresión
de riesgos competitivos.
Mi idea era llevar a cabo una regresión de Fine y Gray multivariante usando
como predictores una variable fija X y otra dependiente del tiempo Y.
Para ello primero he hecho un modelo univariante usando sólo la variable
fija X. Aquí sin problema, obtengo el mismo resultado tanto con la función
crr del paquete cmprsk, como con la función finegray seguida de survival
del paquete survival.

Aquí podéis ver la pinta de los datos, donde ftime2 es el tiempo al evento,
cause es el evento (0=cens, 1 evento de interés, 2=competing) y days_pd son
los días hasta el predictor dependiente del tiempo Y (NA cuando no lo
tiene):


> head(epi2,40)
   id ftime2 days_pd X  cause
1   1   15.0  NA 1 2
2   3   24.0  NA 0 2
3   4 1094.0  NA 0 2
4   51.0  NA 1 2
5   65.0  NA 1 2
6   72.0  NA 1 2
7   8  110.0  NA 1 2
8  10  506.0  NA 1 0
9  129.0  NA 1 2
10 13  128.0  NA 1 2

> tail(epi2,40)
   id ftime2 days_pd X cause
1036  877562 525 1 2
1037  876614 538 0 2
1038  892592 539 1 0
1039  905613 539 0 1
1040   97713 572 0 2
1041  962784 572 0 1
1042  885574 574 1 0
1043 1018   1168 590 0 0
1044  959786 595 0 2
1045  948750 596 0 2



*Cuando evalúo el efecto de X el código es:*

> pdata <- finegray(Surv(ftime2, cause) ~ ., data=epi2,id=id)

> fgfit <- coxph(Surv(fgstart, fgstop, fgstatus) ~ X,
+weight=fgwt, data=pdata)
> fgfit
Call:
coxph(formula = Surv(fgstart, fgstop, fgstatus) ~ X, data = pdata,
weights = fgwt)

coef exp(coef) se(coef) z  p
X -0.614 0.5410.228 -2.69 0.0072

Likelihood ratio test=7.62  on 1 df, p=0.00577
n= 25625, number of events= 86


*Tras ello intento generar una base de datos en formato largo para la
variable dependiente del tiempo days_pd usando tmerge *

epitd<-subset (epi, select=c(id, ftime2, X, Y, days_pd, cause))
epitd1 <- tmerge(epitd, epitd, id=id, cause = event(ftime2, cause))
epitd2 <- tmerge(epitd1, epitd1, id=id, Y= tdc(days_pd, Y))
epitd2$Y[is.na(epitd2$Y)]=0

> tail(epitd2,40)
  idftime2 X days_pd  cause prog tstart tstopY
1430  985893 0 762 21762   893  1
1431  982869 1 789 0   1  0   789  0
1432  982869 1 789 2   1789   869  1
1433  987909 1 810 0   1  0   810  0
1434  987909 1 8102   1810   909  1
1435 1022   1224 0 831  0   1  0   831  0
1436 1022   1224 0 831  0   1831  1224  1
1437 1023   1225 1 852 0   1  0   852  0
1438 1023   1225 1 852 1   1852  1225  1

*Se observa que los casos se duplican, por ejemplo, el id=982 desarrolla la
variante dependiente del tiempo Y en el punto 789 y luego tiene el evento
competitivo=2 en el momento 869.*
*Tras ello aplico la regresión de FG para X, que es la variable fija, y el
resultado NO es consistente con el que se obtuvo con la base de datos en
formato corto (HR 0.541 antes y 0.597 ahora).*
*No sé si tiene que ver o no con el warning que aparece... *

*¿Alguien sabría explicarme qué tipo de sesgo he cometido?*


> pdata_1 <- finegray(Surv(tstart,tstop,event) ~ ., data=epitd2,
count="var", na.action= na.pass,id=id)

Warning message:
In any(sorty[-last, 3]) : coercing argument of type 'double' to logical
> fgfit4 <- coxph(Surv(fgstart, fgstop, fgstatus==1) ~ X+cluster(id),
+weight=fgwt, data=pdata_1)
> fgfit4
Call:
coxph(formula = Surv(fgstart, fgstop, fgstatus == 1) ~ X+
cluster(id), data = pdata_1, weights = fgwt)

coef exp(coef) se(coef) robust se z p
X -0.517 0.5970.228 0.227 -2.28 0.023

Likelihood ratio test=5.37  on 1 df, p=0.0205
n= 30290, number of events= 86

[[alternative HTML version deleted]]

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


[R] Manipulations with CO2 dataset on R

2017-10-08 Thread Ludovico Piccolo
Hi,



I just started a new course this semester on R, I never used it in my life and 
i'm stuck on these questions from 3 days, it would be really nice if someone 
could explain me the answers with the relative commands.

thanks a lot in advance

The following 7 questions are based on the CO2 dataset of R.

1) How many of the plants in CO2 are Mc2 for Plant?

2) How many are either Mc2 or Mn2?

3) How many are Quebec for Type and nonchilled for Treatment?

4) How many have a concentration (conc) of 350 or bigger?

5) How many have a concentration between 350 and 435 (inclusive)?

6) How many have a concentration between 300 and 450 (inclusive) and are 
nonchilled?

7)How many have an uptake that is less than 1/10 of the concentration (in the 
units reported)?



[[alternative HTML version deleted]]

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


[R] how to overlay 2d pdf atop scatter plot using ggplot2

2017-10-08 Thread Big Floppy Dog
Note: I have posted this on SO also but while the question has been
upvoted, there has been no answer yet.

https://stackoverflow.com/questions/46622243/ggplot-plot-2d-probability-density-function-on-top-of-points-on-ggplot

Apologies for those who have seen it there also but I thought that this
list of experts may have someone who knows the answer.

I have the following example code:



require(mvtnorm)
require(ggplot2)
set.seed(1234)
xx <- data.frame(rmvt(100, df = c(13, 13)))
ggplot(data = xx,  aes(x = X1, y= X2)) + geom_point() + geom_density2d()



It yields a scatterplot of X2 against X1 and a KDE contour plot of the
density (as it should).

My question is: is it possible to change the contour plot to display
the contours

of a two-dimensional density function (say dmvt), using ggplot2?

The remaining figures in my document are in ggplot2 and therefore I
am looking for a ggplot2 solution.

Thanks in advance!

BFD

[[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] multi variable analysis

2017-10-08 Thread Arun Kumar
Hi All,

I have been given three raw data csv files related to an advertising
campaign. Impressions, clicks and conversion. They asked me to suggest
optimisation suggestions using uni variable and multi variable analysis.
The clicks or conversions are spread across various parameters like device,
country, city, ad type, browser, postal code etc. How do I approach the
analysis and modelling in this regard.

Thanks,
Arun

[[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] load() failed to load .Rdata file in AWS-Ububtu

2017-10-08 Thread Christofer Bogaso
Thanks Eric for your pointer. However I just altered the argument of
load() function a little bit to get that loaded. Below is the line
what I tried.

ubuntu@ip-172-31-23-148:~$ R


R version 3.4.2 (2017-09-28) -- "Short Summer"

Copyright (C) 2017 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)


R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.


  Natural language support but running in an English locale


R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.


Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.


During startup - Warning message:

Setting LC_CTYPE failed, using "C"

> load("/home/ubuntu/Dat.RData")

>

However it still failing when I try that within my shiny app in AWS.

Below are my ui.R and server.R files respectively.

library(shiny)

# Define UI for miles per gallon application
fluidPage(
  fluidRow(
column(12,
  tableOutput('table')
)
  )
)

server.R :

library(shiny)

load("/home/ubuntu/Dat.RData")

shinyServer(function(input, output) {
output$table = renderTable(head(data.frame(1:20, 1:20), 20))
})

with above setup when I deploy my shiny app I get below error :

18.221.184.94:3838 says
The application unexpectedly exited
Diagnostic information has been dumped to the JavaScript error console.

appreciate any help to get rid of this error.

Thanks for your time.

On Sun, Oct 8, 2017 at 12:39 AM, Eric Berger  wrote:
> Hi Christofer,
> The directory /srv/shiny-server would normally be owned by the root user.
> Your options would seem to be to either (1) bring up the R session as root
> (dangerous)
> or (2) try copying the file to your local directory and read it from there
> (if allowed).
> e.g. from the Unix shell:
>> cd ~   (i.e. cd to your home directory)
>> cp /srv/shiny-server/Dat.Rdata .   (Note the '.' at the end. This may not
>> work - if not then you can try the following
>> sudo cp /srv/shiny-server/Dat.Rdata . (if you have sudo privileges - only
>> do this if the former command did not work)
>> chmod 777 Dat.Rdata  (a bit of overkill - again preface by sudo if it does
>> not work without it)
>
> Then in your R session you can do the load from the file in this location.
> R>  load("~/Dat.Rdata")
>
> HTH,
> Eric
>
>
> On Sat, Oct 7, 2017 at 8:54 PM, Christofer Bogaso
>  wrote:
>>
>> Hi again,
>>
>> I hope this is the right place to post my question on running R within
>> Ubuntu, however if not, any pointer on right distribution list will be
>> helpful.
>>
>> I am currently using R in Ubuntu which is hosted in Amazon - AWS.
>>
>> I have a .Rdata file in AWS which I am trying to load in R. Used
>> following code, however, fails to load showing some permission issue.
>> However that same .Rdata file is getting loaded perfectly when I try
>> in my regular iOS.
>>
>> Below is my code and corresponding result :
>>
>> ubuntu@ip-172-31-23-148:~$ R
>>
>>
>> R version 3.4.2 (2017-09-28) -- "Short Summer"
>>
>> Copyright (C) 2017 The R Foundation for Statistical Computing
>>
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>>
>> You are welcome to redistribute it under certain conditions.
>>
>> Type 'license()' or 'licence()' for distribution details.
>>
>>
>>   Natural language support but running in an English locale
>>
>>
>> R is a collaborative project with many contributors.
>>
>> Type 'contributors()' for more information and
>>
>> 'citation()' on how to cite R or R packages in publications.
>>
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>>
>> 'help.start()' for an HTML browser interface to help.
>>
>> Type 'q()' to quit R.
>>
>>
>> During startup - Warning message:
>>
>> Setting LC_CTYPE failed, using "C"
>>
>> > file.exists('/srv/shiny-server/Dat.Rdata')
>>
>> [1] TRUE
>>
>> > load('/srv/shiny-server/Dat.Rdata')
>>
>> Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
>>
>> In addition: Warning message:
>>
>> In readChar(con, 5L, useBytes = TRUE) :
>>
>>   cannot open compressed file '/srv/shiny-server/Dat.Rdata', probable
>> reason 'Permission denied'
>>
>> > readRDS('/srv/shiny-server/Dat.Rdata')
>>
>> Error in gzfile(file, "rb") : cannot open the connection
>>
>> In addition: Warning message:
>>
>> In gzfile(file, "rb") :
>>
>>   cannot open compressed file '/srv/shiny-server/Dat.Rdata', probable
>> reason 'Permission denied'
>>
>>
>> Can someone help me to understand where it went wrong with Ubuntu? I
>> also tried with changing the extension from .Rdata to .RData, however
>> observing the same error.
>>
>> Any pointer will be