Re: [R-es] Redo en RStudio, Ctrl y?

2020-08-19 Thread Xavier-Andoni Tibau Alberdi
No se si tiene nada que ver. Pero en mi caso es porque uso SO en aleman. u
de hecho, es cotrol+alt+Z en todo, no solo Rstudio.

Salud!

Xavi

El jue., 20 ago. 2020 5:31, Manuel Mendoza 
escribió:

> Gracias Xavier,  ctr+alt+Z si me funciona y me será de gran utilidad.
> Carlos, si  pone "Ctrl Y",  y no funciona, pero sí funciona ctr+alt+Z,
> supongo que es un error de programación. Miraré lo de la comunidad de
> RStudio, a ver que me dicen.
> Gracias,
> Manuel
>
> El mié., 19 ago. 2020 a las 21:57, Xavier-Andoni Tibau Alberdi (<
> xaviti...@gmail.com>) escribió:
>
> > En mi caso a veces funciona ctr+alt+Z.
> >
> > El mié., 19 ago. 2020 21:46, Carlos Ortega 
> > escribió:
> >
> >> Hola Manuel,
> >>
> >> En Mac son otra combinación, pero sí que funcionan.
> >> RStudio tiene un grupo de soporte (más bien es una Community) donde
> >> podrías
> >> comentarlo por si es un bug.
> >>
> >> Saludos,
> >> Carlos Ortega
> >> www.qualityexcellence.es
> >>
> >>
> >> El mié., 19 ago. 2020 a las 19:52, Manuel Mendoza (<
> >> mmend...@fulbrightmail.org>) escribió:
> >>
> >> > Buenas tardes. Más bien una curiosidad.
> >> > Echaba de menos poder rehacer con *Ctrl y* lo deshecho con *Ctrl z*.
> Lo
> >> > curioso es que RStudio, desde hace un tiempo, en la pestaña *Edit*, al
> >> lado
> >> > de *Redo *pone "*Ctrl y", *pero *Ctrl y* no funciona. ¿sabe alguien
> por
> >> > qué?
> >> > Gracias,
> >> > Manuel
> >> >
> >> > [[alternative HTML version deleted]]
> >> >
> >> > ___
> >> > R-help-es mailing list
> >> > R-help-es@r-project.org
> >> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >> >
> >>
> >>
> >> --
> >> Saludos,
> >> Carlos Ortega
> >> www.qualityexcellence.es
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ___
> >> R-help-es mailing list
> >> R-help-es@r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-help-es
> >>
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

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


Re: [R-es] Redo en RStudio, Ctrl y?

2020-08-19 Thread Manuel Mendoza
Gracias Xavier,  ctr+alt+Z si me funciona y me será de gran utilidad.
Carlos, si  pone "Ctrl Y",  y no funciona, pero sí funciona ctr+alt+Z,
supongo que es un error de programación. Miraré lo de la comunidad de
RStudio, a ver que me dicen.
Gracias,
Manuel

El mié., 19 ago. 2020 a las 21:57, Xavier-Andoni Tibau Alberdi (<
xaviti...@gmail.com>) escribió:

> En mi caso a veces funciona ctr+alt+Z.
>
> El mié., 19 ago. 2020 21:46, Carlos Ortega 
> escribió:
>
>> Hola Manuel,
>>
>> En Mac son otra combinación, pero sí que funcionan.
>> RStudio tiene un grupo de soporte (más bien es una Community) donde
>> podrías
>> comentarlo por si es un bug.
>>
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>>
>> El mié., 19 ago. 2020 a las 19:52, Manuel Mendoza (<
>> mmend...@fulbrightmail.org>) escribió:
>>
>> > Buenas tardes. Más bien una curiosidad.
>> > Echaba de menos poder rehacer con *Ctrl y* lo deshecho con *Ctrl z*. Lo
>> > curioso es que RStudio, desde hace un tiempo, en la pestaña *Edit*, al
>> lado
>> > de *Redo *pone "*Ctrl y", *pero *Ctrl y* no funciona. ¿sabe alguien por
>> > qué?
>> > Gracias,
>> > Manuel
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > ___
>> > R-help-es mailing list
>> > R-help-es@r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>> >
>>
>>
>> --
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>

[[alternative HTML version deleted]]

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


Re: [R] & and |

2020-08-19 Thread Richard O'Keefe
There are & and | operators in the R language.
There is an | operator in regular expressions.
There is NOT any & operator in regular expressions.
grep("ConfoMap", mydata, value=TRUE)
looks for elements of mydata containing the literal
string 'ConfoMap'.

> foo <- c("a","b","cab","back")
> foo[grepl("a",foo) & grepl("b",foo)]
[1] "cab"  "back"

grepl returns a TRUE/FALSE vector.

On Thu, 20 Aug 2020 at 02:53, Ivan Calandra  wrote:

> Dear useRs,
>
> I feel really stupid, but I cannot understand why "&" doesn't work as I
> expect, while "|" does.
>
> I have the following vector:
> mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> "SSFA-ConfoMap_Sheeps_NMPfilled.csv", "SSFA-Toothfrax_GuineaPigs.xlsx",
> "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> and I want to find the values that include both "ConfoMap" and
> "GuineaPigs".
>
> If I do:
> grep("ConfoMap", mydata, value=TRUE)
> it returns an empty vector, character(0).
>
> But if I do:
> grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> it returns all the elements that include either "ConfoMap" or
> "GuineaPigs", as I would expect.
>
> So what is wrong with my "&" construct? How can I return the elements
> that include both parts?
>
> Thank you for your help!
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> __
> 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] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Jim Lemon
Hi Paul,
I ran this:

library(qcc)
pareto.chart(dataset2$Points)

and like you, got the chart. As you have 140 long labels, I thought at
first it might be the function trying to abbreviate some of them and
actually displaying about 1 in 5. Looking at the code for the
function, this is not the case. You can get the labels (sort of) by
specifying a very wide graphic device and setting the names of the
input vector to dataset2$School:

dpoints<-dataset2$Points
pdf("qcc_dataset2.pdf",width=20,height=5)
names(dpoints)<-dataset2$School
pareto.chart(dpoints)
dev.off()

The attached image shows what I mean.

Jim

On Thu, Aug 20, 2020 at 7:27 AM Paul Bernal  wrote:
>
> Dear friends,
>
> Hope you are doing well. I am currently using R version 3.6.2. I installed
> and loaded package qcc by Mr. Luca Scrucca.
>
> This is the structure of my data:
>
> str(dataset2)
> 'data.frame':   140 obs. of  2 variables:
>  $ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116 35
> 106 65 17 ...
>  $ Points: num  55 43 24 21 20 20 18 17 16 16 ...
>
>
>
> I tried using the function pareto.chart from the qcc package, but the names
> of the columns in the pareto chart are some codes that do not match the
> school names in the School column of dataset2.
>
> The graph is generated without any issues, it's just that I want the bars
> to have the school labels, how can I accomplish this?
>
> Below is the dput() of my dataset.
>
> dput(dataset2)
> structure(list(School = structure(c(39L, 29L, 66L, 16L, 67L,
> 116L, 35L, 106L, 65L, 17L, 12L, 55L, 136L, 8L, 24L, 140L, 123L,
> 114L, 22L, 15L, 98L, 4L, 107L, 110L, 20L, 76L, 19L, 25L, 93L,
> 14L, 46L, 7L, 104L, 121L, 23L, 88L, 74L, 41L, 103L, 59L, 96L,
> 95L, 30L, 109L, 117L, 132L, 47L, 21L, 137L, 79L, 115L, 101L,
> 125L, 2L, 129L, 71L, 73L, 58L, 127L, 131L, 78L, 18L, 50L, 100L,
> 80L, 37L, 38L, 108L, 40L, 85L, 86L, 45L, 138L, 126L, 34L, 135L,
> 5L, 1L, 31L, 82L, 87L, 63L, 105L, 68L, 28L, 72L, 111L, 49L, 112L,
> 32L, 70L, 10L, 3L, 118L, 44L, 133L, 57L, 48L, 64L, 97L, 43L,
> 99L, 56L, 9L, 119L, 61L, 77L, 81L, 51L, 11L, 52L, 42L, 60L, 53L,
> 134L, 122L, 124L, 128L, 94L, 130L, 92L, 33L, 6L, 26L, 113L, 27L,
> 69L, 36L, 75L, 102L, 83L, 84L, 120L, 13L, 54L, 62L, 89L, 90L,
> 91L, 139L), .Label = c("24 de Diciembre", "Achiote", "Aguadulce",
> "Alcalde Díaz", "Alto Boquete", "Amador", "Amelia Denis de Icaza",
> "Ancón", "Antón", "Arnulfo Arias", "Arosemena", "Arraiján", "Bajo Boquete",
> "Barrio Balboa", "Barrio Colón", "Barrio Norte", "Barrio Sur",
> "Bejuco", "Belisario Frías", "Belisario Porras", "Bella Vista",
> "Betania", "Buena Vista", "Burunga", "Calidonia", "Cañaveral",
> "Canto del Llano", "Capira", "Cativá", "Cermeño", "Cerro Silvestre",
> "Chame", "Chepo", "Chicá", "Chilibre", "Chitré", "Ciricito",
> "Comarca Guna de Madugandí", "Cristóbal", "Cristóbal Este", "Curundú",
> "David", "Don Bosco", "El Arado", "El Caño", "El Chorrillo",
> "El Coco", "El Espino", "El Guabo", "El Harino", "El Higo", "El Llano",
> "El Roble", "El Valle", "Ernesto Córdoba Campos", "Escobal",
> "Feuillet", "Garrote o Puerto Lindo", "Guadalupe", "Herrera",
> "Hurtado", "Isla de Cañas", "Isla Grande", "Iturralde", "José Domingo
> Espinar",
> "Juan Demóstenes Arosemena", "Juan Díaz", "La Concepción", "La Ensenada",
> "La Laguna", "La Mesa", "La Raya de Calobre", "La Represa", "Las Cumbres",
> "Las Lajas", "Las Mañanitas", "Las Ollas Arriba", "Lídice", "Limón",
> "Los Díaz", "Los Llanitos", "María Chiquita", "Mateo Iturralde",
> "Miguel de la Borda", "Nombre de Dios", "Nueva Providencia",
> "Nuevo Chagres", "Nuevo Emperador", "Obaldía", "Ocú", "Olá",
> "Omar Torrijos", "Pacora", "Pajonal", "Palmas Bellas", "Parque Lefevre",
> "Pedasí", "Pedregal", "Penonomé", "Piña", "Playa Leona", "Pocrí",
> "Portobelo", "Pueblo Nuevo", "Puerto Armuelles", "Puerto Caimito",
> "Puerto Pilón", "Punta Chame", "Rio Abajo", "Río Abajo", "Río Grande",
> "Río Hato", "Río Indio", "Rufina Alfaro", "Sabanagrande", "Sabanitas",
> "Sajalices", "Salamanca", "San Carlos", "San Felipe", "San Francisco",
> "San José", "San Juan", "San Juan Bautista", "San Martín", "San Martín de
> Porres",
> "Santa Ana", "Santa Clara", "Santa Fe", "Santa Isabel", "Santa Rita",
> "Santa Rosa", "Santiago", "Santiago Este", "Tinajas", "Tocumen",
> "Veracruz", "Victoriano Lorenzo", "Villa Rosario", "Vista Alegre"
> ), class = "factor"), Points = c(55, 43, 24, 21, 20, 20, 18,
> 17, 16, 16, 15, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 9, 9,
> 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
> 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
> 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA, -140L
> ), class = "data.frame")
>
> Best regards,
>
> Paul
>
> [[alternative HTML version deleted]]
>
> 

Re: [R] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Rasmus Liland
Dear Paul,  I answer inline:

On 2020-08-19 16:27 -0500, Paul Bernal wrote:
| 
| I tried using the function 
| pareto.chart from the qcc package, but 
| the names of the columns in the pareto 
| chart are some codes 

What codes?  Can you please elaborate on 
this?

| that do not match the school names in 
| the School column of dataset2.

Does this mean there exists a third 
hidden vector not included in dataset2 
which conflicts with dataset2$School?

| The graph is generated without any 
| issues, 

Good!

| it's just that I want the bars 
| to have the school labels, how can I 
| accomplish this?

So as ?qcc::pareto.chart states, 
qcc::pareto.chart needs a vector of 
values, data, and names(data) can be 
used to label the bars, there are also 
some examples at the bottom.

Just doing this makes the labels show 
up. 

points <- dataset2$Points
names(points) <- dataset2$School
qcc::pareto.chart(points,
  main="Pareto Chart for School Points")

Was this what you were looking to do?

Best,
Rasmus


signature.asc
Description: PGP signature
__
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] & and |

2020-08-19 Thread Rasmus Liland
On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  wrote:
| 
| I have the following vector:
|   mydata <- 
|   c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv", 
|   "SSFA-ConfoMap_Lithics_NMPfilled.csv", 
|   "SSFA-ConfoMap_Sheeps_NMPfilled.csv", 
|   "SSFA-Toothfrax_GuineaPigs.xlsx", 
|   "SSFA-Toothfrax_Lithics.xlsx", 
|   "SSFA-Toothfrax_Sheeps.xlsx")
| and I want to find the values that 
| include both "ConfoMap" and 
| "GuineaPigs".

Dear Ivan,

I also found this[1], so this line 
returns 1 like many of these other 
suggestions:

grep("(.*ConfoMap)(.*GuineaPigs)", mydata)

Best,
Rasmus

[1] https://stackoverflow.com/questions/13187414/r-grep-is-there-an-and-operator


signature.asc
Description: PGP signature
__
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] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Paul Bernal
Dear friends,

Hope you are doing well. I am currently using R version 3.6.2. I installed
and loaded package qcc by Mr. Luca Scrucca.

This is the structure of my data:

str(dataset2)
'data.frame':   140 obs. of  2 variables:
 $ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116 35
106 65 17 ...
 $ Points: num  55 43 24 21 20 20 18 17 16 16 ...



I tried using the function pareto.chart from the qcc package, but the names
of the columns in the pareto chart are some codes that do not match the
school names in the School column of dataset2.

The graph is generated without any issues, it's just that I want the bars
to have the school labels, how can I accomplish this?

Below is the dput() of my dataset.

dput(dataset2)
structure(list(School = structure(c(39L, 29L, 66L, 16L, 67L,
116L, 35L, 106L, 65L, 17L, 12L, 55L, 136L, 8L, 24L, 140L, 123L,
114L, 22L, 15L, 98L, 4L, 107L, 110L, 20L, 76L, 19L, 25L, 93L,
14L, 46L, 7L, 104L, 121L, 23L, 88L, 74L, 41L, 103L, 59L, 96L,
95L, 30L, 109L, 117L, 132L, 47L, 21L, 137L, 79L, 115L, 101L,
125L, 2L, 129L, 71L, 73L, 58L, 127L, 131L, 78L, 18L, 50L, 100L,
80L, 37L, 38L, 108L, 40L, 85L, 86L, 45L, 138L, 126L, 34L, 135L,
5L, 1L, 31L, 82L, 87L, 63L, 105L, 68L, 28L, 72L, 111L, 49L, 112L,
32L, 70L, 10L, 3L, 118L, 44L, 133L, 57L, 48L, 64L, 97L, 43L,
99L, 56L, 9L, 119L, 61L, 77L, 81L, 51L, 11L, 52L, 42L, 60L, 53L,
134L, 122L, 124L, 128L, 94L, 130L, 92L, 33L, 6L, 26L, 113L, 27L,
69L, 36L, 75L, 102L, 83L, 84L, 120L, 13L, 54L, 62L, 89L, 90L,
91L, 139L), .Label = c("24 de Diciembre", "Achiote", "Aguadulce",
"Alcalde Díaz", "Alto Boquete", "Amador", "Amelia Denis de Icaza",
"Ancón", "Antón", "Arnulfo Arias", "Arosemena", "Arraiján", "Bajo Boquete",
"Barrio Balboa", "Barrio Colón", "Barrio Norte", "Barrio Sur",
"Bejuco", "Belisario Frías", "Belisario Porras", "Bella Vista",
"Betania", "Buena Vista", "Burunga", "Calidonia", "Cañaveral",
"Canto del Llano", "Capira", "Cativá", "Cermeño", "Cerro Silvestre",
"Chame", "Chepo", "Chicá", "Chilibre", "Chitré", "Ciricito",
"Comarca Guna de Madugandí", "Cristóbal", "Cristóbal Este", "Curundú",
"David", "Don Bosco", "El Arado", "El Caño", "El Chorrillo",
"El Coco", "El Espino", "El Guabo", "El Harino", "El Higo", "El Llano",
"El Roble", "El Valle", "Ernesto Córdoba Campos", "Escobal",
"Feuillet", "Garrote o Puerto Lindo", "Guadalupe", "Herrera",
"Hurtado", "Isla de Cañas", "Isla Grande", "Iturralde", "José Domingo
Espinar",
"Juan Demóstenes Arosemena", "Juan Díaz", "La Concepción", "La Ensenada",
"La Laguna", "La Mesa", "La Raya de Calobre", "La Represa", "Las Cumbres",
"Las Lajas", "Las Mañanitas", "Las Ollas Arriba", "Lídice", "Limón",
"Los Díaz", "Los Llanitos", "María Chiquita", "Mateo Iturralde",
"Miguel de la Borda", "Nombre de Dios", "Nueva Providencia",
"Nuevo Chagres", "Nuevo Emperador", "Obaldía", "Ocú", "Olá",
"Omar Torrijos", "Pacora", "Pajonal", "Palmas Bellas", "Parque Lefevre",
"Pedasí", "Pedregal", "Penonomé", "Piña", "Playa Leona", "Pocrí",
"Portobelo", "Pueblo Nuevo", "Puerto Armuelles", "Puerto Caimito",
"Puerto Pilón", "Punta Chame", "Rio Abajo", "Río Abajo", "Río Grande",
"Río Hato", "Río Indio", "Rufina Alfaro", "Sabanagrande", "Sabanitas",
"Sajalices", "Salamanca", "San Carlos", "San Felipe", "San Francisco",
"San José", "San Juan", "San Juan Bautista", "San Martín", "San Martín de
Porres",
"Santa Ana", "Santa Clara", "Santa Fe", "Santa Isabel", "Santa Rita",
"Santa Rosa", "Santiago", "Santiago Este", "Tinajas", "Tocumen",
"Veracruz", "Victoriano Lorenzo", "Villa Rosario", "Vista Alegre"
), class = "factor"), Points = c(55, 43, 24, 21, 20, 20, 18,
17, 16, 16, 15, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 9, 9,
9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA, -140L
), class = "data.frame")

Best regards,

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-es] Redo en RStudio, Ctrl y?

2020-08-19 Thread Xavier-Andoni Tibau Alberdi
En mi caso a veces funciona ctr+alt+Z.

El mié., 19 ago. 2020 21:46, Carlos Ortega 
escribió:

> Hola Manuel,
>
> En Mac son otra combinación, pero sí que funcionan.
> RStudio tiene un grupo de soporte (más bien es una Community) donde podrías
> comentarlo por si es un bug.
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
>
> El mié., 19 ago. 2020 a las 19:52, Manuel Mendoza (<
> mmend...@fulbrightmail.org>) escribió:
>
> > Buenas tardes. Más bien una curiosidad.
> > Echaba de menos poder rehacer con *Ctrl y* lo deshecho con *Ctrl z*. Lo
> > curioso es que RStudio, desde hace un tiempo, en la pestaña *Edit*, al
> lado
> > de *Redo *pone "*Ctrl y", *pero *Ctrl y* no funciona. ¿sabe alguien por
> > qué?
> > Gracias,
> > Manuel
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

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


Re: [R-es] Redo en RStudio, Ctrl y?

2020-08-19 Thread Carlos Ortega
Hola Manuel,

En Mac son otra combinación, pero sí que funcionan.
RStudio tiene un grupo de soporte (más bien es una Community) donde podrías
comentarlo por si es un bug.

Saludos,
Carlos Ortega
www.qualityexcellence.es


El mié., 19 ago. 2020 a las 19:52, Manuel Mendoza (<
mmend...@fulbrightmail.org>) escribió:

> Buenas tardes. Más bien una curiosidad.
> Echaba de menos poder rehacer con *Ctrl y* lo deshecho con *Ctrl z*. Lo
> curioso es que RStudio, desde hace un tiempo, en la pestaña *Edit*, al lado
> de *Redo *pone "*Ctrl y", *pero *Ctrl y* no funciona. ¿sabe alguien por
> qué?
> Gracias,
> Manuel
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


[R-es] Redo en RStudio, Ctrl y?

2020-08-19 Thread Manuel Mendoza
Buenas tardes. Más bien una curiosidad.
Echaba de menos poder rehacer con *Ctrl y* lo deshecho con *Ctrl z*. Lo
curioso es que RStudio, desde hace un tiempo, en la pestaña *Edit*, al lado
de *Redo *pone "*Ctrl y", *pero *Ctrl y* no funciona. ¿sabe alguien por
qué?
Gracias,
Manuel

[[alternative HTML version deleted]]

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


Re: [R] combine filter() and select()

2020-08-19 Thread Jeff Newmiller
The whole point of dplyr primitives is to support data frames... that is, lists 
of columns. When you pare your data frame down to one column you are almost 
certainly using the wrong tool for the job.

So, sure, your code works... and it even does what you wanted in the dplyr 
style, but what a pointless exercise.

grep( "a", mytbl$file, value=TRUE )

On August 19, 2020 7:56:32 AM PDT, Ivan Calandra  wrote:
>Dear useRs,
>
>I'm new to the tidyverse world and I need some help on basic things.
>
>I have the following tibble:
>mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop =
>1:6), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
>
>I want to subset the rows with "a" in the column "files", and keep only
>that column.
>
>So I did:
>myfile <- mytbl %>%
>  filter(grepl("a", files)) %>%
>  select(files)
>
>It works, but I believe there must be an easier way to combine filter()
>and select(), right?
>
>Thank you!
>Ivan

-- 
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] combine filter() and select()

2020-08-19 Thread Chris Evans
Inline

- Original Message -
> From: "Ivan Calandra" 
> To: "R-help" 
> Sent: Wednesday, 19 August, 2020 16:56:32
> Subject: [R] combine filter() and select()

> Dear useRs,
> 
> I'm new to the tidyverse world and I need some help on basic things.
> 
> I have the following tibble:
> mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop =
> 1:6), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
> 
> I want to subset the rows with "a" in the column "files", and keep only
> that column.
> 
> So I did:
> myfile <- mytbl %>%
>  filter(grepl("a", files)) %>%
>  select(files)
> 
> It works, but I believe there must be an easier way to combine filter()
> and select(), right?

I would write 

mytbl %>%
  filter(grepl("a", files)) %>%
  select(files) -> myfile

as I like to keep a sort of "top to bottom and left to right" flow when writing 
in the tidyverse dialect of R but that's really not important.

Apart from that I think what you've done is "proper tidyverse". To me another 
difference between the dialects is that classical R often seems to put value 
on, and make it easy, to do things with incredible few characters.  I think the 
people who are brilliant at that sort of coding, and there are many on this 
list, that sort of coding is also easy to read.  I know that Chinese is easy to 
read if you grew up on it but to a bear of little brain like me, the much more 
verbose style of tidyverse repays typing time with readability when I come back 
to my code and, though I have little experience of this yet, when I read other 
poeple's code.

What did you think wasn't "easy" about what you wrote?

Very best (all),

Chris

> 
> Thank you!
> Ivan
> 
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
> 
> __
> 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.

-- 
Small contribution in our coronavirus rigours: 
https://www.coresystemtrust.org.uk/home/free-options-to-replace-paper-core-forms-during-the-coronavirus-pandemic/

Chris Evans  Visiting Professor, University of Sheffield 

I do some consultation work for the University of Roehampton 
 and other places
but  remains my main Email address.  I have a work web site 
at:
   https://www.psyctc.org/psyctc/
and a site I manage for CORE and CORE system trust at:
   http://www.coresystemtrust.org.uk/
I have "semigrated" to France, see: 
   https://www.psyctc.org/pelerinage2016/semigrating-to-france/ 
   
https://www.psyctc.org/pelerinage2016/register-to-get-updates-from-pelerinage2016/

If you want an Emeeting, I am trying to keep them to Thursdays and my diary is 
at:
   https://www.psyctc.org/pelerinage2016/ceworkdiary/
Beware: French time, generally an hour ahead of UK.

__
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] & and |

2020-08-19 Thread William Dunlap via R-help
Instead of intersect you could use grepl(pattern1,x) &
grepl(pattern2,x).  Use which() on the result if you must have
integers, but the logicals that grepl() produces are often easier to
use as subscripts.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 19, 2020 at 8:54 AM Ivan Calandra  wrote:
>
> Indeed!
> I was just hoping that there would be a shorter way... intersect() is a
> nice alternative too. Maybe I can make it work with pipes so that I
> don't have to repeat "mydata" but that's another story.
>
> Thank you for the help!
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 19/08/2020 17:31, Bert Gunter wrote:
> > Well... wouldn't it be:
> >
> > rep("(ConfoMap.*GuineaPigs)|(GuineaPigs.*ConfoMap)", mydata, value=TRUE)
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming along
> > and sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Wed, Aug 19, 2020 at 8:23 AM Ivan Calandra  > > wrote:
> >
> > Thank you Bert for the pointer.
> >
> > So I guess the solution is:
> > grep("ConfoMap.+GuineaPigs", mydata, value=TRUE)
> >
> > This is not the case here, but what if "GuineaPigs" comes before
> > "ConfoMap"?
> > Of course I could do two "grep()" calls, but if there a better
> > solution?
> >
> > Ivan
> >
> > --
> > Dr. Ivan Calandra
> > TraCEr, laboratory for Traceology and Controlled Experiments
> > MONREPOS Archaeological Research Centre and
> > Museum for Human Behavioural Evolution
> > Schloss Monrepos
> > 56567 Neuwied, Germany
> > +49 (0) 2631 9772-243
> > https://www.researchgate.net/profile/Ivan_Calandra
> >
> > On 19/08/2020 17:07, Bert Gunter wrote:
> > > "&" is not a regex metacharacter.
> > > See ?regexp
> > >
> > > Bert Gunter
> > >
> > > "The trouble with having an open mind is that people keep coming
> > along
> > > and sticking things into it."
> > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> > >
> > >
> > > On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  > 
> > > >> wrote:
> > >
> > > Dear useRs,
> > >
> > > I feel really stupid, but I cannot understand why "&"
> > doesn't work
> > > as I
> > > expect, while "|" does.
> > >
> > > I have the following vector:
> > > mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> > > "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> > > "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> > > "SSFA-Toothfrax_GuineaPigs.xlsx",
> > > "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> > > and I want to find the values that include both "ConfoMap" and
> > > "GuineaPigs".
> > >
> > > If I do:
> > > grep("ConfoMap", mydata, value=TRUE)
> > > it returns an empty vector, character(0).
> > >
> > > But if I do:
> > > grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> > > it returns all the elements that include either "ConfoMap" or
> > > "GuineaPigs", as I would expect.
> > >
> > > So what is wrong with my "&" construct? How can I return the
> > elements
> > > that include both parts?
> > >
> > > Thank you for your help!
> > > Ivan
> > >
> > > --
> > > Dr. Ivan Calandra
> > > TraCEr, laboratory for Traceology and Controlled Experiments
> > > MONREPOS Archaeological Research Centre and
> > > Museum for Human Behavioural Evolution
> > > Schloss Monrepos
> > > 56567 Neuwied, Germany
> > > +49 (0) 2631 9772-243
> > > https://www.researchgate.net/profile/Ivan_Calandra
> > >
> > > __
> > > 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
> > 

Re: [R] & and |

2020-08-19 Thread Henrik Bengtsson
A version of Eric's answer is to use grepl(), which returns a logical vector:

mydata[grepl("ConfoMap", mydata) & grepl("GuineaPigs", mydata)]

with the OR analogue:

mydata[grepl("ConfoMap", mydata) | grepl("GuineaPigs", mydata)]

/Henrik

On Wed, Aug 19, 2020 at 8:24 AM Ivan Calandra  wrote:
>
> Thank you Eric, I didn't think about intersect().
>
> Now I'm trying to do that in tidyverse with pipes, and I think that's
> too much for me for now!
>
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 19/08/2020 17:17, Eric Berger wrote:
> > mydata[ intersect( grep("ConfoMap", mydata), grep("GuineaPigs",
> > mydata)  ) ]
> >
> >
> >
> > On Wed, Aug 19, 2020 at 6:13 PM Bert Gunter  > > wrote:
> >
> > "&" is not a regex metacharacter.
> > See ?regexp
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming
> > along and
> > sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  > > wrote:
> >
> > > Dear useRs,
> > >
> > > I feel really stupid, but I cannot understand why "&" doesn't
> > work as I
> > > expect, while "|" does.
> > >
> > > I have the following vector:
> > > mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> > > "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> > > "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> > "SSFA-Toothfrax_GuineaPigs.xlsx",
> > > "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> > > and I want to find the values that include both "ConfoMap" and
> > > "GuineaPigs".
> > >
> > > If I do:
> > > grep("ConfoMap", mydata, value=TRUE)
> > > it returns an empty vector, character(0).
> > >
> > > But if I do:
> > > grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> > > it returns all the elements that include either "ConfoMap" or
> > > "GuineaPigs", as I would expect.
> > >
> > > So what is wrong with my "&" construct? How can I return the
> > elements
> > > that include both parts?
> > >
> > > Thank you for your help!
> > > Ivan
> > >
> > > --
> > > Dr. Ivan Calandra
> > > TraCEr, laboratory for Traceology and Controlled Experiments
> > > MONREPOS Archaeological Research Centre and
> > > Museum for Human Behavioural Evolution
> > > Schloss Monrepos
> > > 56567 Neuwied, Germany
> > > +49 (0) 2631 9772-243
> > > https://www.researchgate.net/profile/Ivan_Calandra
> > >
> > > __
> > > 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-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] & and |

2020-08-19 Thread Ivan Calandra
Indeed!
I was just hoping that there would be a shorter way... intersect() is a
nice alternative too. Maybe I can make it work with pipes so that I
don't have to repeat "mydata" but that's another story.

Thank you for the help!
Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 19/08/2020 17:31, Bert Gunter wrote:
> Well... wouldn't it be:
>
> rep("(ConfoMap.*GuineaPigs)|(GuineaPigs.*ConfoMap)", mydata, value=TRUE)
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 19, 2020 at 8:23 AM Ivan Calandra  > wrote:
>
> Thank you Bert for the pointer.
>
> So I guess the solution is:
> grep("ConfoMap.+GuineaPigs", mydata, value=TRUE)
>
> This is not the case here, but what if "GuineaPigs" comes before
> "ConfoMap"?
> Of course I could do two "grep()" calls, but if there a better
> solution?
>
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 19/08/2020 17:07, Bert Gunter wrote:
> > "&" is not a regex metacharacter.
> > See ?regexp
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming
> along
> > and sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  
> > >> wrote:
> >
> >     Dear useRs,
> >
> >     I feel really stupid, but I cannot understand why "&"
> doesn't work
> >     as I
> >     expect, while "|" does.
> >
> >     I have the following vector:
> >     mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> >     "SSFA-ConfoMap_Lithics_NMPfilled.csv", 
> >     "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> >     "SSFA-Toothfrax_GuineaPigs.xlsx",
> >     "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> >     and I want to find the values that include both "ConfoMap" and
> >     "GuineaPigs".
> >
> >     If I do:
> >     grep("ConfoMap", mydata, value=TRUE)
> >     it returns an empty vector, character(0).
> >
> >     But if I do:
> >     grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> >     it returns all the elements that include either "ConfoMap" or
> >     "GuineaPigs", as I would expect.
> >
> >     So what is wrong with my "&" construct? How can I return the
> elements
> >     that include both parts?
> >
> >     Thank you for your help!
> >     Ivan
> >
> >     --
> >     Dr. Ivan Calandra
> >     TraCEr, laboratory for Traceology and Controlled Experiments
> >     MONREPOS Archaeological Research Centre and
> >     Museum for Human Behavioural Evolution
> >     Schloss Monrepos
> >     56567 Neuwied, Germany
> >     +49 (0) 2631 9772-243
> >     https://www.researchgate.net/profile/Ivan_Calandra
> >
> >     __
> >     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-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] & and |

2020-08-19 Thread Bert Gunter
Well... wouldn't it be:

rep("(ConfoMap.*GuineaPigs)|(GuineaPigs.*ConfoMap)", mydata, value=TRUE)

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 19, 2020 at 8:23 AM Ivan Calandra  wrote:

> Thank you Bert for the pointer.
>
> So I guess the solution is:
> grep("ConfoMap.+GuineaPigs", mydata, value=TRUE)
>
> This is not the case here, but what if "GuineaPigs" comes before
> "ConfoMap"?
> Of course I could do two "grep()" calls, but if there a better solution?
>
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 19/08/2020 17:07, Bert Gunter wrote:
> > "&" is not a regex metacharacter.
> > See ?regexp
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming along
> > and sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  > > wrote:
> >
> > Dear useRs,
> >
> > I feel really stupid, but I cannot understand why "&" doesn't work
> > as I
> > expect, while "|" does.
> >
> > I have the following vector:
> > mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> > "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> > "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> > "SSFA-Toothfrax_GuineaPigs.xlsx",
> > "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> > and I want to find the values that include both "ConfoMap" and
> > "GuineaPigs".
> >
> > If I do:
> > grep("ConfoMap", mydata, value=TRUE)
> > it returns an empty vector, character(0).
> >
> > But if I do:
> > grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> > it returns all the elements that include either "ConfoMap" or
> > "GuineaPigs", as I would expect.
> >
> > So what is wrong with my "&" construct? How can I return the elements
> > that include both parts?
> >
> > Thank you for your help!
> > Ivan
> >
> > --
> > Dr. Ivan Calandra
> > TraCEr, laboratory for Traceology and Controlled Experiments
> > MONREPOS Archaeological Research Centre and
> > Museum for Human Behavioural Evolution
> > Schloss Monrepos
> > 56567 Neuwied, Germany
> > +49 (0) 2631 9772-243
> > https://www.researchgate.net/profile/Ivan_Calandra
> >
> > __
> > 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] & and |

2020-08-19 Thread Ivan Calandra
Thank you Bert for the pointer.

So I guess the solution is:
grep("ConfoMap.+GuineaPigs", mydata, value=TRUE)

This is not the case here, but what if "GuineaPigs" comes before
"ConfoMap"?
Of course I could do two "grep()" calls, but if there a better solution?

Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 19/08/2020 17:07, Bert Gunter wrote:
> "&" is not a regex metacharacter.
> See ?regexp
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  > wrote:
>
> Dear useRs,
>
> I feel really stupid, but I cannot understand why "&" doesn't work
> as I
> expect, while "|" does.
>
> I have the following vector:
> mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> "SSFA-ConfoMap_Lithics_NMPfilled.csv", 
> "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> "SSFA-Toothfrax_GuineaPigs.xlsx",
> "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> and I want to find the values that include both "ConfoMap" and
> "GuineaPigs".
>
> If I do:
> grep("ConfoMap", mydata, value=TRUE)
> it returns an empty vector, character(0).
>
> But if I do:
> grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> it returns all the elements that include either "ConfoMap" or
> "GuineaPigs", as I would expect.
>
> So what is wrong with my "&" construct? How can I return the elements
> that include both parts?
>
> Thank you for your help!
> Ivan
>
> -- 
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> __
> 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] & and |

2020-08-19 Thread Ivan Calandra
Thank you Eric, I didn't think about intersect().

Now I'm trying to do that in tidyverse with pipes, and I think that's
too much for me for now!

Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 19/08/2020 17:17, Eric Berger wrote:
> mydata[ intersect( grep("ConfoMap", mydata), grep("GuineaPigs",
> mydata)  ) ]
>
>
>
> On Wed, Aug 19, 2020 at 6:13 PM Bert Gunter  > wrote:
>
> "&" is not a regex metacharacter.
> See ?regexp
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming
> along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  > wrote:
>
> > Dear useRs,
> >
> > I feel really stupid, but I cannot understand why "&" doesn't
> work as I
> > expect, while "|" does.
> >
> > I have the following vector:
> > mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> > "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> > "SSFA-ConfoMap_Sheeps_NMPfilled.csv",
> "SSFA-Toothfrax_GuineaPigs.xlsx",
> > "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> > and I want to find the values that include both "ConfoMap" and
> > "GuineaPigs".
> >
> > If I do:
> > grep("ConfoMap", mydata, value=TRUE)
> > it returns an empty vector, character(0).
> >
> > But if I do:
> > grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> > it returns all the elements that include either "ConfoMap" or
> > "GuineaPigs", as I would expect.
> >
> > So what is wrong with my "&" construct? How can I return the
> elements
> > that include both parts?
> >
> > Thank you for your help!
> > Ivan
> >
> > --
> > Dr. Ivan Calandra
> > TraCEr, laboratory for Traceology and Controlled Experiments
> > MONREPOS Archaeological Research Centre and
> > Museum for Human Behavioural Evolution
> > Schloss Monrepos
> > 56567 Neuwied, Germany
> > +49 (0) 2631 9772-243
> > https://www.researchgate.net/profile/Ivan_Calandra
> >
> > __
> > 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-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] & and |

2020-08-19 Thread Eric Berger
mydata[ intersect( grep("ConfoMap", mydata), grep("GuineaPigs", mydata)  ) ]



On Wed, Aug 19, 2020 at 6:13 PM Bert Gunter  wrote:

> "&" is not a regex metacharacter.
> See ?regexp
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  wrote:
>
> > Dear useRs,
> >
> > I feel really stupid, but I cannot understand why "&" doesn't work as I
> > expect, while "|" does.
> >
> > I have the following vector:
> > mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> > "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> > "SSFA-ConfoMap_Sheeps_NMPfilled.csv", "SSFA-Toothfrax_GuineaPigs.xlsx",
> > "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> > and I want to find the values that include both "ConfoMap" and
> > "GuineaPigs".
> >
> > If I do:
> > grep("ConfoMap", mydata, value=TRUE)
> > it returns an empty vector, character(0).
> >
> > But if I do:
> > grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> > it returns all the elements that include either "ConfoMap" or
> > "GuineaPigs", as I would expect.
> >
> > So what is wrong with my "&" construct? How can I return the elements
> > that include both parts?
> >
> > Thank you for your help!
> > Ivan
> >
> > --
> > Dr. Ivan Calandra
> > TraCEr, laboratory for Traceology and Controlled Experiments
> > MONREPOS Archaeological Research Centre and
> > Museum for Human Behavioural Evolution
> > Schloss Monrepos
> > 56567 Neuwied, Germany
> > +49 (0) 2631 9772-243
> > https://www.researchgate.net/profile/Ivan_Calandra
> >
> > __
> > 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] & and |

2020-08-19 Thread Bert Gunter
"&" is not a regex metacharacter.
See ?regexp

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra  wrote:

> Dear useRs,
>
> I feel really stupid, but I cannot understand why "&" doesn't work as I
> expect, while "|" does.
>
> I have the following vector:
> mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
> "SSFA-ConfoMap_Lithics_NMPfilled.csv",
> "SSFA-ConfoMap_Sheeps_NMPfilled.csv", "SSFA-Toothfrax_GuineaPigs.xlsx",
> "SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
> and I want to find the values that include both "ConfoMap" and
> "GuineaPigs".
>
> If I do:
> grep("ConfoMap", mydata, value=TRUE)
> it returns an empty vector, character(0).
>
> But if I do:
> grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
> it returns all the elements that include either "ConfoMap" or
> "GuineaPigs", as I would expect.
>
> So what is wrong with my "&" construct? How can I return the elements
> that include both parts?
>
> Thank you for your help!
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> __
> 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] combine filter() and select()

2020-08-19 Thread Ivan Calandra
Dear useRs,

I'm new to the tidyverse world and I need some help on basic things.

I have the following tibble:
mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop =
1:6), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

I want to subset the rows with "a" in the column "files", and keep only
that column.

So I did:
myfile <- mytbl %>%
  filter(grepl("a", files)) %>%
  select(files)

It works, but I believe there must be an easier way to combine filter()
and select(), right?

Thank you!
Ivan

-- 
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

__
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] & and |

2020-08-19 Thread Ivan Calandra
Dear useRs,

I feel really stupid, but I cannot understand why "&" doesn't work as I
expect, while "|" does.

I have the following vector:
mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv",
"SSFA-ConfoMap_Lithics_NMPfilled.csv", 
"SSFA-ConfoMap_Sheeps_NMPfilled.csv", "SSFA-Toothfrax_GuineaPigs.xlsx",
"SSFA-Toothfrax_Lithics.xlsx", "SSFA-Toothfrax_Sheeps.xlsx")
and I want to find the values that include both "ConfoMap" and "GuineaPigs".

If I do:
grep("ConfoMap", mydata, value=TRUE)
it returns an empty vector, character(0).

But if I do:
grep("ConfoMap|GuineaPigs", mydata, value=TRUE)
it returns all the elements that include either "ConfoMap" or
"GuineaPigs", as I would expect.

So what is wrong with my "&" construct? How can I return the elements
that include both parts?

Thank you for your help!
Ivan

-- 
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

__
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 Script Modification Questions

2020-08-19 Thread Rasmus Liland
Dear Stephen,

I answer inline:

On 2020-08-19 12:57 +1000, Jim Lemon wrote:
| On Wed, Aug 19, 2020 at 3:09 AM Stephen P. Molnar  
wrote:
| |
| | What I would like to do is use 
| | linetype, rather than color, in line 
| | 27.

You need to specify linetype instead of 
color in ggplot::aes, like so

ggplot2::aes(
  x=date,
  y=count,
  linetype=cases)

and change 
scale_color_manual to 
scale_linetype_manual and its values 
like so

  ggplot2::scale_linetype_manual(
name = "Test",
labels = levels,
values =
  c("dotted",
"dashed",
"solid"))

| | The date in the title of the plot , 
| | line 33, is the max value of the 
| | date in in line 14 and I would like 
| | to use that rather than edit the 
| | Script every time the date changes.
| 
| Okay, I can't help much with the 
| ggplot stuff so forget the "lty=" 
| argument for that is base graphics. 
| However, you may get away with
| 
| ggtitle(paste0("COVID-19 Tests in Ohio \n(",date[length(date]),")"))+
| 
| I don't know whether the tidy* stuff 
| handles indexing in the same way as 
| base R.

I added a format, which converts it to 
the date format you mentioned (but with 
a zero in the month part ...):

  ggplot2::ggtitle(
paste0("COVID-19 Tests in Ohio \n(",
   format(max(dfO$date), "%m/%d/%y"), ")")) +

Here is the whole script:

datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;)

cases <- c("positive", "negative", "total")
levels <- paste0(
  toupper(substr(cases, 1, 1)),
  substr(cases, 2, nchar(cases)))

dfO <- data.frame(
  date=
rep(
  x=lubridate::ymd(datO$date),
  each=length(cases)),
  cases=levels,
  count=as.vector(t(datO[,cases])))
dfO$cases <- factor(dfO$cases, levels=levels)

file <- "/tmp/stephen.pdf"
res <- .5
width <- 9*res
height <- 5*res
pdf(file=file, width=width, height=height)

mapping <- ggplot2::aes(
  x=date,
  y=count,
  linetype=cases)

p <- 
  ggplot2::ggplot(
data=dfO,
mapping=mapping) +
  ggplot2::geom_line() +
  ggplot2::scale_linetype_manual(
name = "Test",
labels = levels,
values =
  c("dotted",
"dashed",
"solid")) +
  ggplot2::ylim(0, 2e6) +
  ggplot2::labs(
x = "Date",
y = "Number of Tests") +
  ggplot2::ggtitle(
paste0("COVID-19 Tests in Ohio \n(",
   format(max(dfO$date), "%m/%d/%y"), ")")) +
  ggplot2::theme_bw() +
  ggplot2::theme(
axis.text.x = 
  ggplot2::element_text(
angle = 30, 
hjust = 1),
plot.title = 
  ggplot2::element_text(
hjust = 0.5))

p

dev.off()

Best,
Rasmus


signature.asc
Description: PGP signature
__
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] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Valerio Leone Sciabolazza
Eric,
you are right! If I run the code on a different instance, it works.
There must be something in my old R environment that messed this up.
Thank you very much for checking this out.
Best,
Valerio

On Wed, Aug 19, 2020 at 11:36 AM Eric Berger  wrote:
>
> Hi Valerio,
> I did a copy-paste on your reproducible example and I had no problem with 
> chol(nls.out$hessian).
> In addition to summary() you can look at str() to display the structure of 
> any R object.
>
> > str(nls.out)
>
> List of 9
>  $ par :List of 3
>   ..$ a: num 8.99
>   ..$ b: num -1.01
>   ..$ c: num 6.02
>  $ hessian : num [1:3, 1:3] 10.3 43.2 19.9 43.2 382.2 ...
>   ..- attr(*, "dimnames")=List of 2
>   .. ..$ : chr [1:3] "a" "b" "c"
>   .. ..$ : chr [1:3] "a" "b" "c"
>  $ fvec: num [1:100] 0.0232 -0.105 -0.1332 0.0388 0.1482 ...
>  $ info: int 1
>  $ message : chr "Relative error in the sum of squares is at most `ftol'."
>  $ diag:List of 3
>   ..$ a: num 9.98
>   ..$ b: num 88.6
>   ..$ c: num 10
>  $ niter   : int 8
>  $ rsstrace: num [1:9] 1966.2 327.2 104.8 53.9 33.2 ...
>  $ deviance: num 1.06
>  - attr(*, "class")= chr "nls.lm"
>
> Also
> > nls.out$hessian
>  a b c
> a 10.26361  43.17086  19.89616
> b 43.17086 382.17773 166.43747
> c 19.89616 166.43747 100.0
>
> HTH,
> Eric
>
>
>
> On Wed, Aug 19, 2020 at 12:17 PM Valerio Leone Sciabolazza 
>  wrote:
>>
>> Dear R users,
>> I want to modify how the degrees of freedom are calculated from the
>> summary function of the package minpack.lm
>>
>> My first thought was to replicate how minpack.lm:::summary.nls.lm
>> works, and modify the line of the code that is relevant for my task.
>> However, for some reason I am not able to use the code contained in
>> this function to perform this operation.
>>
>> Here is a reproducible example.
>>
>> First, I run a NLLS regression using minpack.lm::nls.lm
>>
>> # From example 1 of the help page of ?minpack.lm::nls.lm
>> library(minpack.lm)
>> x <- seq(0,5,length=100)
>> getPred <- function(parS, xx) parS$a * exp(xx * parS$b) + parS$c
>> pp <- list(a=9,b=-1, c=6)
>> simDNoisy <- getPred(pp,x) + rnorm(length(x),sd=.1)
>> residFun <- function(p, observed, xx) observed - getPred(p,xx)
>> parStart <- list(a=3,b=-.001, c=1)
>> nls.out <- nls.lm(par=parStart, fn = residFun, observed = simDNoisy,
>> xx = x, control = nls.lm.control(nprint=1))
>> summary(nls.out)
>>
>> Now, by running minpack.lm:::summary.nls.lm in the console, I get the 
>> following
>> > minpack.lm:::summary.nls.lm
>> function (object, ...)
>> {
>> param <- coef(object)
>> pnames <- names(param)
>> ibb <- chol(object$hessian)
>> ih <- chol2inv(ibb)
>> p <- length(param)
>> rdf <- length(object$fvec) - p
>> resvar <- deviance(object)/rdf
>> se <- sqrt(diag(ih) * resvar)
>> names(se) <- pnames
>> tval <- param/se
>> param <- cbind(param, se, tval, 2 * pt(abs(tval), rdf, lower.tail = 
>> FALSE))
>> dimnames(param) <- list(pnames, c("Estimate", "Std. Error",
>> "t value", "Pr(>|t|)"))
>> ans <- list(residuals = object$fvec, sigma = sqrt(object$deviance/rdf),
>> df = c(p, rdf), cov.unscaled = ih, info = object$info,
>> niter = object$niter, stopmess = object$message, coefficients = 
>> param)
>> class(ans) <- "summary.nls.lm"
>> ans
>> }
>>
>> Specifically, my task requires to modify the object p of this
>> function, say I want to set p <- 2.
>>
>> To this purpose, I replicate what the summary function does using my
>> object (nls.out), however an error is returned at line three:
>> > param <- coef(nls.out)
>> > pnames <- names(param)
>> > ibb <- chol(nls.out$hessian)
>> Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  :
>>   'data' must be of a vector type, was 'NULL'
>>
>> The reason of the error is that there is no nls.out$hessian in nls.out.
>>
>> I guess that I am missing something about how summary functions work,
>> and this is the reason why I cannot use the code from
>> minpack.lm:::summary.nls.lm outside the minpack.lm environment.
>>
>> Does anyone have any hints on how to proceed? Any other way of dealing
>> with this issue will be equally appreciated.
>>
>> Thank you,
>> Valerio
>>
>> __
>> 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] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Eric Berger
Hi Valerio,
I did a copy-paste on your reproducible example and I had no problem with
chol(nls.out$hessian).
In addition to summary() you can look at str() to display the structure of
any R object.

> str(nls.out)

List of 9
 $ par :List of 3
  ..$ a: num 8.99
  ..$ b: num -1.01
  ..$ c: num 6.02
 $ hessian : num [1:3, 1:3] 10.3 43.2 19.9 43.2 382.2 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:3] "a" "b" "c"
  .. ..$ : chr [1:3] "a" "b" "c"
 $ fvec: num [1:100] 0.0232 -0.105 -0.1332 0.0388 0.1482 ...
 $ info: int 1
 $ message : chr "Relative error in the sum of squares is at most `ftol'."
 $ diag:List of 3
  ..$ a: num 9.98
  ..$ b: num 88.6
  ..$ c: num 10
 $ niter   : int 8
 $ rsstrace: num [1:9] 1966.2 327.2 104.8 53.9 33.2 ...
 $ deviance: num 1.06
 - attr(*, "class")= chr "nls.lm"

Also
> nls.out$hessian
 a b c
a 10.26361  43.17086  19.89616
b 43.17086 382.17773 166.43747
c 19.89616 166.43747 100.0

HTH,
Eric



On Wed, Aug 19, 2020 at 12:17 PM Valerio Leone Sciabolazza <
sciabola...@gmail.com> wrote:

> Dear R users,
> I want to modify how the degrees of freedom are calculated from the
> summary function of the package minpack.lm
>
> My first thought was to replicate how minpack.lm:::summary.nls.lm
> works, and modify the line of the code that is relevant for my task.
> However, for some reason I am not able to use the code contained in
> this function to perform this operation.
>
> Here is a reproducible example.
>
> First, I run a NLLS regression using minpack.lm::nls.lm
>
> # From example 1 of the help page of ?minpack.lm::nls.lm
> library(minpack.lm)
> x <- seq(0,5,length=100)
> getPred <- function(parS, xx) parS$a * exp(xx * parS$b) + parS$c
> pp <- list(a=9,b=-1, c=6)
> simDNoisy <- getPred(pp,x) + rnorm(length(x),sd=.1)
> residFun <- function(p, observed, xx) observed - getPred(p,xx)
> parStart <- list(a=3,b=-.001, c=1)
> nls.out <- nls.lm(par=parStart, fn = residFun, observed = simDNoisy,
> xx = x, control = nls.lm.control(nprint=1))
> summary(nls.out)
>
> Now, by running minpack.lm:::summary.nls.lm in the console, I get the
> following
> > minpack.lm:::summary.nls.lm
> function (object, ...)
> {
> param <- coef(object)
> pnames <- names(param)
> ibb <- chol(object$hessian)
> ih <- chol2inv(ibb)
> p <- length(param)
> rdf <- length(object$fvec) - p
> resvar <- deviance(object)/rdf
> se <- sqrt(diag(ih) * resvar)
> names(se) <- pnames
> tval <- param/se
> param <- cbind(param, se, tval, 2 * pt(abs(tval), rdf, lower.tail =
> FALSE))
> dimnames(param) <- list(pnames, c("Estimate", "Std. Error",
> "t value", "Pr(>|t|)"))
> ans <- list(residuals = object$fvec, sigma = sqrt(object$deviance/rdf),
> df = c(p, rdf), cov.unscaled = ih, info = object$info,
> niter = object$niter, stopmess = object$message, coefficients =
> param)
> class(ans) <- "summary.nls.lm"
> ans
> }
>
> Specifically, my task requires to modify the object p of this
> function, say I want to set p <- 2.
>
> To this purpose, I replicate what the summary function does using my
> object (nls.out), however an error is returned at line three:
> > param <- coef(nls.out)
> > pnames <- names(param)
> > ibb <- chol(nls.out$hessian)
> Error in array(x, c(length(x), 1L), if (!is.null(names(x)))
> list(names(x),  :
>   'data' must be of a vector type, was 'NULL'
>
> The reason of the error is that there is no nls.out$hessian in nls.out.
>
> I guess that I am missing something about how summary functions work,
> and this is the reason why I cannot use the code from
> minpack.lm:::summary.nls.lm outside the minpack.lm environment.
>
> Does anyone have any hints on how to proceed? Any other way of dealing
> with this issue will be equally appreciated.
>
> Thank you,
> Valerio
>
> __
> 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] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Valerio Leone Sciabolazza
Dear R users,
I want to modify how the degrees of freedom are calculated from the
summary function of the package minpack.lm

My first thought was to replicate how minpack.lm:::summary.nls.lm
works, and modify the line of the code that is relevant for my task.
However, for some reason I am not able to use the code contained in
this function to perform this operation.

Here is a reproducible example.

First, I run a NLLS regression using minpack.lm::nls.lm

# From example 1 of the help page of ?minpack.lm::nls.lm
library(minpack.lm)
x <- seq(0,5,length=100)
getPred <- function(parS, xx) parS$a * exp(xx * parS$b) + parS$c
pp <- list(a=9,b=-1, c=6)
simDNoisy <- getPred(pp,x) + rnorm(length(x),sd=.1)
residFun <- function(p, observed, xx) observed - getPred(p,xx)
parStart <- list(a=3,b=-.001, c=1)
nls.out <- nls.lm(par=parStart, fn = residFun, observed = simDNoisy,
xx = x, control = nls.lm.control(nprint=1))
summary(nls.out)

Now, by running minpack.lm:::summary.nls.lm in the console, I get the following
> minpack.lm:::summary.nls.lm
function (object, ...)
{
param <- coef(object)
pnames <- names(param)
ibb <- chol(object$hessian)
ih <- chol2inv(ibb)
p <- length(param)
rdf <- length(object$fvec) - p
resvar <- deviance(object)/rdf
se <- sqrt(diag(ih) * resvar)
names(se) <- pnames
tval <- param/se
param <- cbind(param, se, tval, 2 * pt(abs(tval), rdf, lower.tail = FALSE))
dimnames(param) <- list(pnames, c("Estimate", "Std. Error",
"t value", "Pr(>|t|)"))
ans <- list(residuals = object$fvec, sigma = sqrt(object$deviance/rdf),
df = c(p, rdf), cov.unscaled = ih, info = object$info,
niter = object$niter, stopmess = object$message, coefficients = param)
class(ans) <- "summary.nls.lm"
ans
}

Specifically, my task requires to modify the object p of this
function, say I want to set p <- 2.

To this purpose, I replicate what the summary function does using my
object (nls.out), however an error is returned at line three:
> param <- coef(nls.out)
> pnames <- names(param)
> ibb <- chol(nls.out$hessian)
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  :
  'data' must be of a vector type, was 'NULL'

The reason of the error is that there is no nls.out$hessian in nls.out.

I guess that I am missing something about how summary functions work,
and this is the reason why I cannot use the code from
minpack.lm:::summary.nls.lm outside the minpack.lm environment.

Does anyone have any hints on how to proceed? Any other way of dealing
with this issue will be equally appreciated.

Thank you,
Valerio

__
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] Binomial PCA Using pcr()

2020-08-19 Thread Ulrik Stervbo via R-help

Hi Prasad,

I think this might be a problem with the package, and you can try to 
contact the package author.


The error seem to arise because the pcr() cannot find the 
'negative-binomial' distribution


```
library(qualityTools)
x <- rnbinom(500, mu = 4, size = 100)
pcr(x, distribution = "negative-binomial")
```

When I look in the code of pcr(), there is some testing against the 
words 'negative binomial' (note the missing -), although the 
documentation clearly lists 'negative-binomial' as a possible 
distribution.


Unfortunately changing 'negative-binomial' to 'negative binomial' does 
not help, as


```
pcr(x, distribution = "negative binomial")
```

throws the error "object '.confintnbinom' not found" and a lot of 
warnings.


Best,
Ulrik


On 2020-08-12 12:50, Prasad DN wrote:

Hi All,

i am very new to R and need guidance.

Need help in doing process capability Analysis for my data set (6 
months of

data) given in below format:

Date   |   Opportunities  |  Defectives | DefectivesInPercent

I searched and found that pcr() from QualityTools package can be used 
for

this purpose.  The USL is 2% defectives.

MyData = read.csv(file.choose())   #select  CSV file that has data in 
above

mentioned format.
x <- MyData$DefectivesInPercent

pcr(x, distribution = "negative-binomial", usl=0.02)

I get error message as:
Error in pcr(x, distribution = "negative-binomial", usl = 0.02) :
  y distribution could not be found!

Please advise, how to proceed?

Regards,
Prasad DN

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