Re: [R] Getting "Error in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Deramus, Thomas Patrick
Truly appreciate it Bill.

Will try to make something more trimmed down in the future, but unfortunately 
have to admit I am more of an R neophyte than I would like to be.

From: Joshua Ulrich 
Sent: Thursday, October 6, 2022 11:26 AM
To: Bill Dunlap 
Cc: Deramus, Thomas Patrick ; r-help@r-project.org 

Subject: Re: [R] Getting "Error in ect, plot.new has not been called yet" 
despite grouping plot call

External Email - Use Caution

On Thu, Oct 6, 2022 at 9:44 AM Bill Dunlap  wrote:
>
> Here is how you could have made an example that helpers could easily run.
> It also includes the fix.
>
> f <- function(print.it = FALSE) {
>pdf(file.pdf <- tempfile(fileext=".pdf"))
>series <- as.xts(setNames(sin(seq(0,10,by=.1)),
> seq(as.Date("2022-10-06"),by="weeks",len=101)))
>p <- plot(series)
>if (print.it) {
>print(p)
>}
>sm_series_2 <- smooth(series / 2)
>lines(sm_series_2, col="red")
>abline(h=0.1, col="blue")
>dev.off()
>file.pdf
> }
> > f()
> Error in plot.xy(xy.coords(x, y), type = type, ...) :
>   plot.new has not been called yet
> > f(TRUE)
> [1]
> "C:\\Users\\willi\\AppData\\Local\\Temp\\Rtmp0wX7rO\\file34843df652c.pdf"
>
> If you remove the pdf() and dev.off() I think you will see that the added
> lines do not show up.  I think plot.xts fiddles with the coordinate system
> before and after it plots so that add-ons must be done in a special way.
>

plot.xts() waits until the plot is rendered before calculating the
coordinate system. That allows users to add multiple series that have
different values for the index (x-axis) and data (y-axis).

lines() doesn't show up in your example because it's called after the
plot is rendered, and it's not rendered again after they're added.
`sm_series_2` also needs to be an xts object, otherwise lines.xts() is
not dispatched.

title() and abline() need to be called after the plot is rendered
because they are standard graphics functions. I admit that's very
confusing... I'll see what I can do to fix that.

Here's a revised example that works for me:

f <- function(print.it = FALSE)
{
pdf(file.pdf <- tempfile(fileext=".pdf"))
series <- xts(sin(seq(0,10,by=.1)),
seq(as.Date("2022-10-06"),by="weeks",length.out=101))
p <- plot(series)
sm2 <- xts(smooth(series/2), index(series))
lines(sm2, col="red")
if (print.it) {
print(p)
title("Sine curve example")
abline(h=0.1, col="green")
}
dev.off()
file.pdf
}
f(TRUE)



> -Bill
>
> On Thu, Oct 6, 2022 at 12:42 AM Deramus, Thomas Patrick <
> tdera...@partners.org> wrote:
>
> > Hi Rolf.
> >
> > I followed your suggestion (though it's probably not as trimmed as it
> > could be), but the problem unfortunately persists.
> >
> > Does this make it any clearer or still too many moving parts to make sense
> > of?
> >
> > rm(list = ls(all.names = TRUE)) #will clear all objects includes hidden
> > objects.
> >
> > #Loads the packages
> > library(plyr)
> > library(dplyr)
> > library(ggplot2)
> > library(Kendall)
> > library(lubridate)
> > library(xts)
> > library(TTR)
> > library(trend)
> > library(forecast)
> > library(openxlsx)
> >
> > #Uses the learningCurve Package from Github:
> > #https://secure-web.cisco.com/1GC2a24rvTQn4ZsRD2yEzdiU8p0VcreF81tS2HTnyYa7VJF5IpO2yI1E7CRvAjkTDIaj6KEYqjTGRSAenLfIdC6jV3OEUiCZS17V58pTwQ-55guIdhru6Sek8uJuW1ts44qoo8ZbniSWEwzzch1DcQTxCe9raR3xZavXdeOins1Yzg7le2LJWuRBEk8s9CxpKUsKa9l3qmWmjRszIWVX7nZSBTjnNOFTcJgqc8MQu8qZojb4GwCZ8mlP7U4dQdClXlDxxlTL6kF-Awi1NmycuaWn8MYEjxDTpdyqw97MAkHjESJbjB7Hfv93No-E5_9cp/https%3A%2F%2Fgithub.com%2FAFIT-R%2FlearningCurve
> > library(learningCurve)
> >
> > #Only load this if using VS Studio because it changes the plot function
> > #
> > https://secure-web.cisco.com/19uRRA2OdQiP-LFePtct8U8sQ1opEP7PrOFLjX3GDTAREApng8FFteGdDY-n8lnkoclvIekYRw4YgvqG24Tsovdeq3hKnKx6iBpWoAy-tOijBFwH0AKBvugicSxwCStU9yZANYx2BTYDd8bYZoEkwTYnthGTH4AKLybu5ek_wJMX0hCEzx9IxjRZ-03ISDvocEUUspf4uxi841j1qW7mAZ3WMj4pjTUa8mlUznIxtkTeEdGYN0X4j3Q5iiwLin6l0gntobwjoaTMv_0kq8hQe6_cYJCxBVxU-CEYcY8KPjsM9YBC-oYeFhUt13Wqlj-mO/https%3A%2F%2Fstackoverflow.com%2Fquestions%2F52284345%2Fhow-to-show-r-graph-from-visual-studio-code
> > library(httpgd)
> > library(languageserver)
> >
> > #Loads the Excel files to Dataframes and cleans the data
> > Game_Metrics_Word_Task <-
> > read.xlsx("GamePack_Analytics_ALL_TIME_Short.xlsx", "Boggle")
> > Game_Metrics_Word_Task <- Game_Metrics_Word_Task %>% filter(grepl('1440',
> > StudyId))
> > Game_Metrics_Word_Task$DeviceTime <-
> > ymd_hms(Game_Metrics_Word_Task$DeviceTime,  tz = "America/New_York")
> > Game_Metrics_Word_Task <-
> > Game_Metrics_Word_Task[!duplicated(Game_Metrics_Word_Task[1:2,])]
> >
> > #Splits the dataframe into a tibble containing each participant
> > Participant_Word_Task <-
> > split(arrange(Game_Metrics_Word_Task,StudyId,DeviceTime),
> > arrange(Game_Metrics_Word_Task,StudyId,DeviceTime,StudyId,DeviceTime)$StudyId)
> >
> > 

Re: [R] (no subject)

2022-10-06 Thread Ivan Krylov
Hi Julie,

В Thu, 6 Oct 2022 10:58:51 -0400
Julie Coughlin  пишет:

> Can you send me a later version of r programming to use on my macos
> version 10.12.6? The newest r program is not compatible with my
> macbook.

Since R 4.0.0, the official builds of R require macOS ≥ 10.13. The
Homebrew project doesn't seem to have any binaries for 10.12 either,
but it should be able to build R for you:
https://formulae.brew.sh/formula/r#default

Alternatively, you can follow the guide at
https://cran.r-project.org/doc/manuals/r-release/R-admin.html and build
the source code yourself.

We have a special mailing list dedicated to Mac-related questions:
r-sig-...@r-project.org

-- 
Best regards,
Ivan

__
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] (no subject)

2022-10-06 Thread Rui Barradas

Hello,

I am not a Mac user but have you tried the official R downloads web 
site, The Comprehensive R Archive Network - CRAN?

Here is the link:

https://cran.r-project.org/

Hope this helps,

Rui Barradas

Às 15:58 de 06/10/2022, Julie Coughlin escreveu:

Hi ,
Can you send me a later version of r programming to use on my macos version
10.12.6? The newest r program is not compatible with my macbook.
Thank you, Julie :)

[[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] (no subject)

2022-10-06 Thread Julie Coughlin
Hi ,
Can you send me a later version of r programming to use on my macos version
10.12.6? The newest r program is not compatible with my macbook.
Thank you, Julie :)

[[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] Getting "Error in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Joshua Ulrich
On Thu, Oct 6, 2022 at 9:44 AM Bill Dunlap  wrote:
>
> Here is how you could have made an example that helpers could easily run.
> It also includes the fix.
>
> f <- function(print.it = FALSE) {
>pdf(file.pdf <- tempfile(fileext=".pdf"))
>series <- as.xts(setNames(sin(seq(0,10,by=.1)),
> seq(as.Date("2022-10-06"),by="weeks",len=101)))
>p <- plot(series)
>if (print.it) {
>print(p)
>}
>sm_series_2 <- smooth(series / 2)
>lines(sm_series_2, col="red")
>abline(h=0.1, col="blue")
>dev.off()
>file.pdf
> }
> > f()
> Error in plot.xy(xy.coords(x, y), type = type, ...) :
>   plot.new has not been called yet
> > f(TRUE)
> [1]
> "C:\\Users\\willi\\AppData\\Local\\Temp\\Rtmp0wX7rO\\file34843df652c.pdf"
>
> If you remove the pdf() and dev.off() I think you will see that the added
> lines do not show up.  I think plot.xts fiddles with the coordinate system
> before and after it plots so that add-ons must be done in a special way.
>

plot.xts() waits until the plot is rendered before calculating the
coordinate system. That allows users to add multiple series that have
different values for the index (x-axis) and data (y-axis).

lines() doesn't show up in your example because it's called after the
plot is rendered, and it's not rendered again after they're added.
`sm_series_2` also needs to be an xts object, otherwise lines.xts() is
not dispatched.

title() and abline() need to be called after the plot is rendered
because they are standard graphics functions. I admit that's very
confusing... I'll see what I can do to fix that.

Here's a revised example that works for me:

f <- function(print.it = FALSE)
{
pdf(file.pdf <- tempfile(fileext=".pdf"))
series <- xts(sin(seq(0,10,by=.1)),
seq(as.Date("2022-10-06"),by="weeks",length.out=101))
p <- plot(series)
sm2 <- xts(smooth(series/2), index(series))
lines(sm2, col="red")
if (print.it) {
print(p)
title("Sine curve example")
abline(h=0.1, col="green")
}
dev.off()
file.pdf
}
f(TRUE)



> -Bill
>
> On Thu, Oct 6, 2022 at 12:42 AM Deramus, Thomas Patrick <
> tdera...@partners.org> wrote:
>
> > Hi Rolf.
> >
> > I followed your suggestion (though it's probably not as trimmed as it
> > could be), but the problem unfortunately persists.
> >
> > Does this make it any clearer or still too many moving parts to make sense
> > of?
> >
> > rm(list = ls(all.names = TRUE)) #will clear all objects includes hidden
> > objects.
> >
> > #Loads the packages
> > library(plyr)
> > library(dplyr)
> > library(ggplot2)
> > library(Kendall)
> > library(lubridate)
> > library(xts)
> > library(TTR)
> > library(trend)
> > library(forecast)
> > library(openxlsx)
> >
> > #Uses the learningCurve Package from Github:
> > #https://github.com/AFIT-R/learningCurve
> > library(learningCurve)
> >
> > #Only load this if using VS Studio because it changes the plot function
> > #
> > https://stackoverflow.com/questions/52284345/how-to-show-r-graph-from-visual-studio-code
> > library(httpgd)
> > library(languageserver)
> >
> > #Loads the Excel files to Dataframes and cleans the data
> > Game_Metrics_Word_Task <-
> > read.xlsx("GamePack_Analytics_ALL_TIME_Short.xlsx", "Boggle")
> > Game_Metrics_Word_Task <- Game_Metrics_Word_Task %>% filter(grepl('1440',
> > StudyId))
> > Game_Metrics_Word_Task$DeviceTime <-
> > ymd_hms(Game_Metrics_Word_Task$DeviceTime,  tz = "America/New_York")
> > Game_Metrics_Word_Task <-
> > Game_Metrics_Word_Task[!duplicated(Game_Metrics_Word_Task[1:2,])]
> >
> > #Splits the dataframe into a tibble containing each participant
> > Participant_Word_Task <-
> > split(arrange(Game_Metrics_Word_Task,StudyId,DeviceTime),
> > arrange(Game_Metrics_Word_Task,StudyId,DeviceTime,StudyId,DeviceTime)$StudyId)
> >
> > #Generates a blank output dataframe
> > WordFrame <- data.frame(Participant = c(0), Task = c(0), MannKendall_Tau =
> > c(0), MannKendall_P = c(0), Sen_Slope_Value = c(0), Sen_Slope_Pval = c(0),
> > Pettitts_CIV = c(0), Pettitts_Pval = c(0), ARIMA_Model = c(0),
> > Time_to_Petit = c(0), Number_of_Trials_to_Pettitt = c(0),
> > Playtime_to_Petit_seconds = c(0), Time_Start_to_end_days = c(0),
> > Number_of_Total_Trials = c(0), Total_Playtime_seconds = c(0),
> > Learning_rate_days = c(0), Learning_rate_seconds = c(0), Learned_Task =
> > c(0))
> >
> > #The number of subjects in the xlsx file
> > #Reduced to 2 for ease of use
> > for (i in 1:2){
> >   #This timeseries only includes the trials where the participant
> > completed the task
> >   success_series <- xts(filter(Participant_Word_Task[[i]], GameEndReason
> > == "TIMER_UP")$NumberOfSuccesfulWords , 
> > order.by=as.POSIXct(filter(Participant_Word_Task[[i]],
> > GameEndReason == "TIMER_UP")$DeviceTime))
> >   #This timeseries includes ALL the trials for the sake of plotting
> >   original_series <-
> > xts(Participant_Word_Task[[i]]$NumberOfSuccesfulWords, order.by
> > =as.POSIXct(Participant_Word_Task[[i]]$DeviceTime))
> >
> >   #This is a 

Re: [R] Fixed effect model: different estimation approaches with R return different results

2022-10-06 Thread Valerio Leone Sciabolazza
Thank you Bert, I see your point.
The problem is that I am not sure if this is a statistical issue -
i.e., there is something wrong with my procedure - or, in a manner of
speaking, a software issue: e.g. lm is not expected to return the same
estimates for different approaches because of the way in which the
function estimates the solution, and it should not be used the way I
do. Maybe I should have better stressed this.
Valerio


On Thu, Oct 6, 2022 at 4:31 PM Bert Gunter  wrote:
>
> You could get lucky here, but strictly speaking, this list is about R 
> programming and statistical issues are typically off topic Someone might 
> respond privately, though.
>
> Cheers,
> Bert
>
> On Thu, Oct 6, 2022 at 4:24 AM Valerio Leone Sciabolazza 
>  wrote:
>>
>> Good morning,
>> I am trying to use R to estimate a fixed effects model (i.e., a panel
>> regression model controlling for unobserved time-invariant
>> heterogeneities across agents) using different estimation approaches
>> (e.g. replicating xtreg from Stata, see e.g.
>> https://www.stata.com/support/faqs/statistics/intercept-in-fixed-effects-model/).
>> I have already asked this question on different stacks exchange forums
>> and contacted package creators who dealt with this issue before, but I
>> wasn't able to obtain an answer to my doubts.
>> I hope to have better luck on this list.
>>
>> Let me introduce the problem, and note that I am using an unbalanced panel.
>>
>> The easiest way to estimate my fixed effect model is using the function lm.
>>
>> Example:
>>
>> # load packages
>> library(dplyr)
>> # set seed for replication purposes
>> set.seed(123)
>> # create toy dataset
>> x <- rnorm(4000)
>> x2 <- rnorm(length(x))
>> id <- factor(sample(500,length(x),replace=TRUE))
>> firm <- data.frame(id = id) %>%
>> group_by(id) %>%
>> mutate(firm = 1:n()) %>%
>> pull(firm)
>> id.eff <- rlnorm(nlevels(id))
>> firm.eff <- rexp(length(unique(firm)))
>> y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
>> db = data.frame(y = y, x = x, id = id, firm = firm)
>> rm <- db %>% group_by(id) %>% summarise(firm = max(firm)) %>%
>> filter(firm == 1) %>% pull(id)
>> db = db[-which(db$id %in% rm), ]
>> # Run regression
>> test <- lm(y ~ x + id, data = db)
>>
>> Another approach is demeaning the variables included into the model
>> specification.
>> In this way, one can exclude the fixed effects from the model. Of
>> course, point estimates will be correct, while standard errors will be
>> not (because we are not accounting for the degrees of freedom used in
>> the demeaning).
>>
>> # demean data
>> dbm <- as_tibble(db) %>%
>> group_by(id) %>%
>> mutate(y = y - mean(y),
>>x = x - mean(x)) %>%
>> ungroup()
>> # run regression
>> test2 <- lm(y ~ x, data = dbm)
>> # compare results
>> summary(test)$coefficients[2,1]
>> > 0.9753364
>> summary(test2)$coefficients[2,1]
>> > 0.9753364
>>
>> Another way to do this is to demean the variables and add their grand
>> average (I believe that this is what xtreg from Stata does)
>>
>> # create data
>> n = length(unique(db$id))
>> dbh <- dbm %>%
>> mutate(yh = y + (sum(db$y)/n),
>>xh = x + (sum(db$x)/n))
>> # run regression
>> test3 <- lm(yh ~ xh, dbh)
>> # compare results
>> summary(test)$coefficients[2,1]
>> > 0.9753364
>> summary(test2)$coefficients[2,1]
>> > 0.9753364
>> summary(test3)$coefficients[2,1]
>> > 0.9753364
>>
>> As one can see, the three approaches report the same point estimates
>> (again, standard errors will be different instead).
>>
>> When I include an additional set of fixed effects in the model
>> specification, the three approaches no longer return the same point
>> estimate. However, differences seem to be negligible and they could be
>> due to rounding.
>>
>> db$firm <- as.factor(db$firm)
>> dbm$firm <- as.factor(dbm$firm)
>> dbh$firm <- as.factor(dbh$firm)
>> testB <- lm(y ~ x + id + firm, data = db)
>> testB2 <- lm(y ~ x + firm, data = dbm)
>> testB3 <- lm(yh ~ xh + firm, data = dbh)
>> summary(testB)$coefficients[2,1]
>> > 0.9834414
>> summary(testB2)$coefficients[2,1]
>> > 0.984
>> summary(testB3)$coefficients[2,1]
>> > 0.984
>>
>> A similar behavior occurs if I use a dummy variable rather than a
>> continous one. For the only purpose of the example, I show this by
>> transforming my target variable x from a continuous to a dummy
>> variable.
>>
>> # create data
>> x3 <- ifelse(db$x > 0, 1, 0)
>> db <- db %>% mutate(x3 = x3)
>> dbm <- dbm %>%
>> mutate(x3 = x3) %>%
>> group_by(id) %>%
>> mutate(x3 = x3 - mean(x3)) %>%
>> ungroup()
>> dbh <- dbh %>% mutate(x3 = dbm$x3) %>%
>> mutate(x3 = x3 + (sum(db$x3)/n)) %>%
>> ungroup()
>> # Run regressions
>> testC <- lm(y ~ x3 + id + firm, data = db)
>> testC2 <- lm(y ~ x3 + firm, data = dbm)
>> testC3 <- lm(yh ~ x3 + firm, data = dbh)
>> summary(testC)$coefficients[2, 1]
>> > 1.579883
>> summary(testC2)$coefficients[2, 1]
>> > 1.579159
>> summary(testC3)$coefficients[2, 1]
>> > 1.579159
>>
>> Now, I want to estimate both the impact 

Re: [R] Getting "Error in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Bill Dunlap
Here is how you could have made an example that helpers could easily run.
It also includes the fix.

f <- function(print.it = FALSE) {
   pdf(file.pdf <- tempfile(fileext=".pdf"))
   series <- as.xts(setNames(sin(seq(0,10,by=.1)),
seq(as.Date("2022-10-06"),by="weeks",len=101)))
   p <- plot(series)
   if (print.it) {
   print(p)
   }
   sm_series_2 <- smooth(series / 2)
   lines(sm_series_2, col="red")
   abline(h=0.1, col="blue")
   dev.off()
   file.pdf
}
> f()
Error in plot.xy(xy.coords(x, y), type = type, ...) :
  plot.new has not been called yet
> f(TRUE)
[1]
"C:\\Users\\willi\\AppData\\Local\\Temp\\Rtmp0wX7rO\\file34843df652c.pdf"

If you remove the pdf() and dev.off() I think you will see that the added
lines do not show up.  I think plot.xts fiddles with the coordinate system
before and after it plots so that add-ons must be done in a special way.

-Bill

On Thu, Oct 6, 2022 at 12:42 AM Deramus, Thomas Patrick <
tdera...@partners.org> wrote:

> Hi Rolf.
>
> I followed your suggestion (though it's probably not as trimmed as it
> could be), but the problem unfortunately persists.
>
> Does this make it any clearer or still too many moving parts to make sense
> of?
>
> rm(list = ls(all.names = TRUE)) #will clear all objects includes hidden
> objects.
>
> #Loads the packages
> library(plyr)
> library(dplyr)
> library(ggplot2)
> library(Kendall)
> library(lubridate)
> library(xts)
> library(TTR)
> library(trend)
> library(forecast)
> library(openxlsx)
>
> #Uses the learningCurve Package from Github:
> #https://github.com/AFIT-R/learningCurve
> library(learningCurve)
>
> #Only load this if using VS Studio because it changes the plot function
> #
> https://stackoverflow.com/questions/52284345/how-to-show-r-graph-from-visual-studio-code
> library(httpgd)
> library(languageserver)
>
> #Loads the Excel files to Dataframes and cleans the data
> Game_Metrics_Word_Task <-
> read.xlsx("GamePack_Analytics_ALL_TIME_Short.xlsx", "Boggle")
> Game_Metrics_Word_Task <- Game_Metrics_Word_Task %>% filter(grepl('1440',
> StudyId))
> Game_Metrics_Word_Task$DeviceTime <-
> ymd_hms(Game_Metrics_Word_Task$DeviceTime,  tz = "America/New_York")
> Game_Metrics_Word_Task <-
> Game_Metrics_Word_Task[!duplicated(Game_Metrics_Word_Task[1:2,])]
>
> #Splits the dataframe into a tibble containing each participant
> Participant_Word_Task <-
> split(arrange(Game_Metrics_Word_Task,StudyId,DeviceTime),
> arrange(Game_Metrics_Word_Task,StudyId,DeviceTime,StudyId,DeviceTime)$StudyId)
>
> #Generates a blank output dataframe
> WordFrame <- data.frame(Participant = c(0), Task = c(0), MannKendall_Tau =
> c(0), MannKendall_P = c(0), Sen_Slope_Value = c(0), Sen_Slope_Pval = c(0),
> Pettitts_CIV = c(0), Pettitts_Pval = c(0), ARIMA_Model = c(0),
> Time_to_Petit = c(0), Number_of_Trials_to_Pettitt = c(0),
> Playtime_to_Petit_seconds = c(0), Time_Start_to_end_days = c(0),
> Number_of_Total_Trials = c(0), Total_Playtime_seconds = c(0),
> Learning_rate_days = c(0), Learning_rate_seconds = c(0), Learned_Task =
> c(0))
>
> #The number of subjects in the xlsx file
> #Reduced to 2 for ease of use
> for (i in 1:2){
>   #This timeseries only includes the trials where the participant
> completed the task
>   success_series <- xts(filter(Participant_Word_Task[[i]], GameEndReason
> == "TIMER_UP")$NumberOfSuccesfulWords , 
> order.by=as.POSIXct(filter(Participant_Word_Task[[i]],
> GameEndReason == "TIMER_UP")$DeviceTime))
>   #This timeseries includes ALL the trials for the sake of plotting
>   original_series <-
> xts(Participant_Word_Task[[i]]$NumberOfSuccesfulWords, order.by
> =as.POSIXct(Participant_Word_Task[[i]]$DeviceTime))
>
>   #This is a decomposing process that xts seems to need for plotting.
>   #nweeks is needed for xts to plot the x-axis
>   success_decomp <- ts(success_series, frequency = nweeks(success_series))
>   original_decomp <- ts(original_series, frequency =
> nweeks(success_series))
>
>   #Values which will be included in the plots
>   WordFrame[i,1] <- unique(Participant_Word_Task[[i]]$StudyId)
>   WordFrame[i,5] <- sens.slope(success_decomp)$estimates
>   WordFrame[i,6] <- sens.slope(success_decomp)$p.value
>   WordFrame[i,7] <- pettitt.test(success_decomp)$estimate
>   WordFrame[i,8] <- pettitt.test(success_decomp)$p.value
>
>   #The simple moving average that will be overlayed with the plotted data
>   simplemovingaverage <- SMA(original_series, n = nweeks(original_series))
>
>   #If the three tests are statistically significant, add a green
> horizontal like to value WordFrame[i,7]
>   #Which would be where the slope changes in the series
>   #Fluid variables have been removed from all pdf() and paste() functions
> for ease-of-use
>   if (WordFrame[i,4] <= 0.05 & WordFrame[i,6] <= 0.05 & WordFrame[i,8] <=
> 0.05){
>  {
>   pdf(file = "Word_Task_Acquisition.pdf")
>   plout <- plot(original_series)
>   lines(simplemovingaverage)
>   abline(v = index(original_series[WordFrame[i,7]]),lty=2,
> col='green', lwd=3)
> 

Re: [R] Fixed effect model: different estimation approaches with R return different results

2022-10-06 Thread Bert Gunter
You could get lucky here, but strictly speaking, this list is about R
programming and statistical issues are typically off topic Someone might
respond privately, though.

Cheers,
Bert

On Thu, Oct 6, 2022 at 4:24 AM Valerio Leone Sciabolazza <
sciabola...@gmail.com> wrote:

> Good morning,
> I am trying to use R to estimate a fixed effects model (i.e., a panel
> regression model controlling for unobserved time-invariant
> heterogeneities across agents) using different estimation approaches
> (e.g. replicating xtreg from Stata, see e.g.
>
> https://www.stata.com/support/faqs/statistics/intercept-in-fixed-effects-model/
> ).
> I have already asked this question on different stacks exchange forums
> and contacted package creators who dealt with this issue before, but I
> wasn't able to obtain an answer to my doubts.
> I hope to have better luck on this list.
>
> Let me introduce the problem, and note that I am using an unbalanced panel.
>
> The easiest way to estimate my fixed effect model is using the function lm.
>
> Example:
>
> # load packages
> library(dplyr)
> # set seed for replication purposes
> set.seed(123)
> # create toy dataset
> x <- rnorm(4000)
> x2 <- rnorm(length(x))
> id <- factor(sample(500,length(x),replace=TRUE))
> firm <- data.frame(id = id) %>%
> group_by(id) %>%
> mutate(firm = 1:n()) %>%
> pull(firm)
> id.eff <- rlnorm(nlevels(id))
> firm.eff <- rexp(length(unique(firm)))
> y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
> db = data.frame(y = y, x = x, id = id, firm = firm)
> rm <- db %>% group_by(id) %>% summarise(firm = max(firm)) %>%
> filter(firm == 1) %>% pull(id)
> db = db[-which(db$id %in% rm), ]
> # Run regression
> test <- lm(y ~ x + id, data = db)
>
> Another approach is demeaning the variables included into the model
> specification.
> In this way, one can exclude the fixed effects from the model. Of
> course, point estimates will be correct, while standard errors will be
> not (because we are not accounting for the degrees of freedom used in
> the demeaning).
>
> # demean data
> dbm <- as_tibble(db) %>%
> group_by(id) %>%
> mutate(y = y - mean(y),
>x = x - mean(x)) %>%
> ungroup()
> # run regression
> test2 <- lm(y ~ x, data = dbm)
> # compare results
> summary(test)$coefficients[2,1]
> > 0.9753364
> summary(test2)$coefficients[2,1]
> > 0.9753364
>
> Another way to do this is to demean the variables and add their grand
> average (I believe that this is what xtreg from Stata does)
>
> # create data
> n = length(unique(db$id))
> dbh <- dbm %>%
> mutate(yh = y + (sum(db$y)/n),
>xh = x + (sum(db$x)/n))
> # run regression
> test3 <- lm(yh ~ xh, dbh)
> # compare results
> summary(test)$coefficients[2,1]
> > 0.9753364
> summary(test2)$coefficients[2,1]
> > 0.9753364
> summary(test3)$coefficients[2,1]
> > 0.9753364
>
> As one can see, the three approaches report the same point estimates
> (again, standard errors will be different instead).
>
> When I include an additional set of fixed effects in the model
> specification, the three approaches no longer return the same point
> estimate. However, differences seem to be negligible and they could be
> due to rounding.
>
> db$firm <- as.factor(db$firm)
> dbm$firm <- as.factor(dbm$firm)
> dbh$firm <- as.factor(dbh$firm)
> testB <- lm(y ~ x + id + firm, data = db)
> testB2 <- lm(y ~ x + firm, data = dbm)
> testB3 <- lm(yh ~ xh + firm, data = dbh)
> summary(testB)$coefficients[2,1]
> > 0.9834414
> summary(testB2)$coefficients[2,1]
> > 0.984
> summary(testB3)$coefficients[2,1]
> > 0.984
>
> A similar behavior occurs if I use a dummy variable rather than a
> continous one. For the only purpose of the example, I show this by
> transforming my target variable x from a continuous to a dummy
> variable.
>
> # create data
> x3 <- ifelse(db$x > 0, 1, 0)
> db <- db %>% mutate(x3 = x3)
> dbm <- dbm %>%
> mutate(x3 = x3) %>%
> group_by(id) %>%
> mutate(x3 = x3 - mean(x3)) %>%
> ungroup()
> dbh <- dbh %>% mutate(x3 = dbm$x3) %>%
> mutate(x3 = x3 + (sum(db$x3)/n)) %>%
> ungroup()
> # Run regressions
> testC <- lm(y ~ x3 + id + firm, data = db)
> testC2 <- lm(y ~ x3 + firm, data = dbm)
> testC3 <- lm(yh ~ x3 + firm, data = dbh)
> summary(testC)$coefficients[2, 1]
> > 1.579883
> summary(testC2)$coefficients[2, 1]
> > 1.579159
> summary(testC3)$coefficients[2, 1]
> > 1.579159
>
> Now, I want to estimate both the impact of x when this is higher than
> 0 (i.e., x3) and when this is lower or equal to zero (call it x4).
> Again, observe that x3 might as well be a real dummy variable, not a
> transformation of a continuous variable.
>
> In order to do that, I exclude the intercept from my model.
> Specifically, I do the following:
>
> # create data
> x4 <- ifelse(db$x <= 0, 1, 0)
> db <- db %>% mutate(x4 = x4)
> dbm <- dbm %>%
> mutate(x4 = x4) %>%
> group_by(id) %>%
> mutate(x4 = x4 - mean(x4)) %>%
> ungroup()
> dbh <- dbh %>% mutate(x4 = dbm$x4) %>%
> mutate(x4 = x4 + (sum(db$x4)/n)) %>%
> ungroup()
> testD <- lm(y 

Re: [R] R version 4.2.1 install.packages does not work with IE proxy setting

2022-10-06 Thread PIKAL Petr
Hallo Howard

Thanks, for the time being the previous workaround with wininet options
works for me. I will wait for the new R version and then try to persuade our
IT to make relevant changes.

Cheers
Petr

> -Original Message-
> From: Howard, Tim G (DEC) 
> Sent: Thursday, October 6, 2022 1:09 PM
> To: r-help@r-project.org; PIKAL Petr 
> Subject: Re: [R]  R version 4.2.1 install.packages does not work with IE
proxy
> setting
> 
> Petr,
> You also might want to check out the bug reported here:
> 
> https://bugs.r-project.org/show_bug.cgi?id=18379
> 
> it was fixed and the last two comments discuss how to handle it in
Windows:
> 
> you add a new User Environment Variable:
> R_LIBCURL_SSL_REVOKE_BEST_EFFORT and set it to TRUE
> 
> This fix is in R-4.2.1 Patched (I don't know if it has made it out to the
full
> distribution) and works in my 'corporate' environment.  Perhaps it also
applies
> to your environment.
> 
> Tim
> 
> 
> Date: Wed, 5 Oct 2022 10:34:02 +
> From: PIKAL Petr 
> To: Ivan Krylov 
> Cc: r-help mailing list 
> Subject: Re: [R]  R version 4.2.1 install.packages does not work with
>     IE proxy setting
> Message-ID:
>     <9b38aacf51d746bb87a9cc3765a16...@srvexchcm1302.precheza.cz>
> Content-Type: text/plain; charset="us-ascii"
> 
> Thanks,
> 
> the workaround works but we need try the "permanent" solution with
> Renviron.site file in future.
> 
> Cheers
> Petr
> 
> > -Original Message-
> > From: Ivan Krylov 
> > Sent: Tuesday, October 4, 2022 5:43 PM
> > To: PIKAL Petr 
> > Cc: r-help mailing list 
> > Subject: Re: [R] R version 4.2.1 install.packages does not work with
> > IE
> proxy
> > setting
> >
> > On Tue, 4 Oct 2022 11:01:14 +
> > PIKAL Petr  wrote:
> >
> > > After we installed new R version R 4.2.1 installing packages through
> > > IE proxy setting is compromised with warning that R could not
> > > connect to server (tested in vanilla R).
> >
> > R 4.1 deprecated the use of download.file(method = 'wininet'). R 4.2
> switched
> > the default download method to 'libcurl' and started giving warnings
> > for 'wininet' and http[s]:// URLs.
> >
> > A workaround to get it working right now would be to set
> > options(download.file.method = 'wininet') and live with the resulting
> warnings
> > while R downloads the files, but a next version of R may remove
'wininet'
> > support altogether.
> >
> > In order to get it working with the 'libcurl' method, you'll need to
> provide some
> > environment variables to curl:
> > https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat
> > .ethz.ch%2Fpipermail%2Fr-help%2F2022-
> September%2F475917.htmldata=
> >
> 05%7C01%7Ctim.howard%40dec.ny.gov%7C1b8601d6e602486b347508daa7
> 81d26e%7
> >
> Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C63800647328501003
> 4%7CUnkno
> >
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> WwiL
> >
> CJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=7w1P6Sfu7V3DUM4a3Ez
> gmf87bXn8Cn
> > C%2FipTvXfBpI0c%3Dreserved=0
> >
> > Not sure if libcurl would accept a patch to discover the Windows proxy
> settings
> > automatically, but I don't think it does that now.
> >
> > --
> > Best regards,
> > Ivan

__
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] Fixed effect model: different estimation approaches with R return different results

2022-10-06 Thread Valerio Leone Sciabolazza
Good morning,
I am trying to use R to estimate a fixed effects model (i.e., a panel
regression model controlling for unobserved time-invariant
heterogeneities across agents) using different estimation approaches
(e.g. replicating xtreg from Stata, see e.g.
https://www.stata.com/support/faqs/statistics/intercept-in-fixed-effects-model/).
I have already asked this question on different stacks exchange forums
and contacted package creators who dealt with this issue before, but I
wasn't able to obtain an answer to my doubts.
I hope to have better luck on this list.

Let me introduce the problem, and note that I am using an unbalanced panel.

The easiest way to estimate my fixed effect model is using the function lm.

Example:

# load packages
library(dplyr)
# set seed for replication purposes
set.seed(123)
# create toy dataset
x <- rnorm(4000)
x2 <- rnorm(length(x))
id <- factor(sample(500,length(x),replace=TRUE))
firm <- data.frame(id = id) %>%
group_by(id) %>%
mutate(firm = 1:n()) %>%
pull(firm)
id.eff <- rlnorm(nlevels(id))
firm.eff <- rexp(length(unique(firm)))
y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
db = data.frame(y = y, x = x, id = id, firm = firm)
rm <- db %>% group_by(id) %>% summarise(firm = max(firm)) %>%
filter(firm == 1) %>% pull(id)
db = db[-which(db$id %in% rm), ]
# Run regression
test <- lm(y ~ x + id, data = db)

Another approach is demeaning the variables included into the model
specification.
In this way, one can exclude the fixed effects from the model. Of
course, point estimates will be correct, while standard errors will be
not (because we are not accounting for the degrees of freedom used in
the demeaning).

# demean data
dbm <- as_tibble(db) %>%
group_by(id) %>%
mutate(y = y - mean(y),
   x = x - mean(x)) %>%
ungroup()
# run regression
test2 <- lm(y ~ x, data = dbm)
# compare results
summary(test)$coefficients[2,1]
> 0.9753364
summary(test2)$coefficients[2,1]
> 0.9753364

Another way to do this is to demean the variables and add their grand
average (I believe that this is what xtreg from Stata does)

# create data
n = length(unique(db$id))
dbh <- dbm %>%
mutate(yh = y + (sum(db$y)/n),
   xh = x + (sum(db$x)/n))
# run regression
test3 <- lm(yh ~ xh, dbh)
# compare results
summary(test)$coefficients[2,1]
> 0.9753364
summary(test2)$coefficients[2,1]
> 0.9753364
summary(test3)$coefficients[2,1]
> 0.9753364

As one can see, the three approaches report the same point estimates
(again, standard errors will be different instead).

When I include an additional set of fixed effects in the model
specification, the three approaches no longer return the same point
estimate. However, differences seem to be negligible and they could be
due to rounding.

db$firm <- as.factor(db$firm)
dbm$firm <- as.factor(dbm$firm)
dbh$firm <- as.factor(dbh$firm)
testB <- lm(y ~ x + id + firm, data = db)
testB2 <- lm(y ~ x + firm, data = dbm)
testB3 <- lm(yh ~ xh + firm, data = dbh)
summary(testB)$coefficients[2,1]
> 0.9834414
summary(testB2)$coefficients[2,1]
> 0.984
summary(testB3)$coefficients[2,1]
> 0.984

A similar behavior occurs if I use a dummy variable rather than a
continous one. For the only purpose of the example, I show this by
transforming my target variable x from a continuous to a dummy
variable.

# create data
x3 <- ifelse(db$x > 0, 1, 0)
db <- db %>% mutate(x3 = x3)
dbm <- dbm %>%
mutate(x3 = x3) %>%
group_by(id) %>%
mutate(x3 = x3 - mean(x3)) %>%
ungroup()
dbh <- dbh %>% mutate(x3 = dbm$x3) %>%
mutate(x3 = x3 + (sum(db$x3)/n)) %>%
ungroup()
# Run regressions
testC <- lm(y ~ x3 + id + firm, data = db)
testC2 <- lm(y ~ x3 + firm, data = dbm)
testC3 <- lm(yh ~ x3 + firm, data = dbh)
summary(testC)$coefficients[2, 1]
> 1.579883
summary(testC2)$coefficients[2, 1]
> 1.579159
summary(testC3)$coefficients[2, 1]
> 1.579159

Now, I want to estimate both the impact of x when this is higher than
0 (i.e., x3) and when this is lower or equal to zero (call it x4).
Again, observe that x3 might as well be a real dummy variable, not a
transformation of a continuous variable.

In order to do that, I exclude the intercept from my model.
Specifically, I do the following:

# create data
x4 <- ifelse(db$x <= 0, 1, 0)
db <- db %>% mutate(x4 = x4)
dbm <- dbm %>%
mutate(x4 = x4) %>%
group_by(id) %>%
mutate(x4 = x4 - mean(x4)) %>%
ungroup()
dbh <- dbh %>% mutate(x4 = dbm$x4) %>%
mutate(x4 = x4 + (sum(db$x4)/n)) %>%
ungroup()
testD <- lm(y ~ x3 + x4 + id + firm - 1, data = db)
testD2 <- lm(y ~ x3 + x4 + firm - 1, data = dbm)
testD3 <- lm(yh ~ x3 + x4 + firm - 1, data = dbh)
summary(testD)$coefficients[1:2, ]
> 1.2372816 -0.3426011
summary(testD2)
> Call:
lm(formula = y ~ x3 + x4 + firm - 1, data = dbm)

Residuals:
Min  1Q  Median  3Q Max
-3.8794 -0.7497  0.0010  0.7442  3.8486

Coefficients: (1 not defined because of singularities)
   Estimate Std. Error t value Pr(>|t|)
x3  1.579160.03779  41.788  < 2e-16 ***
x4   NA NA  NA   NA
... 

Re: [R] R version 4.2.1 install.packages does not work with IE proxy setting

2022-10-06 Thread Howard, Tim G (DEC) via R-help
Petr, 
You also might want to check out the bug reported here:

https://bugs.r-project.org/show_bug.cgi?id=18379

it was fixed and the last two comments discuss how to handle it in Windows:

you add a new User Environment Variable:
R_LIBCURL_SSL_REVOKE_BEST_EFFORT and set it to TRUE

This fix is in R-4.2.1 Patched (I don't know if it has made it out to the full 
distribution) and works in my 'corporate' environment.  Perhaps it also applies 
to your environment. 

Tim


Date: Wed, 5 Oct 2022 10:34:02 +
From: PIKAL Petr 
To: Ivan Krylov 
Cc: r-help mailing list 
Subject: Re: [R]  R version 4.2.1 install.packages does not work with
    IE proxy setting
Message-ID:
    <9b38aacf51d746bb87a9cc3765a16...@srvexchcm1302.precheza.cz>
Content-Type: text/plain; charset="us-ascii"

Thanks,

the workaround works but we need try the "permanent" solution with
Renviron.site file in future.

Cheers
Petr

> -Original Message-
> From: Ivan Krylov 
> Sent: Tuesday, October 4, 2022 5:43 PM
> To: PIKAL Petr 
> Cc: r-help mailing list 
> Subject: Re: [R] R version 4.2.1 install.packages does not work with IE
proxy
> setting
>
> On Tue, 4 Oct 2022 11:01:14 +
> PIKAL Petr  wrote:
>
> > After we installed new R version R 4.2.1 installing packages through
> > IE proxy setting is compromised with warning that R could not connect
> > to server (tested in vanilla R).
>
> R 4.1 deprecated the use of download.file(method = 'wininet'). R 4.2
switched
> the default download method to 'libcurl' and started giving warnings for
> 'wininet' and http[s]:// URLs.
>
> A workaround to get it working right now would be to set
> options(download.file.method = 'wininet') and live with the resulting
warnings
> while R downloads the files, but a next version of R may remove 'wininet'
> support altogether.
>
> In order to get it working with the 'libcurl' method, you'll need to
provide some
> environment variables to curl:
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fpipermail%2Fr-help%2F2022-September%2F475917.htmldata=05%7C01%7Ctim.howard%40dec.ny.gov%7C1b8601d6e602486b347508daa781d26e%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638006473285010034%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=7w1P6Sfu7V3DUM4a3Ezgmf87bXn8CnC%2FipTvXfBpI0c%3Dreserved=0
>
> Not sure if libcurl would accept a patch to discover the Windows proxy
settings
> automatically, but I don't think it does that now.
>
> --
> Best regards,
> Ivan


__
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 in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Deramus, Thomas Patrick
I had to place it right before the title and abline functions like so:

for (i in 1:length(Participant_Word_Task)){
success_series <- xts(filter(Participant_Word_Task[[i]], GameEndReason == 
"TIMER_UP")$NumberOfSuccesfulWords , 
order.by=as.POSIXct(filter(Participant_Word_Task[[i]], GameEndReason == 
"TIMER_UP")$DeviceTime))
original_series <- xts(Participant_Word_Task[[i]]$NumberOfSuccesfulWords, 
order.by=as.POSIXct(Participant_Word_Task[[i]]$DeviceTime))
success_decomp <- ts(success_series, frequency = nweeks(success_series))
original_decomp <- ts(original_series, frequency = nweeks(success_series))
WordFrame[i,1] <- unique(Participant_Word_Task[[i]]$StudyId)
WordFrame[i,2] <- "Boggle"
WordFrame[i,3] <- MannKendall(success_decomp)$tau[1]
WordFrame[i,4] <- MannKendall(success_decomp)$sl[1]
WordFrame[i,5] <- sens.slope(success_decomp)$estimates
WordFrame[i,6] <- sens.slope(success_decomp)$p.value
WordFrame[i,7] <- pettitt.test(success_decomp)$estimate
WordFrame[i,8] <- pettitt.test(success_decomp)$p.value
WordFrame[i,10] <- 
difftime(time(success_series[WordFrame[i,7]]),time(original_series[1]))
WordFrame[i,11] <- tail(which(grepl(success_series[WordFrame[i,7]], 
original_series)), n=1)
WordFrame[i,12] <- 
sum(Participant_Word_Task[[i]]$TotalDuration[1:WordFrame[i,11]])-sum(Participant_Word_Task[[i]]$TotalTimePaused[1:WordFrame[i,11]])
WordFrame[i,13] <- 
difftime(time(original_series[length(original_series)]),time(original_series[1]))
WordFrame[i,14] <- length(original_series)
WordFrame[i,15] <- 
sum(Participant_Word_Task[[i]]$TotalDuration[1:length(original_series)])-sum(Participant_Word_Task[[i]]$TotalTimePaused[1:length(original_series)])


simplemovingaverage <- SMA(original_series, n = nweeks(original_series))
if (WordFrame[i,4] <= 0.05 & WordFrame[i,6] <= 0.05 & WordFrame[i,8] <= 
0.05){

 lines(simplemovingaverage,type='l',col='red'); title(paste("Word Task 
Acquisition for Subject", WordFrame[i,1])); abline(v = 
index(original_series[WordFrame[i,7]]),lty=2, col='green', lwd=3); dev.off()
  {
  pdf(file = paste(WordFrame[i,1],"_Word_Task_Acquisition.pdf",collapse = 
NULL, sep = ""))
  plout <- plot(original_series,type='l',col='blue',xlab="Date of 
Play",ylab="Number of Successful Words")
  lines(simplemovingaverage,type='l',col='red')
  print(plout)
  title(paste("Word Task Acquisition for Subject", WordFrame[i,1]))
  abline(v = index(original_series[WordFrame[i,7]]),lty=2, col='green', 
lwd=3)
  dev.off()
  }

  WordFrame[i,18] <- T
  WordFrame[i,16] <- (1-(WordFrame[i,10]/WordFrame[i,13]))
  WordFrame[i,17] <- (1-(WordFrame[i,12]/WordFrame[i,15]))
} else {
  {
  pdf(file = paste(WordFrame[i,1],"_Word_Task_Acquisition.pdf",collapse = 
NULL, sep = ""))
  plout <- plot(original_series,type='l',col='blue',xlab="Date of 
Play",ylab="Number of Successful Words")
  lines(simplemovingaverage,type='l',col='red')
  print(plout)
  title(paste("Word Task Acquisition for Subject", WordFrame[i,1]))
  dev.off()
  }

  WordFrame[i,18] <- F
  WordFrame[i,16] <- 0
  WordFrame[i,17] <- 0
}
}
​
But as soon as I did that it worked!

Thank you so much!

From: Joshua Ulrich 
Sent: Wednesday, October 5, 2022 9:16 PM
To: Deramus, Thomas Patrick 
Cc: R-Help 
Subject: Re: [R] Getting "Error in ect, plot.new has not been called yet" 
despite grouping plot call


External Email - Use Caution

Hi,

My hunch is that you need to add print(plout) before you call dev.off(). See 
https://stackoverflow.com/a/39853861

Try that and let me know if that works. If not, I'll take a closer look later.

Best,
Josh


On Wed, Oct 5, 2022, 1:40 AM Deramus, Thomas Patrick 
mailto:tdera...@partners.org>> wrote:
Sorry to cross-post on Stackoverflow and here but I'm having some difficulty.
https://stackoverflow.com/questions/73942794/still-getting-error-in-ect-plot-new-has-not-been-called-yet-despite-grouping

Trying to make a nested loop that produces PDFs 

Re: [R] Getting "Error in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Deramus, Thomas Patrick
Odd. Thought I had attached it.

Would love to go that route, but the problem is a lot of the sub-bits are 
actually dependent on the values of the timeseries analysis, which has its own 
dependencies..

Would using the following link to download the excel file help at all?
https://docs.google.com/spreadsheets/d/1rPd8bv4WADCdEUhmem-u1-6HWUXKne7b/edit?usp=sharing=110307531005009211602=true=true



From: Rolf Turner 
Sent: Wednesday, October 5, 2022 6:28 PM
To: Deramus, Thomas Patrick 
Cc: r-help@r-project.org 
Subject: Re: [R] Getting "Error in ect, plot.new has not been called yet" 
despite grouping plot call

External Email - Use Caution


Your code is still much too complex for my feeble brain.

Without trying to understand very much, I get the impression that the
example is *not* reproducible.  It requires reading in Excel (yeucchh!)
files to which no-one but you has access.

Skip the reading-in completely.  Create toy data using rnorm() instead.
Then someone may be able to help you.

On Wed, 5 Oct 2022 13:32:00 +
"Deramus, Thomas Patrick"  wrote:

> Hi Rolf.
>
> I followed your suggestion (though it's probably not as trimmed as it
> could be), but the problem unfortunately persists.

If the problem *didn't* persist, then *that* would have been
unfortunate!  The idea is to reproduce the problem in a simpler context
so that one can deduce what is causing the problem!

> Does this make it any clearer or still too many moving parts to make
> sense of?

There are still (far) too many moving parts, for me anyway.  Someone
cleverer than I might be able to see what the problem is.

cheers,

Rolf

>
> rm(list = ls(all.names = TRUE)) #will clear all objects includes
> hidden objects.
>
> #Loads the packages
> library(plyr)
> library(dplyr)
> library(ggplot2)
> library(Kendall)
> library(lubridate)
> library(xts)
> library(TTR)
> library(trend)
> library(forecast)
> library(openxlsx)
>
> #Uses the learningCurve Package from Github:
> #https://secure-web.cisco.com/1GUXNs4DRqUHykKAjZUB89_m2M_KU7oUJ6jl9VAWbtn8YCzSy8qRCHe-LJf3ovhQXKpQcXQe9Bf_BwKHFn4-A8AvtoD_tuXR-jsEcSsEQp-B3sET59hXmBKs_B1M7u2zUxnGNqVZnxYNeip71STXGupngENp0IjZfxd48SZHkztp5CLHFpsdHgz7wHHwePlSTMG8yKmYcS7N6OSkoxENvsL-vCxACXlyPFQTynaQNNjFjV7Ngl8mJpBP0G8pXX8WbogbQlE9ArbYCph6j_3IoVIN8Y6dKqRe44yoi8S3hjJ1PFgdr4JW7nve07XYaC_M-/https%3A%2F%2Fgithub.com%2FAFIT-R%2FlearningCurve
> library(learningCurve)
>
> #Only load this if using VS Studio because it changes the plot
> function
> #https://secure-web.cisco.com/14TdkUQ3Ymy411VwAMhagZmvgDM4nborDvLmLccRSdK1n3ZgXfjjdH9Xn1dVxO2s5Y9R4fZJoitgys453O-kPVFt73W5s3Qa_D078MPMxoTGV6UP55ozAuPwt9nzMGBqak6abbcX1Er2q8CwEMGQJA8AmcdQf0GyGCz8b1qYV-ck9_L4N-Yq5eTWLs2NHrklR0XpUzWvbUBGRH2LpeWPHRLtMZjW8-9T3_1sGyvCHTXDhQ-FXzifBiFtE13_qL50iO1kl8A6p3EeOR0e0-AgW-kGEfpBHGgA53VBlscnA9nqfb60sCgLaAeMz-Pc49ITI/https%3A%2F%2Fstackoverflow.com%2Fquestions%2F52284345%2Fhow-to-show-r-graph-from-visual-studio-code
> library(httpgd) library(languageserver)
>
> #Loads the Excel files to Dataframes and cleans the data
> Game_Metrics_Word_Task <-
> read.xlsx("GamePack_Analytics_ALL_TIME_Short.xlsx", "Boggle")
> Game_Metrics_Word_Task <- Game_Metrics_Word_Task %>%
> filter(grepl('1440', StudyId)) Game_Metrics_Word_Task$DeviceTime <-
> ymd_hms(Game_Metrics_Word_Task$DeviceTime,  tz = "America/New_York")
> Game_Metrics_Word_Task <-
> Game_Metrics_Word_Task[!duplicated(Game_Metrics_Word_Task[1:2,])]
>
> #Splits the dataframe into a tibble containing each participant
> Participant_Word_Task <-
> split(arrange(Game_Metrics_Word_Task,StudyId,DeviceTime),
> arrange(Game_Metrics_Word_Task,StudyId,DeviceTime,StudyId,DeviceTime)$StudyId)
>
> #Generates a blank output dataframe
> WordFrame <- data.frame(Participant = c(0), Task = c(0),
> MannKendall_Tau = c(0), MannKendall_P = c(0), Sen_Slope_Value = c(0),
> Sen_Slope_Pval = c(0), Pettitts_CIV = c(0), Pettitts_Pval = c(0),
> ARIMA_Model = c(0), Time_to_Petit = c(0), Number_of_Trials_to_Pettitt
> = c(0), Playtime_to_Petit_seconds = c(0), Time_Start_to_end_days =
> c(0), Number_of_Total_Trials = c(0), Total_Playtime_seconds = c(0),
> Learning_rate_days = c(0), Learning_rate_seconds = c(0), Learned_Task
> = c(0))
>
> #The number of subjects in the xlsx file
> #Reduced to 2 for ease of use
> for (i in 1:2){
>   #This timeseries only includes the trials where the participant
> completed the task success_series <-
> xts(filter(Participant_Word_Task[[i]], GameEndReason ==
> "TIMER_UP")$NumberOfSuccesfulWords ,
> order.by=as.POSIXct(filter(Participant_Word_Task[[i]], GameEndReason
> == "TIMER_UP")$DeviceTime)) #This timeseries includes ALL the trials
> for the sake of plotting original_series <-
> xts(Participant_Word_Task[[i]]$NumberOfSuccesfulWords,
> order.by=as.POSIXct(Participant_Word_Task[[i]]$DeviceTime))
>
>   #This is a decomposing process that xts seems to need for plotting.
>   #nweeks is needed for xts to plot the x-axis
>   success_decomp <- ts(success_series, 

Re: [R] Getting "Error in ect, plot.new has not been called yet" despite grouping plot call

2022-10-06 Thread Deramus, Thomas Patrick
Hi Rolf.

I followed your suggestion (though it's probably not as trimmed as it could 
be), but the problem unfortunately persists.

Does this make it any clearer or still too many moving parts to make sense of?

rm(list = ls(all.names = TRUE)) #will clear all objects includes hidden objects.

#Loads the packages
library(plyr)
library(dplyr)
library(ggplot2)
library(Kendall)
library(lubridate)
library(xts)
library(TTR)
library(trend)
library(forecast)
library(openxlsx)

#Uses the learningCurve Package from Github:
#https://github.com/AFIT-R/learningCurve
library(learningCurve)

#Only load this if using VS Studio because it changes the plot function
#https://stackoverflow.com/questions/52284345/how-to-show-r-graph-from-visual-studio-code
library(httpgd)
library(languageserver)

#Loads the Excel files to Dataframes and cleans the data
Game_Metrics_Word_Task <- read.xlsx("GamePack_Analytics_ALL_TIME_Short.xlsx", 
"Boggle")
Game_Metrics_Word_Task <- Game_Metrics_Word_Task %>% filter(grepl('1440', 
StudyId))
Game_Metrics_Word_Task$DeviceTime <- ymd_hms(Game_Metrics_Word_Task$DeviceTime, 
 tz = "America/New_York")
Game_Metrics_Word_Task <- 
Game_Metrics_Word_Task[!duplicated(Game_Metrics_Word_Task[1:2,])]

#Splits the dataframe into a tibble containing each participant
Participant_Word_Task <- 
split(arrange(Game_Metrics_Word_Task,StudyId,DeviceTime), 
arrange(Game_Metrics_Word_Task,StudyId,DeviceTime,StudyId,DeviceTime)$StudyId)

#Generates a blank output dataframe
WordFrame <- data.frame(Participant = c(0), Task = c(0), MannKendall_Tau = 
c(0), MannKendall_P = c(0), Sen_Slope_Value = c(0), Sen_Slope_Pval = c(0), 
Pettitts_CIV = c(0), Pettitts_Pval = c(0), ARIMA_Model = c(0), Time_to_Petit = 
c(0), Number_of_Trials_to_Pettitt = c(0), Playtime_to_Petit_seconds = c(0), 
Time_Start_to_end_days = c(0), Number_of_Total_Trials = c(0), 
Total_Playtime_seconds = c(0), Learning_rate_days = c(0), Learning_rate_seconds 
= c(0), Learned_Task = c(0))

#The number of subjects in the xlsx file
#Reduced to 2 for ease of use
for (i in 1:2){
  #This timeseries only includes the trials where the participant completed the 
task
  success_series <- xts(filter(Participant_Word_Task[[i]], GameEndReason == 
"TIMER_UP")$NumberOfSuccesfulWords , 
order.by=as.POSIXct(filter(Participant_Word_Task[[i]], GameEndReason == 
"TIMER_UP")$DeviceTime))
  #This timeseries includes ALL the trials for the sake of plotting
  original_series <- xts(Participant_Word_Task[[i]]$NumberOfSuccesfulWords, 
order.by=as.POSIXct(Participant_Word_Task[[i]]$DeviceTime))

  #This is a decomposing process that xts seems to need for plotting.
  #nweeks is needed for xts to plot the x-axis
  success_decomp <- ts(success_series, frequency = nweeks(success_series))
  original_decomp <- ts(original_series, frequency = nweeks(success_series))

  #Values which will be included in the plots
  WordFrame[i,1] <- unique(Participant_Word_Task[[i]]$StudyId)
  WordFrame[i,5] <- sens.slope(success_decomp)$estimates
  WordFrame[i,6] <- sens.slope(success_decomp)$p.value
  WordFrame[i,7] <- pettitt.test(success_decomp)$estimate
  WordFrame[i,8] <- pettitt.test(success_decomp)$p.value

  #The simple moving average that will be overlayed with the plotted data
  simplemovingaverage <- SMA(original_series, n = nweeks(original_series))

  #If the three tests are statistically significant, add a green horizontal 
like to value WordFrame[i,7]
  #Which would be where the slope changes in the series
  #Fluid variables have been removed from all pdf() and paste() functions for 
ease-of-use
  if (WordFrame[i,4] <= 0.05 & WordFrame[i,6] <= 0.05 & WordFrame[i,8] <= 0.05){
 {
  pdf(file = "Word_Task_Acquisition.pdf")
  plout <- plot(original_series)
  lines(simplemovingaverage)
  abline(v = index(original_series[WordFrame[i,7]]),lty=2, col='green', 
lwd=3)
  title(paste("Word Task Acquisition for Subject"))
  dev.off()
 }
  #If the three tests are NOT statistically significant, generate a plot with 
NO horizontal line at WordFrame[i,7]
  } else {
{
  pdf(file = "Word_Task_Acquisition.pdf")
  plout <- plot(original_series)
  lines(simplemovingaverage)
  title(paste("Word Task Acquisition for Subject"))
  dev.off()
}
  }
}


From: Rolf Turner 
Sent: Wednesday, October 5, 2022 6:06 AM
To: Deramus, Thomas Patrick 
Cc: r-help@r-project.org 
Subject: Re: [R] Getting "Error in ect, plot.new has not been called yet" 
despite grouping plot call

External Email - Use Caution

What you doing or trying to do is far too complex for my poor feeble
and senile brain to come anywhere near comprehending.  The code that
you present exceeds my complexity tolerance by many orders of magnitude.

I have a suggestion, but.  Strip your code down to the *essentials*.
Construct a simple sequence of plotting commands, with *simple* names
for the pdf files involved.  You should require only two or three such
files and two or 

Re: [R] Help installing devtools plus other packages in R terminal

2022-10-06 Thread Ivan Krylov
On Wed, 5 Oct 2022 20:02:02 +
"Rhon Calderon, Eric"  wrote:

> automake found. Running autoupdate and autogen.sh.
<...>
> + libtoolize --copy
> autogen.sh: line 43: libtoolize: command not found

Since you have automake installed, you also need libtool
 installed in order to compile
this particular package from source. Depending on the HPC, there may be
a particular command to "activate" the installation already made by the
HPC administrator.

I guess you could also report this as a bug in devtools: they check for
automake but not libtool. If you can temporarily chmod -x automake, the
installation should succeed too, because then the package will not try
to regenerate its build system. I don't see why they even try to do
that, but maybe that's a workaround for some kind of compatibility
problem.

> CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh
> '/tmp/RtmpMjF6Ns/R.INSTALL4a3cb2204b0da/httpuv/src/libuv/missing'
> aclocal-1.16 -I m4
> /tmp/RtmpMjF6Ns/R.INSTALL4a3cb2204b0da/httpuv/src/libuv/missing: line
> 81: aclocal-1.16: command not found

Make sure your automake installation is working. I think the error is
caused by the previous error and may go away once you install libtool,
but I may be mistaken regarding that.

Do Bioconductor packages really depend on devtools? What do their
errors look like?

-- 
Best regards,
Ivan

__
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 installing devtools plus other packages in R terminal

2022-10-06 Thread Andrew Simmons
To install the packages from source, you need to install make, gcc, and g++:
⁠sudo apt install make⁠
⁠sudo apt install gcc⁠
⁠sudo apt install g++

then try installing them again

On Thu, Oct 6, 2022 at 2:54 AM Rhon Calderon, Eric
 wrote:
>
> Hi,
>
> I am using R in my HPC terminal. After many tries, I was able to install and 
> exec successfully R on my HPC but now I cannot install devtools and other 
> dependencies. I need some of theses packages to install some others from 
> bioconductor. I was wondering if anybody has a solution.
>
> The script I got from my R session is (the highlighted part is the errors I 
> keep getting):
>
> > install.packages('devtools')
> Installing package into ‘/home/ericrhon/R/x86_64-pc-linux-gnu-library/4.2’
> (as ‘lib’ is unspecified)
> --- Please select a CRAN mirror for use in this session ---
> Secure CRAN mirrors
>
>  1: 0-Cloud [https]
>  2: Australia (Canberra) [https]
>  3: Australia (Melbourne 1) [https]
>  4: Australia (Melbourne 2) [https]
>  5: Australia (Perth) [https]
>  6: Austria [https]
>  7: Belgium (Brussels) [https]
>  8: Brazil (PR) [https]
>  9: Brazil (RJ) [https]
> 10: Brazil (SP 1) [https]
> 11: Brazil (SP 2) [https]
> 12: Bulgaria [https]
> 13: Canada (MB) [https]
> 14: Canada (ON 3) [https]
> 15: Chile (Santiago) [https]
> 16: China (Beijing 2) [https]
> 17: China (Beijing 3) [https]
> 18: China (Hefei) [https]
> 19: China (Hong Kong) [https]
> 20: China (Guangzhou) [https]
> 21: China (Lanzhou) [https]
> 22: China (Nanjing) [https]
> 23: China (Shanghai 2) [https]
> 24: China (Shenzhen) [https]
> 25: Colombia (Cali) [https]
> 26: Costa Rica [https]
> 27: Cyprus [https]
> 28: Czech Republic [https]
> 29: Denmark [https]
> 30: East Asia [https]
> 31: Ecuador (Cuenca) [https]
> 32: Ecuador (Quito) [https]
> 33: France (Lyon 1) [https]
> 34: France (Lyon 2) [https]
> 35: France (Marseille) [https]
> 36: France (Paris 1) [https]
> 37: Germany (Erlangen) [https]
> 38: Germany (Leipzig) [https]
> 39: Germany (Göttingen) [https]
> 40: Germany (Münster) [https]
> 41: Germany (Regensburg) [https]
> 42: Greece [https]
> 43: Hungary [https]
> 44: Iceland [https]
> 45: India [https]
> 46: Indonesia (Banda Aceh) [https]
> 47: Iran (Mashhad) [https]
> 48: Italy (Milano) [https]
> 49: Italy (Padua) [https]
> 50: Japan (Tokyo) [https]
> 51: Japan (Yonezawa) [https]
> 52: Korea (Gyeongsan-si) [https]
> 53: Korea (Ulsan) [https]
> 54: Malaysia [https]
> 55: Mexico (Mexico City) [https]
> 56: Mexico (Texcoco) [https]
> 57: Morocco [https]
> 58: Netherlands (Dronten) [https]
> 59: New Zealand [https]
> 60: Norway [https]
> 61: South Africa (Johannesburg) [https]
> 62: Spain (A Coruña) [https]
> 63: Spain (Madrid) [https]
> 64: Sweden (Borås) [https]
> 65: Sweden (Umeå) [https]
> 66: Switzerland [https]
> 67: Taiwan (Taipei) [https]
> 68: Turkey (Denizli) [https]
> 69: Turkey (Istanbul) [https]
> 70: Turkey (Mersin) [https]
> 71: UK (Bristol) [https]
> 72: UK (London 1) [https]
> 73: USA (IA) [https]
> 74: USA (MI) [https]
> 75: USA (MO) [https]
> 76: USA (OH) [https]
> 77: USA (OR) [https]
> 78: USA (TN) [https]
> 79: USA (TX 1) [https]
> 80: Uruguay [https]
> 81: (other mirrors)
>
> Selection: 1
> also installing the dependencies ‘httpuv’, ‘shiny’, ‘miniUI’
>
> trying URL 'https://cloud.r-project.org/src/contrib/httpuv_1.6.6.tar.gz'
> Content type 'application/x-gzip' length 1875264 bytes (1.8 MB)
> ==
> downloaded 1.8 MB
>
> trying URL 'https://cloud.r-project.org/src/contrib/shiny_1.7.2.tar.gz'
> Content type 'application/x-gzip' length 2982507 bytes (2.8 MB)
> ==
> downloaded 2.8 MB
>
> trying URL 'https://cloud.r-project.org/src/contrib/miniUI_0.1.1.1.tar.gz'
> Content type 'application/x-gzip' length 97958 bytes (95 KB)
> ==
> downloaded 95 KB
>
> trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.4.tar.gz'
> Content type 'application/x-gzip' length 374492 bytes (365 KB)
> ==
> downloaded 365 KB
>
> * installing *source* package ‘httpuv’ ...
> ** package ‘httpuv’ successfully unpacked and MD5 sums checked
> ** using staged installation
> ** libs
> g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
> -Ilibuv/include -pthread 
> -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
> -I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
> -fvisibility=hidden -DSTRICT_R_HEADERS -fpic  -g -O2  -c 
> RcppExports-legacy.cpp -o RcppExports-legacy.o
>
> g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
> -Ilibuv/include -pthread 
> -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
> -I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
> -fvisibility=hidden -DSTRICT_R_HEADERS -fpic  -g -O2  -c RcppExports.cpp -o 
> RcppExports.o
> g++ -std=gnu++11 

[R] Help installing devtools plus other packages in R terminal

2022-10-06 Thread Rhon Calderon, Eric
Hi,

I am using R in my HPC terminal. After many tries, I was able to install and 
exec successfully R on my HPC but now I cannot install devtools and other 
dependencies. I need some of theses packages to install some others from 
bioconductor. I was wondering if anybody has a solution.

The script I got from my R session is (the highlighted part is the errors I 
keep getting):

> install.packages('devtools')
Installing package into ‘/home/ericrhon/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Secure CRAN mirrors

 1: 0-Cloud [https]
 2: Australia (Canberra) [https]
 3: Australia (Melbourne 1) [https]
 4: Australia (Melbourne 2) [https]
 5: Australia (Perth) [https]
 6: Austria [https]
 7: Belgium (Brussels) [https]
 8: Brazil (PR) [https]
 9: Brazil (RJ) [https]
10: Brazil (SP 1) [https]
11: Brazil (SP 2) [https]
12: Bulgaria [https]
13: Canada (MB) [https]
14: Canada (ON 3) [https]
15: Chile (Santiago) [https]
16: China (Beijing 2) [https]
17: China (Beijing 3) [https]
18: China (Hefei) [https]
19: China (Hong Kong) [https]
20: China (Guangzhou) [https]
21: China (Lanzhou) [https]
22: China (Nanjing) [https]
23: China (Shanghai 2) [https]
24: China (Shenzhen) [https]
25: Colombia (Cali) [https]
26: Costa Rica [https]
27: Cyprus [https]
28: Czech Republic [https]
29: Denmark [https]
30: East Asia [https]
31: Ecuador (Cuenca) [https]
32: Ecuador (Quito) [https]
33: France (Lyon 1) [https]
34: France (Lyon 2) [https]
35: France (Marseille) [https]
36: France (Paris 1) [https]
37: Germany (Erlangen) [https]
38: Germany (Leipzig) [https]
39: Germany (Göttingen) [https]
40: Germany (Münster) [https]
41: Germany (Regensburg) [https]
42: Greece [https]
43: Hungary [https]
44: Iceland [https]
45: India [https]
46: Indonesia (Banda Aceh) [https]
47: Iran (Mashhad) [https]
48: Italy (Milano) [https]
49: Italy (Padua) [https]
50: Japan (Tokyo) [https]
51: Japan (Yonezawa) [https]
52: Korea (Gyeongsan-si) [https]
53: Korea (Ulsan) [https]
54: Malaysia [https]
55: Mexico (Mexico City) [https]
56: Mexico (Texcoco) [https]
57: Morocco [https]
58: Netherlands (Dronten) [https]
59: New Zealand [https]
60: Norway [https]
61: South Africa (Johannesburg) [https]
62: Spain (A Coruña) [https]
63: Spain (Madrid) [https]
64: Sweden (Borås) [https]
65: Sweden (Umeå) [https]
66: Switzerland [https]
67: Taiwan (Taipei) [https]
68: Turkey (Denizli) [https]
69: Turkey (Istanbul) [https]
70: Turkey (Mersin) [https]
71: UK (Bristol) [https]
72: UK (London 1) [https]
73: USA (IA) [https]
74: USA (MI) [https]
75: USA (MO) [https]
76: USA (OH) [https]
77: USA (OR) [https]
78: USA (TN) [https]
79: USA (TX 1) [https]
80: Uruguay [https]
81: (other mirrors)

Selection: 1
also installing the dependencies ‘httpuv’, ‘shiny’, ‘miniUI’

trying URL 'https://cloud.r-project.org/src/contrib/httpuv_1.6.6.tar.gz'
Content type 'application/x-gzip' length 1875264 bytes (1.8 MB)
==
downloaded 1.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/shiny_1.7.2.tar.gz'
Content type 'application/x-gzip' length 2982507 bytes (2.8 MB)
==
downloaded 2.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/miniUI_0.1.1.1.tar.gz'
Content type 'application/x-gzip' length 97958 bytes (95 KB)
==
downloaded 95 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.4.tar.gz'
Content type 'application/x-gzip' length 374492 bytes (365 KB)
==
downloaded 365 KB

* installing *source* package ‘httpuv’ ...
** package ‘httpuv’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
-Ilibuv/include -pthread -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
-I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
-fvisibility=hidden -DSTRICT_R_HEADERS -fpic  -g -O2  -c RcppExports-legacy.cpp 
-o RcppExports-legacy.o

g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
-Ilibuv/include -pthread -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
-I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
-fvisibility=hidden -DSTRICT_R_HEADERS -fpic  -g -O2  -c RcppExports.cpp -o 
RcppExports.o
g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
-Ilibuv/include -pthread -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
-I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
-fvisibility=hidden -DSTRICT_R_HEADERS -fpic  -g -O2  -c callback.cpp -o 
callback.o
g++ -std=gnu++11 -I"/home/ericrhon/R/4.2/R-4.2.1/include" -DNDEBUG 
-Ilibuv/include -pthread -I'/home/ericrhon/R/4.2/R-4.2.1/library/Rcpp/include' 
-I'/home/ericrhon/R/4.2/R-4.2.1/library/later/include' -I/usr/local/include  
-fvisibility=hidden