Re: [R] Adding comment in C++ code for debugging purpose

2022-12-16 Thread Rui Barradas

Às 23:32 de 16/12/2022, Christofer Bogaso escreveu:

Hi,

I am using an R package where there are some C++ code.

To check some intermediate values generated by that C++ code, I added
a line like

std::cout << "My values";

Now with this modification, I next build a modified package (source) using

R CMD build

Next I install this modified package using install.packages() function

However during the run-time of the C++ code with above modification, I
dont get any print with "My values"

Can you please help to understand why am not getting that printed?

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


Hello,

If the package uses Rcpp try instead


Rcpp::Rcout << "My values" << "\n";   // or std::endl


More generally, there is also


R_Print("My values\n");



Hope this helps,

Rui Barradas

__
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] Adding comment in C++ code for debugging purpose

2022-12-16 Thread Jeff Newmiller
a) This is not the Rcpp help list.

b) Writing to stdout without going through R is not supported in packages. Do 
read the Writing R Extensions manual.

On December 16, 2022 3:32:33 PM PST, Christofer Bogaso 
 wrote:
>Hi,
>
>I am using an R package where there are some C++ code.
>
>To check some intermediate values generated by that C++ code, I added
>a line like
>
>std::cout << "My values";
>
>Now with this modification, I next build a modified package (source) using
>
>R CMD build
>
>Next I install this modified package using install.packages() function
>
>However during the run-time of the C++ code with above modification, I
>dont get any print with "My values"
>
>Can you please help to understand why am not getting that printed?
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] datatable using dt not able to print background colors

2022-12-16 Thread Matthew Pirritano
Hey, all!

I've got a report that uses datatable from DT to create an rmarkdown html that 
looks great as an html but when I try to print it, to a printer, or to a pdf 
the colors I've assigned to cells are not displaying. I'm using chrome and I've 
clicked on the Background graphics button there, but that doesn't help print 
the colors. I have tried to run the datatable section of the code using results 
= 'asis' and eliminating results = 'asis'. Neither seems to help with the

My css style at the top of the rmarkdown is


.main-container {
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
  table.display td { white-space: wrap; }

}
td{
  -webkit-print-color-adjust:exact !important;
  print-color-adjust:exact !important;
}


I added the webkit bit based on what I've found online. Maybe I have something 
set up incorrectly there? Any ideas or thoughts on how to get this to print the 
background colors?

Thanks
matt






This communication is intended for the use of the individual or entity to which 
it is addressed and may contain information that is privileged, confidential or 
otherwise exempt from disclosure under applicable law. If you are not the 
intended recipient, you are hereby notified that any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this communication in error, please notify the sender and delete 
any copies. Thank you.

[[alternative HTML version deleted]]

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


[R] Adding comment in C++ code for debugging purpose

2022-12-16 Thread Christofer Bogaso
Hi,

I am using an R package where there are some C++ code.

To check some intermediate values generated by that C++ code, I added
a line like

std::cout << "My values";

Now with this modification, I next build a modified package (source) using

R CMD build

Next I install this modified package using install.packages() function

However during the run-time of the C++ code with above modification, I
dont get any print with "My values"

Can you please help to understand why am not getting that printed?

__
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] is.na()<- on a character vector

2022-12-16 Thread Göran Broström
Yes, I was confused: In is.na(x) <-value, value is supposed to be an index 
vector, clearly stated on the help page. So Bert�s suggestion is the way to go.

Thanks to all, G�ran

-Ursprungligt meddelande-
Fr�n: Bill Dunlap 
Datum: fredag, 16 december 2022 20:15
Till: G�ran Brostr�m 
Kopia: r-help@r-project.org 
�mne: Re: [R] is.na()<- on a character vector
I think that is.na (x) <- i
generally does the same to x as does
x[i] <- NA


I say 'generally' because some classes (e.g., numeric_version) do not allow 
x[i]<-NA but do allow is.na (x)<-i. It is 
possible that some classes mess up this equivalence, but I think that would be 
considered a bug.


-Bill


On Fri, Dec 16, 2022 at 10:29 AM G�ran Brostr�m 
mailto:goran.brost...@umu.se> 
>> wrote:

I'm confused:

> x <- 1:2
> is.na (x) <- 1
> x
[1] NA 2

OK, but

> x <- c("A", "B")
> is.na (x) <- "A"
> x
A
"A" "B" NA

What happens?

G_ran

__
R-help@r-project.org <_blank> 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] is.na()<- on a character vector

2022-12-16 Thread Bill Dunlap
I think that
   is.na(x) <- i
generally does the same to x as does
   x[i] <- NA

I say 'generally' because some classes (e.g., numeric_version) do not allow
x[i]<-NA but do allow is.na(x)<-i.  It is possible that some classes mess
up this equivalence, but I think that would be considered a bug.

-Bill

On Fri, Dec 16, 2022 at 10:29 AM Göran Broström 
wrote:

> I'm confused:
>
> > x <- 1:2
> > is.na(x) <- 1
> > x
> [1] NA  2
>
> OK, but
>
> > x <- c("A", "B")
> > is.na(x) <- "A"
> > x
>A
> "A" "B"  NA
>
> What happens?
>
> G_ran
>
> __
> 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] is.na()<- on a character vector

2022-12-16 Thread Bert Gunter
To do what the OP wanted, one can use:

x <- c('A', 'B')
is.na(x) <- x=='A'  ## rhs is a logical index vector

## yielding
> x
[1] NA  "B"

Cheers,
Bert

On Fri, Dec 16, 2022 at 10:43 AM Eric Berger  wrote:

> maybe this will make it clear
>
> x <- c(a=1, b=5)
> is.na(x) <- "b"
>
> i.e. your second case is dealing with a named vector
>
> HTH,
> Eric
>
>
> On Fri, Dec 16, 2022 at 8:29 PM Göran Broström 
> wrote:
>
> > I'm confused:
> >
> > > x <- 1:2
> > > is.na(x) <- 1
> > > x
> > [1] NA  2
> >
> > OK, but
> >
> > > x <- c("A", "B")
> > > is.na(x) <- "A"
> > > x
> >A
> > "A" "B"  NA
> >
> > What happens?
> >
> > G_ran
> >
> > __
> > 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.
>

[[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] Get data from a list of data frames (Stefano Sofia)

2022-12-16 Thread Bert Gunter
... and note that my previous version can be simplified using R's pipe
syntax to:

do.call('rbind',Total[select.stat]) |>
   subset(sensor == 'thermometer', code)

## which calls the subset.data.frame() method that gives:
 code
Station1.1 2583
Station4.4 4453
Station5.3 3179

close to the form that you suggested.
Same caveats as my previous post.

Cheers,
Bert


On Fri, Dec 16, 2022 at 7:16 AM Jorgen Harmse via R-help <
r-help@r-project.org> wrote:

> Following Bert Gunter's suggestion, I wonder why the data are in separate
> frames (with hard-coded values) in the first place. You could put them in a
> text file and call read.table. If you provide a header and put a meaningful
> station name at the start of each data row then rownames of your data frame
> will be meaningful.
>
> Regards,
> Jorgen Harmse.
>
> From: R-help  on behalf of
> r-help-requ...@r-project.org 
> Date: Friday, 16December, 2022 at 05:00
> To: r-help@r-project.org 
> Subject: [EXTERNAL] R-help Digest, Vol 238, Issue 16
>
> Message: 1
> Date: Thu, 15 Dec 2022 13:52:35 +
> From: Stefano Sofia 
> To: "r-help@R-project.org" 
> Subject: [R] Get data from a list of data frames
> Message-ID: 
> Content-Type: text/plain; charset="utf-8"
>
> Dear R-list users,
>
> I have a list of n data frames built as follows:
>
>
> Station1 <- data.frame(sensor = c("thermometer", "raingauge", "snowgauge",
> "anemometer"), code = c(2583, 1478, 3178, NA))
> Station2 <- data.frame(sensor = c("thermometer", "raingauge", "snowgauge",
> "anemometer"), code = c(2584, 1479, 3179, 4453))
> 
>
> Total <- list("Station1"=Station1, "Station2"=Station2, ...)
>
> I would need to have a vector with the sensor codes of the thermometers of
> some stations, let's say of Station1, Station2 and Station5 (i.e. c(2583,
> 2584, 2587)).
> I tried with lapply, but I have not been able to get what I need.
> Could you please help me?
>
> Thank you
>
> Stefano
>
>
>
>  (oo)
> --oOO--( )--OOo--
> Stefano Sofia PhD
> Civil Protection - Marche Region - Italy
> Meteo Section
> Snow Section
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona (AN)
> Uff: +39 071 806 7743
> E-mail: stefano.so...@regione.marche.it
> ---Oo-oO
>
> 
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere
> informazioni confidenziali, pertanto � destinato solo a persone autorizzate
> alla ricezione. I messaggi di posta elettronica per i client di Regione
> Marche possono contenere informazioni confidenziali e con privilegi legali.
> Se non si � il destinatario specificato, non leggere, copiare, inoltrare o
> archiviare questo messaggio. Se si � ricevuto questo messaggio per errore,
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
> computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in
> caso di necessit� ed urgenza, la risposta al presente messaggio di posta
> elettronica pu� essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by
> persons entitled to receive the confidential information it may contain.
> E-mail messages to clients of Regione Marche may contain information that
> is confidential and legally privileged. Please do not read, copy, forward,
> or store this message unless you are an intended recipient of it. If you
> have received this message in error, please forward it to the sender and
> delete it completely from your computer system.
>
> --
> Questo messaggio  stato analizzato da Libraesva ESG ed  risultato non
> infetto.
> This message was scanned by Libraesva ESG and is believed to be clean.
>
>
> [[alternative HTML version deleted]]
>
>
>
>
>
> --
>
> Message: 4
> Date: Thu, 15 Dec 2022 09:31:51 -0800
> From: Bert Gunter 
> To: Gerrit Eichner ,
> stefano.so...@regione.marche.it
> Cc: r-help@r-project.org
> Subject: Re: [R] Get data from a list of data frames
> Message-ID:
> <
> cagxfjbtgwq2nop0bjczct7ri6fhdmorxixv+o2-2m_-sqz6...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Well, just for giggles, Gerrit's solution can be easily vectorized (i.e. no
> apply()-type stuff needed) IFF the structure of all the data frames are
> identical so that rbind() works:
>
> d <-do.call('rbind',Total[select.stat]) ## one data frame to combine them
> all ;-)
> d[d$sensor == 'thermometer','code']
>
> Whether this is better, worse, or unneeded, I cannot say.
>
> Cheers,
> Bert
>
>
>
> [[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] is.na()<- on a character vector

2022-12-16 Thread Jeff Newmiller
I don't find _either_ of these acceptable.

On the other hand,

x[ is.na( x ) ] <- 1

should have no effect on x.

On December 16, 2022 10:28:52 AM PST, "Göran Broström"  
wrote:
>I'm confused:
>
>> x <- 1:2
>> is.na(x) <- 1
>> x
>[1] NA  2
>
>OK, but
>
>> x <- c("A", "B")
>> is.na(x) <- "A"
>> x
>   A 
>"A" "B"  NA  
>
>What happens?
>
>G_ran
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] is.na()<- on a character vector

2022-12-16 Thread Eric Berger
maybe this will make it clear

x <- c(a=1, b=5)
is.na(x) <- "b"

i.e. your second case is dealing with a named vector

HTH,
Eric


On Fri, Dec 16, 2022 at 8:29 PM Göran Broström 
wrote:

> I'm confused:
>
> > x <- 1:2
> > is.na(x) <- 1
> > x
> [1] NA  2
>
> OK, but
>
> > x <- c("A", "B")
> > is.na(x) <- "A"
> > x
>A
> "A" "B"  NA
>
> What happens?
>
> G_ran
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] is.na()<- on a character vector

2022-12-16 Thread Göran Broström
I'm confused:

> x <- 1:2
> is.na(x) <- 1
> x
[1] NA  2

OK, but

> x <- c("A", "B")
> is.na(x) <- "A"
> x
   A 
"A" "B"  NA  

What happens?

G_ran

__
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] Get data from a list of data frames (Stefano Sofia)

2022-12-16 Thread Jorgen Harmse via R-help
Following Bert Gunter's suggestion, I wonder why the data are in separate 
frames (with hard-coded values) in the first place. You could put them in a 
text file and call read.table. If you provide a header and put a meaningful 
station name at the start of each data row then rownames of your data frame 
will be meaningful.

Regards,
Jorgen Harmse.

From: R-help  on behalf of 
r-help-requ...@r-project.org 
Date: Friday, 16December, 2022 at 05:00
To: r-help@r-project.org 
Subject: [EXTERNAL] R-help Digest, Vol 238, Issue 16

Message: 1
Date: Thu, 15 Dec 2022 13:52:35 +
From: Stefano Sofia 
To: "r-help@R-project.org" 
Subject: [R] Get data from a list of data frames
Message-ID: 
Content-Type: text/plain; charset="utf-8"

Dear R-list users,

I have a list of n data frames built as follows:


Station1 <- data.frame(sensor = c("thermometer", "raingauge", "snowgauge", 
"anemometer"), code = c(2583, 1478, 3178, NA))
Station2 <- data.frame(sensor = c("thermometer", "raingauge", "snowgauge", 
"anemometer"), code = c(2584, 1479, 3179, 4453))


Total <- list("Station1"=Station1, "Station2"=Station2, ...)

I would need to have a vector with the sensor codes of the thermometers of some 
stations, let's say of Station1, Station2 and Station5 (i.e. c(2583, 2584, 
2587)).
I tried with lapply, but I have not been able to get what I need.
Could you please help me?

Thank you

Stefano



 (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
� il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed 
urgenza, la risposta al presente messaggio di posta elettronica pu� essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

--
Questo messaggio  stato analizzato da Libraesva ESG ed  risultato non infetto.
This message was scanned by Libraesva ESG and is believed to be clean.


[[alternative HTML version deleted]]





--

Message: 4
Date: Thu, 15 Dec 2022 09:31:51 -0800
From: Bert Gunter 
To: Gerrit Eichner ,
stefano.so...@regione.marche.it
Cc: r-help@r-project.org
Subject: Re: [R] Get data from a list of data frames
Message-ID:

Content-Type: text/plain; charset="utf-8"

Well, just for giggles, Gerrit's solution can be easily vectorized (i.e. no
apply()-type stuff needed) IFF the structure of all the data frames are
identical so that rbind() works:

d <-do.call('rbind',Total[select.stat]) ## one data frame to combine them
all ;-)
d[d$sensor == 'thermometer','code']

Whether this is better, worse, or unneeded, I cannot say.

Cheers,
Bert



[[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] [Rd] I do not want that R CMD build removes temp directory

2022-12-16 Thread Uwe Ligges




On 15.12.2022 21:47, Witold E Wolski wrote:

Thank you Simon,

It seems not to be related to the R package but rather to the OS,
(just got the same error when installing the shiny R package from
CRAN).
I am on an M1 mac running Windows ARM in Parallels. Installed a
x86_64-w64 R version.



"** byte-compile and prepare package for lazy loading
ERROR: lazy loading failed for package 'shiny'
* removing 'C:/Users/witoldwolski/AppData/Local/R/win-library/4.2/shiny'
Warning in install.packages :"


Can we please have the full output?

Best,
Uwe Ligges




On Thu, 15 Dec 2022 at 19:09, Simon Urbanek  wrote:


Yes:

$ R CMD INSTALL --help | grep error
   --no-clean-on-error   do not remove installed package on error

But probably more commonly used way is to install the package from its unpacked 
directory as that avoids the use of temporary directories in the first place.

In you case you can also use --no-test-load and the non-functional package will 
still be installed so you can inspect it.

Cheers,
Simon

PS: please don't cross-post



On Dec 16, 2022, at 7:01 AM, Witold E Wolski  wrote:

I am getting a package build error, and can not figure out the problem.
The error is
"
ERROR: lazy loading failed for package 'prolfqua'
* removing 'C:/Users/
"
However since R CMD build removes the temp directory and does not give
any other errors how can I find out what the build problem is?

Is there a way to disable the temp directory removal?

Best Regards
Witek
--
Witold Eryk Wolski

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel








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