Re: [R] Adding page numbers to existing PDFs

2022-10-27 Thread Paul Murrell

Hi

Below is a script that does the job for a very simple R plot, making use 
of R and a couple of free software tools (ghostscript and poppler).  It 
may or may not help with your real problem (NOTE the WARNING) ...



library(grImport)

## Multipage PDF created by R
pdf("plot-in.pdf")
plot(1)
plot(2)
dev.off()

## Separate into individual pages
system("pdfseparate plot-in.pdf plot-in-%d.pdf")

inFiles <- list.files(pattern="plot-in-[0-9]+.pdf")

for (i in seq_along(inFiles)) {
## Convert to PostScript
## (WARNING:  may cause [some] rasterization, depending on content
##of plot and on the conversion tool;  anything that is
##rasterized will NOT get imported)
system(paste0("pdf2ps plot-in-", i, ".pdf plot-in-", i, ".ps"))

## Import to R
PostScriptTrace(paste0("plot-in-", i, ".ps"),
paste0("plot-in-", i, ".xml"))
plot <- readPicture(paste0("plot-in-", i, ".xml"))

## Add page number (in new PDF)
pdf(paste0("plot-out-", i, ".pdf"))
grid.picture(plot)
grid.text(paste0("Page ", i), .5, unit(1, "lines"))
dev.off()
}

outFiles <- list.files(pattern="plot-out-[0-9]+.pdf")

## Recombine into single, multi-page PDF
system(paste0("pdfunite ", paste(outFiles, collapse=" "),
  " plot-out.pdf"))


If you do want to use something like this, let me know, because there 
are some other limitations that you might want to be aware of.


Paul

On 22/10/2022 6:45 am, Dennis Fisher wrote:

R 4.2.1
OS X

Colleagues

I have multipage PDF files that were created in R — the files do NOT 
have page numbers. I would like to add page numbers after the fact, 
i.e., read a file into R, add margin text, then output as a PDF.

Can this be done in R (base R or a package)?
It can be done in Python using reportlab.pdfgen — however, the file size 
increases prohibitively.


Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com 



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


--
Dr Paul Murrell
Te Kura Tatauranga | Department of Statistics
Waipapa Taumata Rau | The University of Auckland
Private Bag 92019, Auckland, New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
www.stat.auckland.ac.nz/~paul/

__
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] compile report error

2022-10-27 Thread Ivan Krylov
В Wed, 26 Oct 2022 18:51:40 +0200
Gábor Malomsoki  пишет:

> Error in parse(text = x, keep.source = TRUE) :
>   :13:66: unexpected INCOMPLETE_STRING
> 12:
> 13: tomitettseg_GesNa$station_desc[tomitettseg_GesNa$station_desc ==
> "Dichtheits.- Durchflusspr
> 
> i get this error message when i try to compile the report.

How exactly do you compile your report? Is it a Sweave / knitr /
rmarkdown vignette? Something else? What's the encoding of the file? Is
it declared anywhere? What is your operating system and its native
encoding (i.e. sessionInfo() output)?

-- 
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] intersection in data frame

2022-10-27 Thread Gábor Malomsoki
Dear all,

i have tried all of your proposals, all of them was ok.
Maybe dcast() with data table was faster.
Thank you!

Best regards
Gabor

Am Fr., 14. Okt. 2022 um 01:31 Uhr schrieb Dénes Tóth <
toth.de...@kogentum.hu>:

> Or if your data is really large, you can try data.table::dcast().
>
>  > library(data.table)
>  > dcast(ID ~ station, data = as.data.table(df1))
> ID xy xz
> 1: 12 15 20
> 2: 13 16 19
>
> (Note: instead of `as.data.table()`, you can use `setDT` or create your
> object as a data.table in the first place.)
>
>
> On 10/13/22 11:22 PM, Rui Barradas wrote:
> > Hello,
> >
> > To reshape from long to wide format, here are two options:
> >
> >
> > df1 <- 'IDstation  value
> > 12  xy15
> > 12  xz20
> > 13   xy   16
> > 13   xz   19'
> > df1 <- read.table(textConnection(df1), header = TRUE)
> >
> >
> > # base R
> > reshape(df1, direction = "wide", idvar = "ID", timevar = "station")
> > #>   ID value.xy value.xz
> > #> 1 12   15   20
> > #> 3 13   16   19
> >
> > # tidyverse
> > tidyr::pivot_wider(df1, ID, names_from = station)
> > #> # A tibble: 2 × 3
> > #>  IDxyxz
> > #> 
> > #> 1121520
> > #> 2131619
> >
> >
> > This question is StackOverflow question [1].
> >
> > [1]
> >
> https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format
> >
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > Às 19:08 de 13/10/2022, Gábor Malomsoki escreveu:
> >> Dears,
> >>
> >> i need to create from a column of observations variables in a datafram
> >> like
> >> this way:
> >> example:
> >> original:
> >> IDstation  value
> >> 12  xy15
> >> 12  xz20
> >> 13   xy   16
> >> 13   xz   19
> >>
> >> new df:
> >>
> >>   ID  xy xz
> >> 12  15 20
> >> 13  16 19
> >>
> >> i have been looking around for examples, but i could not find any how to
> >> change my df.
> >> I would like to make regression analysis on the values from different
> >> production stations, so my df is very huge.
> >>
> >> Please help on finding the package, description or anything else could
> >> help.
> >>
> >> Thank you in advance!
> >>
> >> Best regards
> >> Malo
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

[[alternative HTML version deleted]]

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


Re: [R] compile report error

2022-10-27 Thread Gábor Malomsoki
Dear Rui,

this is very strange, it seams that in your script there is no problem to
compile the report, but in mine not, i just sent you the rows 10:15 from
141299 obs.
It seams it does not like the punctuation marks in "Dichtheits.-
Durchflussprüfung M8.1", so i used a gsub () then a sub () replacing the
column with punctuation mark to something else.
Then i do not need this line in the script:
tomitettseg_GesNa$station_desc[tomitettseg_GesNa$station_desc ==
"Dichtheits.- Durchflussprüfung M8.1"] <-"D_D_"
Now it works.

Thank you anyway

Best regards
Gabor








Am Mi., 26. Okt. 2022 um 22:08 Uhr schrieb Rui Barradas <
ruipbarra...@sapo.pt>:

> Às 20:19 de 26/10/2022, Gábor Malomsoki escreveu:
> > If i change the column name:
> > "Dichtheits.- Durchflussprüfung M8.1"
> > In the csv to something else, like "x" then it works, but this is not the
> > elegant solution.
> >
> >
> > Gábor Malomsoki  schrieb am Mi., 26. Okt.
> 2022,
> > 19:37:
> >
> >> Hello,
> >>
> >> sure
> >> dput(tomitettseg[10:15, c(1-8)])
> >>
> >> structure(list(serial_number = c("362017126683", "362017126683",
> >> "362017126683", "362017362605", "362017362605",
> >> "362017362605"
> >> ), station_number = c(362060010081, 362060010081, 362060010081,
> >> 362060010081, 362060010081, 362060010081), station_desc =
> c("Dichtheits.-
> >> Durchflussprüfung M8.1",
> >> "Dichtheits.- Durchflussprüfung M8.1", "Dichtheits.- Durchflussprüfung
> >> M8.1",
> >> "Dichtheits.- Durchflussprüfung M8.1", "Dichtheits.- Durchflussprüfung
> >> M8.1",
> >> "Dichtheits.- Durchflussprüfung M8.1"), part_number = c(40005935L,
> >> 40005935L, 40005935L, 40005935L, 40005935L, 40005935L), book_date =
> >> c("2019-01-15 07:49:58.46700",
> >> "2019-01-15 07:49:58.46700", "2019-01-15 07:49:58.46700",
> >> "2019-01-15 07:58:18.40300", "2019-01-15 07:58:18.40300",
> >> "2019-01-15 07:58:18.40300"), measure_name = c("BlowBy (BlowBy)
> >> Leckrate",
> >> "BlowBy (BlowBy) Druck", "GESnA (GESnA) Leckrate", "BlowBy (BlowBy)
> >> Leckrate",
> >> "BlowBy (BlowBy) Druck", "GESnA (GESnA) Leckrate"), book_state = c(0L,
> >> 0L, 0L, 0L, 0L, 0L)), row.names = 10:15, class = "data.frame")
> >>
> >>
> >>
> >> Am Mi., 26. Okt. 2022 um 19:05 Uhr schrieb Rui Barradas <
> >> ruipbarra...@sapo.pt>:
> >>
> >>> Às 17:51 de 26/10/2022, Gábor Malomsoki escreveu:
> Dear all,
> 
>  Error in parse(text = x, keep.source = TRUE) :
>  :13:66: unexpected INCOMPLETE_STRING
>  12:
>  13: tomitettseg_GesNa$station_desc[tomitettseg_GesNa$station_desc ==
>  "Dichtheits.- Durchflusspr
> 
>  i get this error message when i try to compile the report.
>  i think this is because of the punktuation mark between the quotation
> >>> marks
>  "." .
>  i do not know how to solve this, because with this column name i got
> the
>  csv,  and i am changing the column name in the script, not to have it
> so
>  long and avoid characters like .   ü  :
> tomitettseg_GesNa$station_desc[tomitettseg_GesNa$station_desc ==
>  "Dichtheits.- Durchflussprüfung M8.1"] <-"D_D_"
>  thanks
> 
>  BR
>  Gabor
> 
> [[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.
> >>>
> >>> Hello,
> >>>
> >>> Can you post the output of dput(x)? Or of dput(x[10:15])?
> >>>
> >>> Hope this helps,
> >>>
> >>> Rui Barradas
> >>>
> >>
> >
>
> Hello,
>
> Are you looking for this?
>
>
>
> df1 <-
>structure(list(
>  serial_number = c("362017126683", "362017126683",
>"362017126683", "362017362605",
>"362017362605", "362017362605"),
>  station_number = c(362060010081, 362060010081, 362060010081,
> 362060010081, 362060010081, 362060010081),
>  station_desc = c("Dichtheits.- Durchflussprüfung M8.1",
>   "Dichtheits.- Durchflussprüfung M8.1",
>   "Dichtheits.- Durchflussprüfung M8.1",
>   "Dichtheits.- Durchflussprüfung M8.1",
>   "Dichtheits.- Durchflussprüfung M8.1",
>   "Dichtheits.- Durchflussprüfung M8.1"),
>  part_number = c(40005935L, 40005935L, 40005935L, 40005935L,
> 40005935L, 40005935L),
>  book_date = c("2019-01-15 07:49:58.46700", "2019-01-15
> 07:49:58.46700",
>"2019-01-15 07:49:58.46700", "2019-01-15
> 07:58:18.40300",
>"2019-01-15 07:58:18.40300", "2019-01-15
> 07:58:18.40300"),
>  measure_name = c("BlowBy (BlowBy) Leckrate", "BlowBy (BlowBy) Druck",
>   

[R] Automatic Distribution Fitting Using R

2022-10-27 Thread Paul Bernal
Dear friends,

I previously asked if there was an R package that could automatically test
several different probability distributions for a given dataset and give
the best fit.

I found that the package DistributionFitR does something along those lines
with the function globalfit(), just in case anyone is interested.

Best,
Paul

[[alternative HTML version deleted]]

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


Re: [R] R-help Digest, Vol 236, Issue 25

2022-10-27 Thread Thomas Subia
Paul wrote:
" Is there any package besides fitdistrplus that does allow automatic
distribution fitting?"

Automatic distribution fitting can be done using Minitab.
Minitab will try and fit your dataset against 14 distributions.
It has the option of using a Box-Cox or a Johnson methods to transform the 
dataset into a normal distribution.
I suspect that this is as close as you can get to an automatic distribution 
fitting.

Hope this helps!

Thomas Subia

-Original Message-
From: R-help  On Behalf Of 
r-help-requ...@r-project.org
Sent: Thursday, October 27, 2022 3:00 AM
To: r-help@r-project.org
Subject: R-help Digest, Vol 236, Issue 25

Send R-help mailing list submissions to
r-help@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit

https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!NX4bS6ECB6Pv!58HVkevfq5zfBsZ-2SRH07K3Plt5jMiaOZESF0m5ISL6OEQ6tVLVvrxTtICUro1_0hb0FfINk_O3DRlbb69V3tZbX1blniVg28s$
 
or, via email, send a message with subject or body 'help' to
r-help-requ...@r-project.org

You can reach the person managing the list at
r-help-ow...@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."


Today's Topics:

   1. Re: unexpected 'else' in " else" (Richard O'Keefe)
   2. Function for Distribution Fitting (Paul Bernal)
   3. Re: Function for Distribution Fitting (JRG)
   4. Re: Function for Distribution Fitting (Bert Gunter)
   5. Re: Function for Distribution Fitting (Gabor Grothendieck)
   6. compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=)
   7. Re: compile report error (Rui Barradas)
   8. Re: Function for Distribution Fitting (Ebert,Timothy Aaron)
   9. Re: compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=)
  10. Best place to ask questions about non-R Base topics, ex.
  dplyr, dbplyr, etc. ? (Kelly Thompson)
  11. Re:  Best place to ask questions about non-R Base topics, ex.
  dplyr, dbplyr, etc. ? (Jeff Newmiller)
  12. Re: compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=)
  13. Re:  Best place to ask questions about non-R Base topics, ex.
  dplyr, dbplyr, etc. ? (Eric Berger)
  14. Re: compile report error (Rui Barradas)
  15. Color Nodes (Jeff Reichman)
  16. Re: Color Nodes (Rui Barradas)
  17. Re: Color Nodes (Jeff Reichman)
  18. R-package imputeTS / warning messages (Paulo Barata)
  19. Re: Color Nodes (Eric Berger)

--

Message: 1
Date: Wed, 26 Oct 2022 23:03:30 +1300
From: "Richard O'Keefe" 
To: Jinsong Zhao 
Cc: "r-help@r-project.org" 
Subject: Re: [R] unexpected 'else' in " else"
Message-ID:

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

This is explained in books about S and R.
The first place to look is of course
> ?"if"
which says

 Note that it is a common mistake to forget to put braces ('{ ..
 }') around your statements, e.g., after 'if(..)' or 'for()'.
 In particular, you should not have a newline between '}' and
 'else' to avoid a syntax error in entering a 'if ... else'
 construct at the keyboard or via 'source'.  For that reason, one
 (somewhat extreme) attitude of defensive programming is to always
 use braces, e.g., for 'if' clauses.


The basic issue is that the top level wants to get started
on your command AS SOON AS IT HAS A COMPLETE COMMAND,
and if (...) stmt
is complete.  It's not going to hang around "Waiting for Godot"
for an 'else' that might never ever ever turn up.  So
   if (x < y) z <-
   x else z <- y
is absolutely fine, no braces needed, while
   if (x < y) z <- x
   else z <- y
will see the eager top level rush off to do your bidding
at the end of the first line and then be completely
baffled by an 'else' where it does not expect one.

It's the same reason that you break AFTER infix operators
instead of BEFORE.
   x <- y +
   z
works fine, while
   x <- y
   + z
doesn't.



On Fri, 21 Oct 2022 at 22:29, Jinsong Zhao  wrote:

> Hi there,
>
> The following code would cause R error:
>
>  > w <- 1:5
>  > r <- 1:5
>  > if (is.matrix(r))
> + r[w != 0, , drop = FALSE]
>  > else r[w != 0]
> Error: unexpected 'else' in "else"
>
> However, the code:
>  if (is.matrix(r))
>  r[w != 0, , drop = FALSE]
>  else r[w != 0]
> is extracted from stats::weighted.residuals.
>
> My question is why the code in the function does not cause error?
>
> Best,
> Jinsong
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!NX4bS6ECB6Pv!58HVkevfq5zfBsZ-2SRH07K3Plt5jMiaOZESF0m5ISL6OEQ6tVLVvrxTtICUro1_0hb0FfINk_O3DRlbb69V3tZbX1blniVg28s$
>  
> PLEASE do read the posting guide
> 

Re: [R] $ subset operator behavior in lapply

2022-10-27 Thread Jeff Newmiller
Your message is garbled. Please send plain text to the mailing list.

On October 27, 2022 2:31:47 AM PDT, Hilmar Berger  wrote:
>Dear all,
>
>I'm a little bit surprised by the behavior of the $ operator when used
>in lapply - any indication what might be wrong is appreciated.
>
>> xx = list(A=list(a=1:3, b=LETTERS[1:3]),"B"=list(a=7:9, b=LETTERS[7:9]))  > 
>> lapply(xx,`$`,"a") $A NULL $B NULL > `$`(xx[[1]],"a") [1] 1 2 3 >
>lapply(xx,`[`,"a") $A $A$a [1] 1 2 3 $B $B$a [1] 7 8 9 Any idea why I
>`$`(object, name) works when applied to the single list element but not
>within lapply (in contrast to `[`)?
>I checked the help page of the extraction operators but could not find
>anything that explains this. Thanks and best regards Hilmar >
>sessionInfo() R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu
>(64-bit) Running under: Ubuntu 20.04.5 LTS Matrix products: default
>BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK:
>/usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 locale: [1]
>LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=de_DE.UTF-8
>LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=de_DE.UTF-8
>LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C [9]
>LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=de_DE.UTF-8
>LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices
>utils datasets methods base loaded via a namespace (and not attached):
>[1] compiler_4.2.1
>
>   [[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.

-- 
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] $ subset operator behavior in lapply

2022-10-27 Thread Andrew Simmons
$ does not evaluate its second argument, it does something like
as.character(substitute(name)).

You should be using

lapply(list, function(x) x$a)

or

lapply(list, `[[`, "a")


On Thu, Oct 27, 2022, 12:29 Hilmar Berger  wrote:

> Dear all,
>
> I'm a little bit surprised by the behavior of the $ operator when used
> in lapply - any indication what might be wrong is appreciated.
>
> > xx = list(A=list(a=1:3, b=LETTERS[1:3]),"B"=list(a=7:9,
> b=LETTERS[7:9]))  > lapply(xx,`$`,"a") $A NULL $B NULL > `$`(xx[[1]],"a")
> [1] 1 2 3 >
> lapply(xx,`[`,"a") $A $A$a [1] 1 2 3 $B $B$a [1] 7 8 9 Any idea why I
> `$`(object, name) works when applied to the single list element but not
> within lapply (in contrast to `[`)?
> I checked the help page of the extraction operators but could not find
> anything that explains this. Thanks and best regards Hilmar >
> sessionInfo() R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu
> (64-bit) Running under: Ubuntu 20.04.5 LTS Matrix products: default
> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK:
> /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 locale: [1]
> LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=de_DE.UTF-8
> LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=de_DE.UTF-8
> LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C [9]
> LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=de_DE.UTF-8
> LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices
> utils datasets methods base loaded via a namespace (and not attached):
> [1] compiler_4.2.1
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] $ subset operator behavior in lapply

2022-10-27 Thread Hilmar Berger
Dear all,

I'm a little bit surprised by the behavior of the $ operator when used
in lapply - any indication what might be wrong is appreciated.

> xx = list(A=list(a=1:3, b=LETTERS[1:3]),"B"=list(a=7:9, b=LETTERS[7:9]))  > 
> lapply(xx,`$`,"a") $A NULL $B NULL > `$`(xx[[1]],"a") [1] 1 2 3 >
lapply(xx,`[`,"a") $A $A$a [1] 1 2 3 $B $B$a [1] 7 8 9 Any idea why I
`$`(object, name) works when applied to the single list element but not
within lapply (in contrast to `[`)?
I checked the help page of the extraction operators but could not find
anything that explains this. Thanks and best regards Hilmar >
sessionInfo() R version 4.2.1 (2022-06-23) Platform: x86_64-pc-linux-gnu
(64-bit) Running under: Ubuntu 20.04.5 LTS Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK:
/usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 locale: [1]
LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=de_DE.UTF-8
LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=de_DE.UTF-8
LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C [9]
LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices
utils datasets methods base loaded via a namespace (and not attached):
[1] compiler_4.2.1

[[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] Color Nodes

2022-10-27 Thread Jeff Reichman
Thanks for the tip

-Original Message-
From: Eric Berger  
Sent: Thursday, October 27, 2022 2:49 AM
To: reichm...@sbcglobal.net
Cc: Rui Barradas ; R-help@r-project.org
Subject: Re: [R] Color Nodes

You may want to change the color of the vertex labels. e.g.
plot(g, vertex.size = 20, vertex.label.dist = 0.5,
  vertex.color = V(g)$color, vertex.label.color="cyan")



On Thu, Oct 27, 2022 at 1:52 AM Jeff Reichman  wrote:
>
> Yes Rui that will work for my needs thank you
>
> -Original Message-
> From: Rui Barradas 
> Sent: Wednesday, October 26, 2022 4:40 PM
> To: reichm...@sbcglobal.net; R-help@r-project.org
> Subject: Re: [R] Color Nodes
>
> Às 21:37 de 26/10/2022, Jeff Reichman escreveu:
> > R-Help
> >
> >
> >
> > For those of you who use igraph is there a way to highlight (color) 
> > particular notes. For example if I want to color the "Peter" node 
> > red and everything else blue  or leave default) how would I do that 
> > or can I do that. Seems as though I might create an attribute column - 
> > maybe??
> >
> >
> >
> > Jeff
> >
> >
> >
> > library(igraph)
> >
> >
> >
> > # define links in data
> >
> > edges <- rbind(c("Dave", "Jenny"), c("Peter", "Jenny"), c("John", 
> > "Jenny"), c("Dave", "Peter"), c("Dave", "John"), c("Peter", "Sam"), 
> > c("Sam", "Albert"), c("Peter", "John"))
> >
> >
> >
> > # generate and plot graph
> >
> > # set argument directed = FALSE in graph.edgelist() to plot an 
> > undirected graph.
> >
> > g <- graph.edgelist(edges, directed = FALSE)
> >
> > plot(g, vertex.size = 1, vertex.label.dist = 0.5)
> >
> >
> >   [[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.
>
> Hello,
>
> After creating the graph, set the vertices colors by subsetting V(g).
> Here are two exaples, the first color Peter red and leave the others with 
> their default color. The second, color the other vertices blue.
>
>
>
> V(g)["Peter"]$color <- "red"
>
> plot(g, vertex.size = 20, vertex.label.dist = 0.5,
>   vertex.color = V(g)$color)
>
> V(g)$color <- "blue"
> V(g)["Peter"]$color <- "red"
> plot(g, vertex.size = 20, vertex.label.dist = 0.5,
>   vertex.color = V(g)$color)
>
>
>
> 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.

__
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] Color Nodes

2022-10-27 Thread Eric Berger
You may want to change the color of the vertex labels. e.g.
plot(g, vertex.size = 20, vertex.label.dist = 0.5,
  vertex.color = V(g)$color, vertex.label.color="cyan")



On Thu, Oct 27, 2022 at 1:52 AM Jeff Reichman  wrote:
>
> Yes Rui that will work for my needs thank you
>
> -Original Message-
> From: Rui Barradas 
> Sent: Wednesday, October 26, 2022 4:40 PM
> To: reichm...@sbcglobal.net; R-help@r-project.org
> Subject: Re: [R] Color Nodes
>
> Às 21:37 de 26/10/2022, Jeff Reichman escreveu:
> > R-Help
> >
> >
> >
> > For those of you who use igraph is there a way to highlight (color)
> > particular notes. For example if I want to color the "Peter" node red
> > and everything else blue  or leave default) how would I do that or can
> > I do that. Seems as though I might create an attribute column - maybe??
> >
> >
> >
> > Jeff
> >
> >
> >
> > library(igraph)
> >
> >
> >
> > # define links in data
> >
> > edges <- rbind(c("Dave", "Jenny"), c("Peter", "Jenny"), c("John",
> > "Jenny"), c("Dave", "Peter"), c("Dave", "John"), c("Peter", "Sam"),
> > c("Sam", "Albert"), c("Peter", "John"))
> >
> >
> >
> > # generate and plot graph
> >
> > # set argument directed = FALSE in graph.edgelist() to plot an
> > undirected graph.
> >
> > g <- graph.edgelist(edges, directed = FALSE)
> >
> > plot(g, vertex.size = 1, vertex.label.dist = 0.5)
> >
> >
> >   [[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.
>
> Hello,
>
> After creating the graph, set the vertices colors by subsetting V(g).
> Here are two exaples, the first color Peter red and leave the others with 
> their default color. The second, color the other vertices blue.
>
>
>
> V(g)["Peter"]$color <- "red"
>
> plot(g, vertex.size = 20, vertex.label.dist = 0.5,
>   vertex.color = V(g)$color)
>
> V(g)$color <- "blue"
> V(g)["Peter"]$color <- "red"
> plot(g, vertex.size = 20, vertex.label.dist = 0.5,
>   vertex.color = V(g)$color)
>
>
>
> 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.

__
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-es] minera de texto 2

2022-10-27 Thread Juan Abasolo
Con la libreria readtext de Quanteda? https://readtext.quanteda.io/
Mirá que si usás Linux hay que instalar alguna cosa en el sistema.

Yo lo uso para leer todos los txt (pdf, docx... ) de una carpeta y queda
todo ordenadito.

Suerte


Hau idatzi du Jose Betancourt Bethencourt (betans...@gmail.com)
erabiltzaileak (2022 urr. 26, az. (19:26)):

> -Estimados
>
> Como lograr en mineria de texto en R que se lea un archivo de txt que
> tiene un discurso escrito, no en columnas, sino texto integro
>
> saludos
>
> José
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Juan Abasolo, PhD

Hizkuntzaren eta Literaturaren Didaktika Saila | EUDIA ikerketa taldea
Bilboko Hezkuntza Fakultatea
Euskal Herriko Unibertsitatea UPV/EHU

Sarriena auzoa z/g 48940 - Leioa (Bizkaia)

T   : (+34) 94 601 7567
Telegram: @JuanAbasolo
Skype   : abasolo72

[[alternative HTML version deleted]]

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