Re: [R] Question regarding reservoir volume and water level

2024-04-10 Thread javad bayat
> >> x6 <- x5 %>%
> >>   mutate(V_sum = cumsum(Vol)) %>%
> >>   mutate(A_sum = cumsum(Area))
> >> plot(x6$value~x6$V_sum)
> >>
> >> And I thought that it is possible to get the elevation for a specific
> >> volume by linear model between elevation and volume, as follow:
> >>
> >> # Get a linear model between elevation and the volume
> >> lm1 <- lm(value ~ V_sum, data = x6)
> >> d <- data.frame(V_sum = 14e6)  #
> >> predict(lm1, newdata = d)
> >>
> >> But it is not possible through the LM.
> >> Now I want to know what would be the water level in the reservoir if the
> >> reservoir volume doubled or we adding a known volume to it?
> >> Also what would be the volume if the water level increases to 1250 m?
> >>
> >> I would be more than happy if you help me to do this.
> >> Sincerely
> >>
> >> On Mon, Apr 8, 2024 at 12:23 AM  wrote:
> >>
> >>> John,
> >>>
> >>> Your reaction was what my original reaction was until I realized I had
> to
> >>> find out what a DEM file was and that contains enough of the kind of
> >>> depth-dimension data you describe albeit what may be a very irregular
> cross
> >>> section to calculate for areas and thence volumes.
> >>>
> >>> If I read it correctly, this can be a very real-world problem worthy
> of a
> >>> solution, such as in places like California where they had a tad more
> rain
> >>> than usual and some reservoirs may overflow. Someone else provided what
> >>> sounds like a mathematical algorithm but my guess is what is needed
> here is
> >>> perhaps less analytic since there may be no trivial way to create
> formulas
> >>> and take integrals and so on, but simply an approximate way to
> calculate
> >>> incremental volumes for each horizontal "slice" and keep adding or
> >>> subtracting them till you reach a target and then read off another
> variable
> >>> at that point such as depth.
> >>>
> >>> Some care must be taken as water level has to be relative to something
> and
> >>> many natural reservoirs have no unique bottom level. Some water may
> also be
> >>> stored underground and to the side and pour in if the level lowers or
> can
> >>> be
> >>> used to escape if the level rises.
> >>>
> >>>
> >>> -Original Message-
> >>> From: R-help  On Behalf Of Sorkin, John
> >>> Sent: Sunday, April 7, 2024 3:08 PM
> >>> To: Rui Barradas ; javad bayat <
> j.bayat...@gmail.com
> >>>> ;
> >>> R-help 
> >>> Subject: Re: [R] Question regarding reservoir volume and water level
> >>>
> >>> Aside from the fact that the original question might well be a class
> >>> exercise (or homework), the question is unanswerable given the data
> given
> >>> by
> >>> the original poster. One needs to know the dimensions of the reservoir,
> >>> above and below the current waterline. Are the sides, above and below
> the
> >>> waterline smooth? Is the region currently above the waterline that can
> >>> store
> >>> water a mirror image of the region below the waterline? Is the region
> above
> >>> the reservoir include a flood plane? Will the additional water go into
> the
> >>> flood plane?
> >>>
> >>> The lack of required detail in the question posed by the original
> poster
> >>> suggests that there are strong assumptions, assumptions that typically
> >>> would
> >>> be made in a class-room example or exercise.
> >>>
> >>> John
> >>>
> >>> John David Sorkin M.D., Ph.D.
> >>> Professor of Medicine, University of Maryland School of Medicine;
> >>> Associate Director for Biostatistics and Informatics, Baltimore VA
> Medical
> >>> Center Geriatrics Research, Education, and Clinical Center;
> >>> PI Biostatistics and Informatics Core, University of Maryland School of
> >>> Medicine Claude D. Pepper Older Americans Independence Center;
> >>> Senior Statistician University of Maryland Center for Vascular
> Research;
> >>>
> >>> Division of Gerontology and Paliative Care,
> >>> 10 North Greene Street
> >>> GRECC (BT/18/GR)
> >>> Baltimore, MD 21201-1524
> >>> Cell phone 

Re: [R] Question regarding reservoir volume and water level

2024-04-09 Thread David Stevens via R-help
s enough of the kind of
>>> depth-dimension data you describe albeit what may be a very irregular cross
>>> section to calculate for areas and thence volumes.
>>>
>>> If I read it correctly, this can be a very real-world problem worthy of a
>>> solution, such as in places like California where they had a tad more rain
>>> than usual and some reservoirs may overflow. Someone else provided what
>>> sounds like a mathematical algorithm but my guess is what is needed here is
>>> perhaps less analytic since there may be no trivial way to create formulas
>>> and take integrals and so on, but simply an approximate way to calculate
>>> incremental volumes for each horizontal "slice" and keep adding or
>>> subtracting them till you reach a target and then read off another variable
>>> at that point such as depth.
>>>
>>> Some care must be taken as water level has to be relative to something and
>>> many natural reservoirs have no unique bottom level. Some water may also be
>>> stored underground and to the side and pour in if the level lowers or can
>>> be
>>> used to escape if the level rises.
>>>
>>>
>>> -Original Message-
>>> From: R-help  On Behalf Of Sorkin, John
>>> Sent: Sunday, April 7, 2024 3:08 PM
>>> To: Rui Barradas ; javad bayat >>> ;
>>> R-help 
>>> Subject: Re: [R] Question regarding reservoir volume and water level
>>>
>>> Aside from the fact that the original question might well be a class
>>> exercise (or homework), the question is unanswerable given the data given
>>> by
>>> the original poster. One needs to know the dimensions of the reservoir,
>>> above and below the current waterline. Are the sides, above and below the
>>> waterline smooth? Is the region currently above the waterline that can
>>> store
>>> water a mirror image of the region below the waterline? Is the region above
>>> the reservoir include a flood plane? Will the additional water go into the
>>> flood plane?
>>>
>>> The lack of required detail in the question posed by the original poster
>>> suggests that there are strong assumptions, assumptions that typically
>>> would
>>> be made in a class-room example or exercise.
>>>
>>> John
>>>
>>> John David Sorkin M.D., Ph.D.
>>> Professor of Medicine, University of Maryland School of Medicine;
>>> Associate Director for Biostatistics and Informatics, Baltimore VA Medical
>>> Center Geriatrics Research, Education, and Clinical Center;
>>> PI Biostatistics and Informatics Core, University of Maryland School of
>>> Medicine Claude D. Pepper Older Americans Independence Center;
>>> Senior Statistician University of Maryland Center for Vascular Research;
>>>
>>> Division of Gerontology and Paliative Care,
>>> 10 North Greene Street
>>> GRECC (BT/18/GR)
>>> Baltimore, MD 21201-1524
>>> Cell phone 443-418-5382
>>>
>>>
>>>
>>>
>>> 
>>> From: R-help  on behalf of Rui Barradas
>>> 
>>> Sent: Sunday, April 7, 2024 10:53 AM
>>> To: javad bayat; R-help
>>> Subject: Re: [R] Question regarding reservoir volume and water level
>>>
>>> Às 13:27 de 07/04/2024, javad bayat escreveu:
>>>> Dear all;
>>>> I have a question about the water level of a reservoir, when the volume
>>>> changed or doubled.
>>>> There is a DEM file with the highest elevation 1267 m. The lowest
>>> elevation
>>>> is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
>>>> Now I want to know what would be the water level if the volume rises to
>>>> 1250 m? or what would be the water level if the volume doubled
>>> (14,000,000
>>>> m3)?
>>>>
>>>> Is there any way to write codes to do this in R?
>>>> I would be more than happy if anyone could help me.
>>>> Sincerely
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>> Hello,
>>>
>>> This is a simple rule of three.
>>> If you know the level l the argument doesn't need to be named but if you
>>> know the volume v then it must be named.
>>>
>>>
>>> water_level <- function(l, v, level = 1240, volume = 7e6) {
>>>if(missing(v)) {
>>>  volume * l 

Re: [R] Question regarding reservoir volume and water level

2024-04-09 Thread peter dalgaard
So, you know how to get volume for given water level. 

For the reverse problem, you get in trouble because of the nonlinearity 
inherent in the dependence of surface area on the level. 

I don't think there is a simple solution to this, save for mapping out the 
volume as a function of water level and solving equations for the water level 
using (say) uniroot(). Which may actually suffice for practical purposes.

For small changes, finding the derivative of the relation is easy: d(volume) = 
Area * d(level) and this can be used as an approximate relation as long as the 
Area remains nearly constant. 

However generic questions like doubling the volume are impossible to answer 
without knowledge of the reservoir shape. E.g. in a cylindrical reservoir 
halving the water level also halves the volume, but in a conical reservoir, 
halving the level leaves only 1/8 of the volume.

-pd



> On 8 Apr 2024, at 05:55 , javad bayat  wrote:
> 
> Dear all;
> Many thanks for your replies. This was not homework. I apologize.
> Let me explain more.
> There is a dam constructed in a valley with the highest elevation of 1255
> m. The area of its reservoir can be calculated by drawing a polygon around
> the water and it is known.
> I have the Digital Elevation Model (DEM) of the region (reservoir and its
> surrounding area). I have calculated the volume of the current reservoir
> (7e6 m3) using the following codes.
> library(raster)
> library(terra)
> library(exactextractr)
> library(dplyr)
> library(sf)
> # Calculate volume for polygon
> # Read the DEM raster file
> r <- rast("E:/...DEM.tif")
> # Read the polygon shapefile
> p <- st_read("E:/...Dam.shp")
> 
> r <- crop(r, extent(p))
> r <- mask(r, p)
> 
> # Extract the cells in each polygon and calculate the area of each cell
> x <- exact_extract(r, p, coverage_area = TRUE)
> # Extract polygon values as a dataframe
> x1 = as.data.frame(x[1])
> head(x1)
> x1 = na.omit(x1)
> # Calculate the height above the minimum elevation in the polygon
> x1$Height = max(x1[,1]) - x1[,1]
> # Calculate the volume of each cell
> x1$Vol = x1[,2] * x1[,3]
> sum(x1$Vol)
> x2 = x1[,c(1,2,4)]
> x2 = sort(x2,'value')
> head(x2)
> x3 <- aggregate(Vol ~ value, data = x2, FUN = sum)
> x4 <- aggregate(coverage_area ~ value, data = x2, FUN = sum)
> x5 = cbind(x3, Area = x4[,2])
> library(dplyr)
> x6 <- x5 %>%
>  mutate(V_sum = cumsum(Vol)) %>%
>  mutate(A_sum = cumsum(Area))
> plot(x6$value~x6$V_sum)
> 
> And I thought that it is possible to get the elevation for a specific
> volume by linear model between elevation and volume, as follow:
> 
> # Get a linear model between elevation and the volume
> lm1 <- lm(value ~ V_sum, data = x6)
> d <- data.frame(V_sum = 14e6)  #
> predict(lm1, newdata = d)
> 
> But it is not possible through the LM.
> Now I want to know what would be the water level in the reservoir if the
> reservoir volume doubled or we adding a known volume to it?
> Also what would be the volume if the water level increases to 1250 m?
> 
> I would be more than happy if you help me to do this.
> Sincerely
> 
> On Mon, Apr 8, 2024 at 12:23 AM  wrote:
> 
>> John,
>> 
>> Your reaction was what my original reaction was until I realized I had to
>> find out what a DEM file was and that contains enough of the kind of
>> depth-dimension data you describe albeit what may be a very irregular cross
>> section to calculate for areas and thence volumes.
>> 
>> If I read it correctly, this can be a very real-world problem worthy of a
>> solution, such as in places like California where they had a tad more rain
>> than usual and some reservoirs may overflow. Someone else provided what
>> sounds like a mathematical algorithm but my guess is what is needed here is
>> perhaps less analytic since there may be no trivial way to create formulas
>> and take integrals and so on, but simply an approximate way to calculate
>> incremental volumes for each horizontal "slice" and keep adding or
>> subtracting them till you reach a target and then read off another variable
>> at that point such as depth.
>> 
>> Some care must be taken as water level has to be relative to something and
>> many natural reservoirs have no unique bottom level. Some water may also be
>> stored underground and to the side and pour in if the level lowers or can
>> be
>> used to escape if the level rises.
>> 
>> 
>> -Original Message-
>> From: R-help  On Behalf Of Sorkin, John
>> Sent: Sunday, April 7, 2024 3:08 PM
>> To: Rui Barradas ; javad bayat >> ;
>> R-help 
>> Subject: Re: [R] Ques

Re: [R] Question regarding reservoir volume and water level

2024-04-07 Thread javad bayat
Dear all;
Many thanks for your replies. This was not homework. I apologize.
Let me explain more.
There is a dam constructed in a valley with the highest elevation of 1255
m. The area of its reservoir can be calculated by drawing a polygon around
the water and it is known.
I have the Digital Elevation Model (DEM) of the region (reservoir and its
surrounding area). I have calculated the volume of the current reservoir
(7e6 m3) using the following codes.
library(raster)
library(terra)
library(exactextractr)
library(dplyr)
library(sf)
# Calculate volume for polygon
# Read the DEM raster file
r <- rast("E:/...DEM.tif")
# Read the polygon shapefile
p <- st_read("E:/...Dam.shp")

r <- crop(r, extent(p))
r <- mask(r, p)

# Extract the cells in each polygon and calculate the area of each cell
x <- exact_extract(r, p, coverage_area = TRUE)
# Extract polygon values as a dataframe
x1 = as.data.frame(x[1])
head(x1)
x1 = na.omit(x1)
# Calculate the height above the minimum elevation in the polygon
x1$Height = max(x1[,1]) - x1[,1]
# Calculate the volume of each cell
x1$Vol = x1[,2] * x1[,3]
sum(x1$Vol)
x2 = x1[,c(1,2,4)]
x2 = sort(x2,'value')
head(x2)
x3 <- aggregate(Vol ~ value, data = x2, FUN = sum)
x4 <- aggregate(coverage_area ~ value, data = x2, FUN = sum)
x5 = cbind(x3, Area = x4[,2])
library(dplyr)
x6 <- x5 %>%
  mutate(V_sum = cumsum(Vol)) %>%
  mutate(A_sum = cumsum(Area))
plot(x6$value~x6$V_sum)

And I thought that it is possible to get the elevation for a specific
volume by linear model between elevation and volume, as follow:

# Get a linear model between elevation and the volume
lm1 <- lm(value ~ V_sum, data = x6)
d <- data.frame(V_sum = 14e6)  #
predict(lm1, newdata = d)

But it is not possible through the LM.
Now I want to know what would be the water level in the reservoir if the
reservoir volume doubled or we adding a known volume to it?
Also what would be the volume if the water level increases to 1250 m?

I would be more than happy if you help me to do this.
Sincerely

On Mon, Apr 8, 2024 at 12:23 AM  wrote:

> John,
>
> Your reaction was what my original reaction was until I realized I had to
> find out what a DEM file was and that contains enough of the kind of
> depth-dimension data you describe albeit what may be a very irregular cross
> section to calculate for areas and thence volumes.
>
> If I read it correctly, this can be a very real-world problem worthy of a
> solution, such as in places like California where they had a tad more rain
> than usual and some reservoirs may overflow. Someone else provided what
> sounds like a mathematical algorithm but my guess is what is needed here is
> perhaps less analytic since there may be no trivial way to create formulas
> and take integrals and so on, but simply an approximate way to calculate
> incremental volumes for each horizontal "slice" and keep adding or
> subtracting them till you reach a target and then read off another variable
> at that point such as depth.
>
> Some care must be taken as water level has to be relative to something and
> many natural reservoirs have no unique bottom level. Some water may also be
> stored underground and to the side and pour in if the level lowers or can
> be
> used to escape if the level rises.
>
>
> -Original Message-----
> From: R-help  On Behalf Of Sorkin, John
> Sent: Sunday, April 7, 2024 3:08 PM
> To: Rui Barradas ; javad bayat  >;
> R-help 
> Subject: Re: [R] Question regarding reservoir volume and water level
>
> Aside from the fact that the original question might well be a class
> exercise (or homework), the question is unanswerable given the data given
> by
> the original poster. One needs to know the dimensions of the reservoir,
> above and below the current waterline. Are the sides, above and below the
> waterline smooth? Is the region currently above the waterline that can
> store
> water a mirror image of the region below the waterline? Is the region above
> the reservoir include a flood plane? Will the additional water go into the
> flood plane?
>
> The lack of required detail in the question posed by the original poster
> suggests that there are strong assumptions, assumptions that typically
> would
> be made in a class-room example or exercise.
>
> John
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine, University of Maryland School of Medicine;
> Associate Director for Biostatistics and Informatics, Baltimore VA Medical
> Center Geriatrics Research, Education, and Clinical Center;
> PI Biostatistics and Informatics Core, University of Maryland School of
> Medicine Claude D. Pepper Older Americans Independence Center;
> Senior Statistician University of Maryland Center for Vascular Research;
>
> Division of Gerontology and Paliative Care,

Re: [R] Question regarding reservoir volume and water level

2024-04-07 Thread avi.e.gross
John,

Your reaction was what my original reaction was until I realized I had to
find out what a DEM file was and that contains enough of the kind of
depth-dimension data you describe albeit what may be a very irregular cross
section to calculate for areas and thence volumes.

If I read it correctly, this can be a very real-world problem worthy of a
solution, such as in places like California where they had a tad more rain
than usual and some reservoirs may overflow. Someone else provided what
sounds like a mathematical algorithm but my guess is what is needed here is
perhaps less analytic since there may be no trivial way to create formulas
and take integrals and so on, but simply an approximate way to calculate
incremental volumes for each horizontal "slice" and keep adding or
subtracting them till you reach a target and then read off another variable
at that point such as depth.

Some care must be taken as water level has to be relative to something and
many natural reservoirs have no unique bottom level. Some water may also be
stored underground and to the side and pour in if the level lowers or can be
used to escape if the level rises.


-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Sunday, April 7, 2024 3:08 PM
To: Rui Barradas ; javad bayat ;
R-help 
Subject: Re: [R] Question regarding reservoir volume and water level

Aside from the fact that the original question might well be a class
exercise (or homework), the question is unanswerable given the data given by
the original poster. One needs to know the dimensions of the reservoir,
above and below the current waterline. Are the sides, above and below the
waterline smooth? Is the region currently above the waterline that can store
water a mirror image of the region below the waterline? Is the region above
the reservoir include a flood plane? Will the additional water go into the
flood plane?

The lack of required detail in the question posed by the original poster
suggests that there are strong assumptions, assumptions that typically would
be made in a class-room example or exercise.

John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical
Center Geriatrics Research, Education, and Clinical Center;
PI Biostatistics and Informatics Core, University of Maryland School of
Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382





From: R-help  on behalf of Rui Barradas

Sent: Sunday, April 7, 2024 10:53 AM
To: javad bayat; R-help
Subject: Re: [R] Question regarding reservoir volume and water level

Às 13:27 de 07/04/2024, javad bayat escreveu:
> Dear all;
> I have a question about the water level of a reservoir, when the volume
> changed or doubled.
> There is a DEM file with the highest elevation 1267 m. The lowest
elevation
> is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
> Now I want to know what would be the water level if the volume rises to
> 1250 m? or what would be the water level if the volume doubled (14,000,000
> m3)?
>
> Is there any way to write codes to do this in R?
> I would be more than happy if anyone could help me.
> Sincerely
>
>
>
>
>
>
>
>
Hello,

This is a simple rule of three.
If you know the level l the argument doesn't need to be named but if you
know the volume v then it must be named.


water_level <- function(l, v, level = 1240, volume = 7e6) {
   if(missing(v)) {
 volume * l / level
   } else level * v / volume
}

lev <- 1250
vol <- 14e6

water_level(l = lev)
#> [1] 7056452
water_level(v = vol)
#> [1] 2480


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a
presença de vírus.
http://www.avg.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.

__
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] Question regarding reservoir volume and water level

2024-04-07 Thread avi.e.gross
Chris, since it does indeed look like homework, albeit a deeper looks
suggests it may not beI think we can safely answer the question:

>Is there any way to write codes to do this in R?

The answer is YES.

And before you ask, it can be done in Python, Java, C++, Javascript, BASIC,
FORTRAN and probably even COBOL and many forms of assembler.

And, it can be done even without a computer using your mind and pencil and
paper.

I have seen similar problems discussed using a search and wonder if that is
where you should go, or perhaps consult your textbook or class notes.

OK, levity aside, what is the real question? 

If you want help designing an algorithm that solves the problem, that is
outside the scope of this forum and may indeed count as helping someone for
free with their homework or other work.

If this was a place for tutoring help you might  be asked to try to show
some work and point out where one step seems stuck. You might get answers.

Perhaps a better question is to look at your problem and see what it might
need and ask if someone knows of one or more R packages that handle your
needs.

But as I read your message, assume people reading it have no idea what a DEM
file is. I looked it up and it a Digital Elevation Model. I then searched to
see if anyone discussed how to bring the contents of the file into an R
session and found some suggestions but note I have not, nor plan, to try any
of them.

Your request does not specify any particular shape for the containment of
existing water or what is above. If it is from a DES file, it would have
info about what likely may be quite irregular surfaces that vary with depth.
That is not as simple a calculation as asking what happens if the container
is a cylinder or cone . It depends on the data we cannot see. It sounds way
beyond basic R as it likely involves working with 3-D matrices or something
similar.

So I looked for packages you can search for too and I see one called,
appropriately, DEM. I see other packages called Terra and CopernicusDEM  and
whitebox and you may want to do searching and see if anything solves parts
of your problem.

And, of course, it may be something you find will do it easily for you if
someone has provided say a module for Python.

Good Luck.


-Original Message-
From: R-help  On Behalf Of Chris Ryan via
R-help
Sent: Sunday, April 7, 2024 9:26 AM
To: r-help@r-project.org; javad bayat ; R-help

Subject: Re: [R] Question regarding reservoir volume and water level

Homework?
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

On April 7, 2024 8:27:18 AM EDT, javad bayat  wrote:
>Dear all;
>I have a question about the water level of a reservoir, when the volume
>changed or doubled.
>There is a DEM file with the highest elevation 1267 m. The lowest elevation
>is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
>Now I want to know what would be the water level if the volume rises to
>1250 m? or what would be the water level if the volume doubled (14,000,000
>m3)?
>
>Is there any way to write codes to do this in R?
>I would be more than happy if anyone could help me.
>Sincerely
>
>
>
>
>
>
>
>

__
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] Question regarding reservoir volume and water level

2024-04-07 Thread Sorkin, John
Aside from the fact that the original question might well be a class exercise 
(or homework), the question is unanswerable given the data given by the 
original poster. One needs to know the dimensions of the reservoir, above and 
below the current waterline. Are the sides, above and below the waterline 
smooth? Is the region currently above the waterline that can store water a 
mirror image of the region below the waterline? Is the region above the 
reservoir include a flood plane? Will the additional water go into the flood 
plane?

The lack of required detail in the question posed by the original poster 
suggests that there are strong assumptions, assumptions that typically would be 
made in a class-room example or exercise.

John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical 
Center Geriatrics Research, Education, and Clinical Center;
PI Biostatistics and Informatics Core, University of Maryland School of 
Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382





From: R-help  on behalf of Rui Barradas 

Sent: Sunday, April 7, 2024 10:53 AM
To: javad bayat; R-help
Subject: Re: [R] Question regarding reservoir volume and water level

Às 13:27 de 07/04/2024, javad bayat escreveu:
> Dear all;
> I have a question about the water level of a reservoir, when the volume
> changed or doubled.
> There is a DEM file with the highest elevation 1267 m. The lowest elevation
> is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
> Now I want to know what would be the water level if the volume rises to
> 1250 m? or what would be the water level if the volume doubled (14,000,000
> m3)?
>
> Is there any way to write codes to do this in R?
> I would be more than happy if anyone could help me.
> Sincerely
>
>
>
>
>
>
>
>
Hello,

This is a simple rule of three.
If you know the level l the argument doesn't need to be named but if you
know the volume v then it must be named.


water_level <- function(l, v, level = 1240, volume = 7e6) {
   if(missing(v)) {
 volume * l / level
   } else level * v / volume
}

lev <- 1250
vol <- 14e6

water_level(l = lev)
#> [1] 7056452
water_level(v = vol)
#> [1] 2480


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
http://www.avg.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.

__
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] Question regarding reservoir volume and water level

2024-04-07 Thread Rui Barradas

Às 13:27 de 07/04/2024, javad bayat escreveu:

Dear all;
I have a question about the water level of a reservoir, when the volume
changed or doubled.
There is a DEM file with the highest elevation 1267 m. The lowest elevation
is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
Now I want to know what would be the water level if the volume rises to
1250 m? or what would be the water level if the volume doubled (14,000,000
m3)?

Is there any way to write codes to do this in R?
I would be more than happy if anyone could help me.
Sincerely









Hello,

This is a simple rule of three.
If you know the level l the argument doesn't need to be named but if you 
know the volume v then it must be named.



water_level <- function(l, v, level = 1240, volume = 7e6) {
  if(missing(v)) {
volume * l / level
  } else level * v / volume
}

lev <- 1250
vol <- 14e6

water_level(l = lev)
#> [1] 7056452
water_level(v = vol)
#> [1] 2480


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.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.


Re: [R] Question regarding reservoir volume and water level

2024-04-07 Thread Chris Ryan via R-help
Homework?
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

On April 7, 2024 8:27:18 AM EDT, javad bayat  wrote:
>Dear all;
>I have a question about the water level of a reservoir, when the volume
>changed or doubled.
>There is a DEM file with the highest elevation 1267 m. The lowest elevation
>is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
>Now I want to know what would be the water level if the volume rises to
>1250 m? or what would be the water level if the volume doubled (14,000,000
>m3)?
>
>Is there any way to write codes to do this in R?
>I would be more than happy if anyone could help me.
>Sincerely
>
>
>
>
>
>
>
>

__
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] Question about R software and output

2023-10-03 Thread Richard O'Keefe
R is open source software, available from CRAN servers, but also
packaged for various Linux distributions.  On this machine,
running Ubuntu, R was installed using the 'apt' package manager.

R is a complete programming language with built-in support for
reading and writing over the network.  Packages -- whether on CRAN
or elsewhere -- extend R with code written in a mixture of Fortran,
C, C++, and R.  Base R behaves itself, but a package loaded from
some random GitHub site could do anything.

Data processed by R need not have been anywhere near Excel or any
kind of spreadsheet.  I don't even *have* Excel on any of the machines
I run R on.  Most of the data I process is not in .csv or .xslx format.
R is able to read data in many formats as described in the
R Data Import/Export
manual, which is fairly brief.  If there is a data exchange format
with a significant community, chances are there's an R package that
can read and/or write it.  Indeed, it is even possible to extract
information from PDFs in R using the pdftools package.

It sounds as though your primary concern is data protection, and
there's good news and bad news.  The good news is that if you stick
with R and with packages from a trusted repository, you're safe.
The bad news is that a programming language that can do anything
can do ANYTHING, and you are not safe from a malicious programmer
in your own organisation sending data anywhere she wants to.
% R
> system("some possibly dangerous command goes here")
Of course, this doesn't let anyone do something they couldn't already
do *without* R.

And this gets us to the real bad news.  I think you are trying
to achieve security by a method that cannot work.  You're trying to
limit yourself to safe software.  But you ALSO need to plug ALL the
USB ports, ALL the Thunderbolt ports, snip the wires to the Wifi and
Bluetooth modules,If a system is capable enough to install
R (or anything else), it is insecure *without* R.  You have to limit
the internet connections that can possibly be established by ANY
program, and that means several levels of firewalls.  It also means
no "work from home".

On Wed, 4 Oct 2023 at 03:18, Ferguson Charity (CEMINFERGUSON) <
charity.eminfergu...@gstt.nhs.uk> wrote:

> To whom it may concern,
>
>
>
> My understanding is that the R software is downloaded from a CRAN network
> and data is imported into it using Microsoft Excel for example. Could I
> please just double check whether any data or results from the output is
> held on external servers or is it just held on local files on the computer?
>
>
>
> Many thanks,
>
>
>
> Charity
>
>
>
> *
>
> The information contained in this message and or attachments is intended
> only for the
> person or entity to which it is addressed and may contain confidential
> and/or
> privileged material. Unless otherwise specified, the opinions expressed
> herein do not
> necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
> any of its subsidiaries. The information contained in this e-mail may be
> subject to
> public disclosure under the Freedom of Information Act 2000. Unless the
> information
> is legally exempt from disclosure, the confidentiality of this e-mail and
> any replies
> cannot be guaranteed.
>
> Any review, retransmission,dissemination or other use of, or taking of any
> action in
> reliance upon, this information by persons or entities other than the
> intended
> recipient is prohibited. If you received this in error, please contact the
> sender
> and delete the material from any system and destroy any copies.
>
> We make every effort to keep our network free from viruses. However, it is
> your
> responsibility to ensure that this e-mail and any attachments are free of
> viruses as
> we can take no responsibility for any computer virus which might be
> transferred by
> way of this e-mail.
>
>
> *
>
> [[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] Question about R software and output

2023-10-03 Thread CALUM POLWART
Charity

There is OFTEN confusion what we mean when we say "R".

R is effectively a single bit of software with a ton of other bits of
software as optional extras.  You might think of some of those optional
extras like apps on a phone. You'd say you have a phone when you can open
the box and power it on. But you might add say "Spotify" app to it. That
will then be downloading the songs. And inevitably sending some data back
(I not do Spotify - no idea what - but it must have your identification and
what songs to play as a minimum).

R packages are like apps. They interact with the R core and do sometimes
amazing things. I think the majority do all that entirely on the machine
running R. BUT some may be using external services. There is for instance a
package that can interact with the Twitter API.  It would be impossible to
do that without sending as a minimum some login data and downloading data
back.  But you'd not normally send your entire research database to Twitter
during the login!

There will be SOME R packages that may be doing some odd stuff which might
need the dataset sent to the web. I can't think of any! Then there are
packages that could accidentally send data that you may or may not consider
sensitive. Say for instance you have a postcode list for every patient in
your research study. And you wanted to geocode that to get their location
as a long/lat... you can do that in an r package - which will have to send
the post code to get the answer. You haven't identified why you want the
postcode... but it is patient identifiable data...

That's R.

Add to that R Studio (or possibly other software solutions) - which is a
development environment which sits on top of R. It's often what people mean
by programming in R but it's effectively a glorified text editor. R Studio
desktop doesn't send data anywhere. Although it has database connectors
that could (but so can excel so if IG are flipping out feel free to remind
them of that!).

R Studio can work with git which is a version management system and can
upload code to a service like GitHub. You COULD upload data in that, or you
could chose not to.

And finally...

R Studio has a cloud version. It looks 98% the same as R Studio desktop.
Now called Posit.Cloud. That's a cloud service. While it may be secure etc
-- you are processing on their server not your PC.  And if this was your
question - it's a whole different set of answers!!


You may also want to Google NHSRcommunity where you might find help if
there are IG question to address as many of us will have wrestled with an
NHS IG team at some point.



On Tue, 3 Oct 2023, 17:26 Michael Dewey,  wrote:

> Dear Charity
>
> Since your organisation is a member of King's Health Partners you might
> like to ask colleagues in KCL for local support.
>
> Michael
>
> On 02/10/2023 08:48, Ferguson Charity (CEMINFERGUSON) wrote:
> > To whom it may concern,
> >
> >
> >
> > My understanding is that the R software is downloaded from a CRAN
> network and data is imported into it using Microsoft Excel for example.
> Could I please just double check whether any data or results from the
> output is held on external servers or is it just held on local files on the
> computer?
> >
> >
> >
> > Many thanks,
> >
> >
> >
> > Charity
> >
> >
> >
> *
> >
> > The information contained in this message and or attachments is intended
> only for the
> > person or entity to which it is addressed and may contain confidential
> and/or
> > privileged material. Unless otherwise specified, the opinions expressed
> herein do not
> > necessarily represent those of Guy's and St Thomas' NHS Foundation Trust
> or
> > any of its subsidiaries. The information contained in this e-mail may be
> subject to
> > public disclosure under the Freedom of Information Act 2000. Unless the
> information
> > is legally exempt from disclosure, the confidentiality of this e-mail
> and any replies
> > cannot be guaranteed.
> >
> > Any review, retransmission,dissemination or other use of, or taking of
> any action in
> > reliance upon, this information by persons or entities other than the
> intended
> > recipient is prohibited. If you received this in error, please contact
> the sender
> > and delete the material from any system and destroy any copies.
> >
> > We make every effort to keep our network free from viruses. However, it
> is your
> > responsibility to ensure that this e-mail and any attachments are free
> of viruses as
> > we can take no responsibility for any computer virus which might be
> transferred by
> > way of this e-mail.
> >
> >
> *
> >
> >   [[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 

Re: [R] Question about R software and output

2023-10-03 Thread Michael Dewey

Dear Charity

Since your organisation is a member of King's Health Partners you might 
like to ask colleagues in KCL for local support.


Michael

On 02/10/2023 08:48, Ferguson Charity (CEMINFERGUSON) wrote:

To whom it may concern,



My understanding is that the R software is downloaded from a CRAN network and 
data is imported into it using Microsoft Excel for example. Could I please just 
double check whether any data or results from the output is held on external 
servers or is it just held on local files on the computer?



Many thanks,



Charity


*

The information contained in this message and or attachments is intended only 
for the
person or entity to which it is addressed and may contain confidential and/or
privileged material. Unless otherwise specified, the opinions expressed herein 
do not
necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
any of its subsidiaries. The information contained in this e-mail may be 
subject to
public disclosure under the Freedom of Information Act 2000. Unless the 
information
is legally exempt from disclosure, the confidentiality of this e-mail and any 
replies
cannot be guaranteed.

Any review, retransmission,dissemination or other use of, or taking of any 
action in
reliance upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact the 
sender
and delete the material from any system and destroy any copies.

We make every effort to keep our network free from viruses. However, it is your
responsibility to ensure that this e-mail and any attachments are free of 
viruses as
we can take no responsibility for any computer virus which might be transferred 
by
way of this e-mail.

*

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



--
Michael

__
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] Question about R software and output

2023-10-03 Thread avi.e.gross
Charity,

As some of the answers I have seen show, your question is not clear.

You need to be clear on what you mean about R software and other concepts
before an answer makes sense.

The Base version of R may come on your computer already but likely has been
installed from some external source, or updated and the CRAN mirrors are one
such installation. As far as I know, it downloads the main R software as
well as packages considered important as part of that distribution and from
then on, you can disconnect your computer from any network and it will work
fine for any programs that operate only locally. 

Of course any program you run that wishes to access external resources can
do so. In particular, it is quite common for you at the prompt, or within an
R program, to ask for a package stored externally to be placed within your
computer but once done, it remains there until and unless you want to get a
newer version or something.

There are packages that include data within themselves and may well be some
that dynamically go out and get info from somewhere but I know of no simple
way to find out other than reading the source code or seeing what happens if
you disconnect from the internet.

Your mention of EXCEL also needs clarification. EXCEL has absolutely nothing
to do with R. It is an unrelated product and you do not need to have it
installed to run R and vice versa. That does not mean your program cannot
interact with EXCEL or the files it makes, just that it is not part of base
R. R does allow importing data (locally or not) in lots of formats including
some that EXCEL can save data in. But generally, internal to R there are
storage methods such as the data.frame that hold data and manipulate it and
a typical R program may read in some data from files like .CSV that can be
saved from EXCEL or many other sources or with the proper packages, you can
read directly from more native EXCEL formats such as XLSX files. And, you
can write out results in many ways using packages that include those
formats.

Once data has been received, I know of no way in R that tags it with the
source of the data as being internal or external. Often the fact that
something is external is well hidden as many R packages have ways to access
external data as if it were local.

Perhaps you can explain more clearly what your concerns are. But note R is
not atypical among computer languages and many others might share the same
issues that concern you. 

Avi

-Original Message-
From: R-help  On Behalf Of Ferguson Charity
(CEMINFERGUSON)
Sent: Monday, October 2, 2023 3:49 AM
To: r-help@r-project.org
Subject: [R] Question about R software and output

To whom it may concern,



My understanding is that the R software is downloaded from a CRAN network
and data is imported into it using Microsoft Excel for example. Could I
please just double check whether any data or results from the output is held
on external servers or is it just held on local files on the computer?



Many thanks,



Charity



*

The information contained in this message and or attachments is intended
only for the
person or entity to which it is addressed and may contain confidential
and/or 
privileged material. Unless otherwise specified, the opinions expressed
herein do not
necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
any of its subsidiaries. The information contained in this e-mail may be
subject to 
public disclosure under the Freedom of Information Act 2000. Unless the
information 
is legally exempt from disclosure, the confidentiality of this e-mail and
any replies
cannot be guaranteed.

Any review, retransmission,dissemination or other use of, or taking of any
action in 
reliance upon, this information by persons or entities other than the
intended
recipient is prohibited. If you received this in error, please contact the
sender
and delete the material from any system and destroy any copies.

We make every effort to keep our network free from viruses. However, it is
your
responsibility to ensure that this e-mail and any attachments are free of
viruses as
we can take no responsibility for any computer virus which might be
transferred by 
way of this e-mail.


*

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

Re: [R] Question about R software and output

2023-10-03 Thread Ebert,Timothy Aaron
I would answer "local files only," but with sufficient motive it is possible 
for some people to abuse a system. Base R does not download any of your data. 
The packages that I know about do not download data. You can add a layer of 
protection by only downloading directly from the source rather than through 
some third party. If you are skilled, you should be able to read through the 
source code to check for statements that would write your data to an external 
source.

Another viewpoint: R is an approved software for the University of Florida. The 
University is very aware of regulations and risks associated with personally 
identifiable information. Downloading to an external location would be a 
security risk that the University would not allow. That said, the university 
provides students and employees  an approved link for downloading the software. 
It is designed to help people avoid third party sites and associated risks.

If this is an issue with personally identifiable information, then you should 
check with your employer if R is an approved software.


-Original Message-
From: R-help  On Behalf Of Ferguson Charity 
(CEMINFERGUSON)
Sent: Monday, October 2, 2023 3:49 AM
To: r-help@r-project.org
Subject: [R] Question about R software and output

[External Email]

To whom it may concern,



My understanding is that the R software is downloaded from a CRAN network and 
data is imported into it using Microsoft Excel for example. Could I please just 
double check whether any data or results from the output is held on external 
servers or is it just held on local files on the computer?



Many thanks,



Charity


*

The information contained in this message and or attachments is intended only 
for the person or entity to which it is addressed and may contain confidential 
and/or privileged material. Unless otherwise specified, the opinions expressed 
herein do not necessarily represent those of Guy's and St Thomas' NHS 
Foundation Trust or any of its subsidiaries. The information contained in this 
e-mail may be subject to public disclosure under the Freedom of Information Act 
2000. Unless the information is legally exempt from disclosure, the 
confidentiality of this e-mail and any replies cannot be guaranteed.

Any review, retransmission,dissemination or other use of, or taking of any 
action in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any system and destroy any copies.

We make every effort to keep our network free from viruses. However, it is your 
responsibility to ensure that this e-mail and any attachments are free of 
viruses as we can take no responsibility for any computer virus which might be 
transferred by way of this e-mail.

*

[[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] Question about R software and output

2023-10-03 Thread Bert Gunter
I am pretty sure you'll get more replies than mine, so just consider this
as part of the story.

Your understanding is confused/flawed.

1. R can be downloaded from hundreds/thousands of software repositories,
not just CRAN.

2. R can read/upload data in hundreds of different formats, not just
Excel's. R makes no use of Excel to read external files (I wasn't clear
what you meant here).

3. As Ben said, it is certainly possible that some R packages -- optional
add-ons extending R capabilities ---  communicate with and store data or
results on external servers. R,  itself, can run locally and can store
results either locally or externally. Like most software, it can also be
integrated as part of the infrastructure on a server for web applications.

If you have a specific question not addressed by these various replies, ask
it. You will most likely get a useful reply.

Cheers,
Bert

On Tue, Oct 3, 2023 at 7:17 AM Ferguson Charity (CEMINFERGUSON) <
charity.eminfergu...@gstt.nhs.uk> wrote:

> To whom it may concern,
>
>
>
> My understanding is that the R software is downloaded from a CRAN network
> and data is imported into it using Microsoft Excel for example. Could I
> please just double check whether any data or results from the output is
> held on external servers or is it just held on local files on the computer?
>
>
>
> Many thanks,
>
>
>
> Charity
>
>
>
> *
>
> The information contained in this message and or attachments is intended
> only for the
> person or entity to which it is addressed and may contain confidential
> and/or
> privileged material. Unless otherwise specified, the opinions expressed
> herein do not
> necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
> any of its subsidiaries. The information contained in this e-mail may be
> subject to
> public disclosure under the Freedom of Information Act 2000. Unless the
> information
> is legally exempt from disclosure, the confidentiality of this e-mail and
> any replies
> cannot be guaranteed.
>
> Any review, retransmission,dissemination or other use of, or taking of any
> action in
> reliance upon, this information by persons or entities other than the
> intended
> recipient is prohibited. If you received this in error, please contact the
> sender
> and delete the material from any system and destroy any copies.
>
> We make every effort to keep our network free from viruses. However, it is
> your
> responsibility to ensure that this e-mail and any attachments are free of
> viruses as
> we can take no responsibility for any computer virus which might be
> transferred by
> way of this e-mail.
>
>
> *
>
> [[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] Question about R software and output

2023-10-03 Thread Ivan Krylov
В Mon, 2 Oct 2023 07:48:36 +
"Ferguson Charity (CEMINFERGUSON)" 
пишет:

> My understanding is that the R software is downloaded from a CRAN
> network

This is mostly true. (There are other ways of installing R, but it is
most frequently downloaded from a CRAN mirror.)

> and data is imported into it using Microsoft Excel for example.

This is not exactly the case.

It is possible to prepare data using Microsoft Excel and store it in
the Microsoft Excel format, but the actual import process is performed
either using base R functions (e.g. read.csv(), which is built into R),
or using third-party packages running inside R (e.g. "openxlsx", which
is available on CRAN) that implement the functions necessary to
transform Excel format into R data structures.

It is also possible to prepare data using other software, or type it
manually into R, or store it only in R's native data format (using
the saveRDS() or save() functions).

> Could I please just double check whether any data or results from the
> output is held on external servers or is it just held on local files
> on the computer?

As long as you're running R on your own computer, it should keep the
data locally. The words of a J. Random Hacker from the Internet don't
carry much weight with government agencies (as they shouldn't), but the
source code of R is open to audits. Additionally, there are some
guidance documents at .

Note that this only covers R itself and not any third-party software
packages that you could be using together with R. (You could also be
connecting to an RStudio server or running an instance of webR in your
web browser, in which case your data is subject to the privacy policy
of the server administrators.) For example, the "googleCloudRunner"
package available on CRAN is designed for the purpose of running code
on Google infrastructure and will send the data there if asked to.

CRAN packages are required never to do anything that might be regarded
as antisocial ,
but a dedicated attacker may be able to slip something past the
reviewers anyway.

Since your e-mail address contains nhs.uk, the
 website could help you find the
information you need.

-- 
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] Question about R software and output

2023-10-03 Thread Ben Bolker
   It's conceivable that functions in a contributed package would 
communicate/transmit or receive data from a remote server, but base R 
does nothing like that (unless you explicitly ask it to).


  cheers
   Ben Bolker

On 2023-10-02 3:48 a.m., Ferguson Charity (CEMINFERGUSON) wrote:

To whom it may concern,



My understanding is that the R software is downloaded from a CRAN network and 
data is imported into it using Microsoft Excel for example. Could I please just 
double check whether any data or results from the output is held on external 
servers or is it just held on local files on the computer?



Many thanks,



Charity


*

The information contained in this message and or attachments is intended only 
for the
person or entity to which it is addressed and may contain confidential and/or
privileged material. Unless otherwise specified, the opinions expressed herein 
do not
necessarily represent those of Guy's and St Thomas' NHS Foundation Trust or
any of its subsidiaries. The information contained in this e-mail may be 
subject to
public disclosure under the Freedom of Information Act 2000. Unless the 
information
is legally exempt from disclosure, the confidentiality of this e-mail and any 
replies
cannot be guaranteed.

Any review, retransmission,dissemination or other use of, or taking of any 
action in
reliance upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact the 
sender
and delete the material from any system and destroy any copies.

We make every effort to keep our network free from viruses. However, it is your
responsibility to ensure that this e-mail and any attachments are free of 
viruses as
we can take no responsibility for any computer virus which might be transferred 
by
way of this e-mail.

*

[[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] question about update()

2023-05-04 Thread Adelchi Azzalini via R-help
Hi, Berwin, good to hear from you, and thanks for the detailed comments and 
suggestion.

Actually, my current experimental code works in the way that you suggest, 
calling directly lm.fit and glm.fit.  What I am trying to develop is an 
“improved” version of the code for distribution to other people. Hence I wanted 
to streamline the code, in particular avoiding branches for each fitting 
procedure (lm.fit, glm.fit and possibly more).  But I am now considering to 
drop the idea of the “improved” version, and stick to the direct calls to the 
fitting functions.

Duncan, thanks for your additional comments. It is true that my original 
message presented a very simplified picture of the problem, possibly 
over-simplistic.  If I present the problem in the full version of the code, it 
would look quite long and messy. If I manage to construct a reasonably 
simplified version of the code, I shall post the question again.

Best wishes,

Adelchi
 

> On 4 May 2023, at 11:44, Berwin A Turlach  wrote:
> 
> G'day Adelchi,
> 
> hope all is well with you.
> 
> On Thu, 4 May 2023 10:34:00 +0200
> Adelchi Azzalini via R-help  wrote:
> 
>> Thanks, Duncan. What you indicate is surely the ideal route.
>> Unfortunately, in my case this is not feasible, because the
>> construction of xf and the update call are within an iterative
>> procedure where xf is changed at each iteration, so that the steps 
>> 
>> obj$data <- cbind(obj$data, xf=xf)
>> new.obj <- update(obj, . ~ . + xf)
>> 
>> must be repeated hundreds of times, each with a different xf.
> 
> If memory serves correctly, update() takes the object that is passed to
> it, looks at what the call was that created that object, modifies that
> call according to the additional arguments, and finally executes the
> modified call.
> 
> So there is a lot of manipulations going on in update().  In particular
> it would result each time in a call to lm(), glm() or whatever call was
> used to create the object.  Inside any of these modelling functions a
> lot of symbolic manipulations/calculations are needed too (parsing the
> formula, creating the design matrix and response vector from the parsed
> formula and data frame, checking if weights are used ).
> 
> If you do the same calculation essentially over and over again, just
> with minor modification, all these symbolic manipulations are just time
> consuming.
> 
> IMHO, you will be better off to bypass update() and just use lm.fit()
> (for which lm() is a nice front-end) and glm.fit() (for which glm() is a
> nice front-end), or whatever routine does the grunt work of fitting the
> model to the data in your application (hopefully, the package creator
> used a set up of XXX.fit() to fit the model, called by XXX() that does
> all the fancy formula handling).
> 
> Cheers,
> 
> Berwin
> 

__
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] question about update()

2023-05-04 Thread Berwin A Turlach
G'day Adelchi,

hope all is well with you.

On Thu, 4 May 2023 10:34:00 +0200
Adelchi Azzalini via R-help  wrote:

> Thanks, Duncan. What you indicate is surely the ideal route.
> Unfortunately, in my case this is not feasible, because the
> construction of xf and the update call are within an iterative
> procedure where xf is changed at each iteration, so that the steps 
> 
> obj$data <- cbind(obj$data, xf=xf)
> new.obj <- update(obj, . ~ . + xf)
>  
> must be repeated hundreds of times, each with a different xf.

If memory serves correctly, update() takes the object that is passed to
it, looks at what the call was that created that object, modifies that
call according to the additional arguments, and finally executes the
modified call.

So there is a lot of manipulations going on in update().  In particular
it would result each time in a call to lm(), glm() or whatever call was
used to create the object.  Inside any of these modelling functions a
lot of symbolic manipulations/calculations are needed too (parsing the
formula, creating the design matrix and response vector from the parsed
formula and data frame, checking if weights are used ).

If you do the same calculation essentially over and over again, just
with minor modification, all these symbolic manipulations are just time
consuming.

IMHO, you will be better off to bypass update() and just use lm.fit()
(for which lm() is a nice front-end) and glm.fit() (for which glm() is a
nice front-end), or whatever routine does the grunt work of fitting the
model to the data in your application (hopefully, the package creator
used a set up of XXX.fit() to fit the model, called by XXX() that does
all the fancy formula handling).

Cheers,

Berwin

__
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] question about update()

2023-05-04 Thread Duncan Murdoch

On 04/05/2023 4:34 a.m., Adelchi Azzalini wrote:




On 4 May 2023, at 10:26, Duncan Murdoch  wrote:

On 04/05/2023 4:05 a.m., Adelchi Azzalini via R-help wrote:

Hi. There must be something about the use of update() which I do not grasp,
as the next exercise indicates.
Suppose that obj is an object returned by a call to lm() or glm().
Next, a new variable xf is constructed using the same dataframe used
for producing obj. Then
obj$data <- cbind(obj$data, xf=xf)
new.obj <- update(obj, . ~ . + xf)
generates
Error in eval(predvars, data, env) : object 'xf' not found
Could somebody explain what I got wrong, and how to fix it?


I don't think you should be modifying the obj$data element:  as far as I can 
see, it's not used during the update, which will just re-evaluate the original 
call to glm().  So you should modify the dataframe that you passed in when 
creating obj.



Thanks, Duncan. What you indicate is surely the ideal route. Unfortunately, in 
my case this is not feasible, because the construction of xf and the update 
call are within an iterative procedure where xf is changed at each iteration, 
so that the steps

obj$data <- cbind(obj$data, xf=xf)
new.obj <- update(obj, . ~ . + xf)
  
must be repeated hundreds of times, each with a different xf.


Sorry, that doesn't make sense.

You didn't show us complete code, but presumably it's preceded by 
something like this:


  obj <- glm( ..., data = somedata)

So change your modification to this:

  somedata$xf <- xf

That can be done hundreds of times.  This will need to be more elaborate 
if the function doing the iteration has a copy of obj but doesn't have a 
copy of somedata, but there are lots of ways to resolve that.  Without 
seeing complete code, I can't recommend which one to use.


Duncan Murdoch

__
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] question about update()

2023-05-04 Thread Adelchi Azzalini via R-help



> On 4 May 2023, at 10:26, Duncan Murdoch  wrote:
> 
> On 04/05/2023 4:05 a.m., Adelchi Azzalini via R-help wrote:
>> Hi. There must be something about the use of update() which I do not grasp,
>> as the next exercise indicates.
>> Suppose that obj is an object returned by a call to lm() or glm().
>> Next, a new variable xf is constructed using the same dataframe used
>> for producing obj. Then
>> obj$data <- cbind(obj$data, xf=xf)
>> new.obj <- update(obj, . ~ . + xf)
>> generates
>> Error in eval(predvars, data, env) : object 'xf' not found
>> Could somebody explain what I got wrong, and how to fix it?
> 
> I don't think you should be modifying the obj$data element:  as far as I can 
> see, it's not used during the update, which will just re-evaluate the 
> original call to glm().  So you should modify the dataframe that you passed 
> in when creating obj.
> 

Thanks, Duncan. What you indicate is surely the ideal route. Unfortunately, in 
my case this is not feasible, because the construction of xf and the update 
call are within an iterative procedure where xf is changed at each iteration, 
so that the steps 

obj$data <- cbind(obj$data, xf=xf)
new.obj <- update(obj, . ~ . + xf)
 
must be repeated hundreds of times, each with a different xf.

Adelchi

__
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] Question about implementing statistical test in R

2023-05-03 Thread Ebert,Timothy Aaron
Start with defining your dependent variable and independent variable(s). As an 
equation like y equals some function of x, the y is the dependent variable. It 
is often continuous, but does not have to be.

If your continuous variable is the dependent variable and you have one 
categorical independent variable then the ANOVA would be a general comparison 
tests determining if there are differences. This can be further broken down by 
a multiple comparison test. The Tukey test is commonly used if you assume 
normal distributions. The Kruskal-Wallis test would be the start of a 
non-parametric approach.


Tim

-Original Message-
From: R-help  On Behalf Of RIDDHI BABEL via R-help
Sent: Wednesday, May 3, 2023 11:42 AM
To: r-help@r-project.org
Subject: [R] Question about implementing statistical test in R

[External Email]

Hi,

I am a new user and have a stats question that I need help implementing in R.

I have 4 groups and I want to assess whether there is a statistical difference 
between these groups at baseline first in a global comparison test and then a 
pairwise comparison test.

There are about 2 continuous variables and 10 categorical variables

For the group wise comparison for continuous variables-I am using the Mann 
Whitney test

For the categorical variables-I am using either chi square or Fisher exact test 
for both global comparison and pairwise comparison.

What packages should I use to implement this in R? Is there any example code 
that I use? I was thinking tbl_summary but don't think that's the right one.

Would really appreciate any help with this!

Thank you!

[[alternative HTML version deleted]]

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

__
R-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] Question about italics in legendg() - plotrix

2023-02-14 Thread Jim Lemon
Hi Nicole,
plotrix is intended to be modular, that is, it builds plots step by step.
This makes it easier to understand code that you haven't written or haven't
seen for a while. Here is an example showing how to change the font using
par():

library(plotrix)
plot(0,type="n",xlim=c(0,1),ylim=c(-1,0))
par(font=3)
legendg(0.115,-0.055,legend=c("Pan troglodytes","Macaca mulatta",
 "Saguinus oedipus","Lemur catta","Galago senegalensis"),
pch=list(c(15,0),c(16,1),c(17,2),c(18,5),c(19,10)),
 col=list(c("royalblue","skyblue1"),
 c("chocolate","gold"),c("deeppink","lightpink"),
 c("black","grey"),c("forestgreen","lightgreen")))
par(font=1)
legendg(0.45,-0.7,legend=c("Pan troglodytes","Macaca mulatta",
 "Saguinus oedipus","Lemur catta","Galago senegalensis"),
pch=list(c(15,0),c(16,1),c(17,2),c(18,5),c(19,10)),
 col=list(c("royalblue","skyblue1"),
 c("chocolate","gold"),c("deeppink","lightpink"),
 c("black","grey"),c("forestgreen","lightgreen")))

There are 4 or 5 preset font types built into R (normal, bold, italic,
bolditalic and maybe symbol). You can also change the base font using the
family= argument to par(), but that's quite a bit more complicated.

Jim

[[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] question

2023-01-31 Thread Carolyn J Miller via R-help
Very true,

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology



From: Bert Gunter 
Sent: Tuesday, January 31, 2023 10:46 AM
To: Carolyn J Miller 
Cc: Boris Steipe ; r-help@r-project.org 

Subject: Re: [R] question

"The combination of some data and an aching desire for an answer does not 
ensure that a reasonable answer can be extracted from a given body of data."

John Tukey

Cheers,
Bert

On Tue, Jan 31, 2023 at 7:44 AM Carolyn J Miller via R-help 
mailto:r-help@r-project.org>> wrote:
Hi Boris,

It's hair cortisol so it shouldn't have an effect. My study species are 
ungulates, which retain their coat through the winter into the spring shedding 
out around April/May so in theory these two sampling periods should provide the 
same results as hair cort provides an average of accumulated cort levels 
released into the hair over that growth period until they shed out. Of course 
the individuals that had hair collected in March instead of December have had 
longer to incorporate more cort levels into the hair collected in comparison to 
their conspecifics captured in December.

I had a repeated measures approach to this previously but due to missing data 
from uneven captures the model gets angry since there's only 2 levels of 
replication and many are not repeated at all. We're considering dividing up the 
dataset by season to eliminate the need for repeated measures. I've had it 
suggested that we should use the single measure of cort (which is what most 
individuals have) in both rows (March and December) based on this logic, and 
then just run the models as separate seasons.

I ran the t-test between the march and december cort samples and they are not 
representing the same information.

The joys of data analysis!

Thanks for your feedback,

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology



From: Boris Steipe mailto:boris.ste...@utoronto.ca>>
Sent: Tuesday, January 31, 2023 10:16 AM
To: Carolyn J Miller mailto:cjmil...@syr.edu>>
Cc: r-help@r-project.org<mailto:r-help@r-project.org> 
mailto:r-help@r-project.org>>
Subject: Re: [R] question

Perhaps, rather than looking to compress your observations into a single 
number, you could simply visualize what you observed: use a boxplot to show the 
March and December observations, and overlay the three animals that were 
recaptured as individual points, connected with a line.

Feel free to ask again if you are not sure how to do that.

Cheers,
Boris


PS. Lets hope that the capture did not stress them to the degree that their 
cortisol is elevated at recapture :-)




> On 2023-01-31, at 09:52, Carolyn J Miller via R-help 
> mailto:r-help@r-project.org>> wrote:
>
> Thank you!
>
> Carolyn J. Miller
> M.S. Student, Ecology
> SUNY-ESF, Environmental Biology
>
>
> 
> From: Ebert,Timothy Aaron mailto:teb...@ufl.edu>>
> Sent: Tuesday, January 31, 2023 9:50 AM
> To: Carolyn J Miller mailto:cjmil...@syr.edu>>; PIKAL Petr 
> mailto:petr.pi...@precheza.cz>>; 
> r-help@r-project.org<mailto:r-help@r-project.org> 
> mailto:r-help@r-project.org>>
> Subject: RE: question
>
>
> As indicated here: 
> https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/
>
> The cor() function needs two vectors. The only way that works is if you are 
> looking at the correlation between �Month� and �Cort.�
>
> If you interested in the correlation between  Cort measured in month 3 versus 
> month 12 then you are not getting the right answer.
>
>
>
> Animal ID is not relevant in this analysis (as presented).
>
> The animals that have been measured twice would be a repeated measures 
> analysis (by default) unless there is some reason to suspect that the six 
> month lag is too long for an outcome in month 3 to influence the outcome in 
> month 12. The remaining animals are an experimental design for avoiding a 
> repeated measures analysis. This would be something like a t-test to 
> determine if the animals in Month 3 are different than Month 12.
>
>
>
> Tim
>
>
>
> From: Carolyn J Miller mailto:cjmil...@syr.edu>>
> Sent: Tuesday, January 31, 2023 9:30 AM
> To: PIKAL Petr mailto:petr.pi...@precheza.cz>>; 
> r-help@r-project.org<mailto:r-help@r-project.org>; Ebert,Timothy Aaron 
> mailto:teb...@ufl.edu>>
> Subject: Re: question
>
>
>
> [External Email]
>
> Hi Timothy,
>
>
>
> Here's some example data that might help to demonstrate how the data 
> currently looks.
>
>
>
> AnimalID
>
> Month
>
> Cort
>
> 1
>
> 12
>
> 0.00591
>
> 1
>
> 3
>
> 

Re: [R] question

2023-01-31 Thread Bert Gunter
"The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data."

John Tukey

Cheers,
Bert

On Tue, Jan 31, 2023 at 7:44 AM Carolyn J Miller via R-help <
r-help@r-project.org> wrote:

> Hi Boris,
>
> It's hair cortisol so it shouldn't have an effect. My study species are
> ungulates, which retain their coat through the winter into the spring
> shedding out around April/May so in theory these two sampling periods
> should provide the same results as hair cort provides an average of
> accumulated cort levels released into the hair over that growth period
> until they shed out. Of course the individuals that had hair collected in
> March instead of December have had longer to incorporate more cort levels
> into the hair collected in comparison to their conspecifics captured in
> December.
>
> I had a repeated measures approach to this previously but due to missing
> data from uneven captures the model gets angry since there's only 2 levels
> of replication and many are not repeated at all. We're considering dividing
> up the dataset by season to eliminate the need for repeated measures. I've
> had it suggested that we should use the single measure of cort (which is
> what most individuals have) in both rows (March and December) based on this
> logic, and then just run the models as separate seasons.
>
> I ran the t-test between the march and december cort samples and they are
> not representing the same information.
>
> The joys of data analysis!
>
> Thanks for your feedback,
>
> Carolyn J. Miller
> M.S. Student, Ecology
> SUNY-ESF, Environmental Biology
>
>
> 
> From: Boris Steipe 
> Sent: Tuesday, January 31, 2023 10:16 AM
> To: Carolyn J Miller 
> Cc: r-help@r-project.org 
> Subject: Re: [R] question
>
> Perhaps, rather than looking to compress your observations into a single
> number, you could simply visualize what you observed: use a boxplot to show
> the March and December observations, and overlay the three animals that
> were recaptured as individual points, connected with a line.
>
> Feel free to ask again if you are not sure how to do that.
>
> Cheers,
> Boris
>
>
> PS. Lets hope that the capture did not stress them to the degree that
> their cortisol is elevated at recapture :-)
>
>
>
>
> > On 2023-01-31, at 09:52, Carolyn J Miller via R-help <
> r-help@r-project.org> wrote:
> >
> > Thank you!
> >
> > Carolyn J. Miller
> > M.S. Student, Ecology
> > SUNY-ESF, Environmental Biology
> >
> >
> > 
> > From: Ebert,Timothy Aaron 
> > Sent: Tuesday, January 31, 2023 9:50 AM
> > To: Carolyn J Miller ; PIKAL Petr <
> petr.pi...@precheza.cz>; r-help@r-project.org 
> > Subject: RE: question
> >
> >
> > As indicated here:
> https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/
> >
> > The cor() function needs two vectors. The only way that works is if you
> are looking at the correlation between �Month� and �Cort.�
> >
> > If you interested in the correlation between  Cort measured in month 3
> versus month 12 then you are not getting the right answer.
> >
> >
> >
> > Animal ID is not relevant in this analysis (as presented).
> >
> > The animals that have been measured twice would be a repeated measures
> analysis (by default) unless there is some reason to suspect that the six
> month lag is too long for an outcome in month 3 to influence the outcome in
> month 12. The remaining animals are an experimental design for avoiding a
> repeated measures analysis. This would be something like a t-test to
> determine if the animals in Month 3 are different than Month 12.
> >
> >
> >
> > Tim
> >
> >
> >
> > From: Carolyn J Miller 
> > Sent: Tuesday, January 31, 2023 9:30 AM
> > To: PIKAL Petr ; r-help@r-project.org;
> Ebert,Timothy Aaron 
> > Subject: Re: question
> >
> >
> >
> > [External Email]
> >
> > Hi Timothy,
> >
> >
> >
> > Here's some example data that might help to demonstrate how the data
> currently looks.
> >
> >
> >
> > AnimalID
> >
> > Month
> >
> > Cort
> >
> > 1
> >
> > 12
> >
> > 0.00591
> >
> > 1
> >
> > 3
> >
> > 0.00583
> >
> > 2
> >
> > 3
> >
> > 0.005722
> >
> > 3
> >
> > 3
> >
>

Re: [R] question

2023-01-31 Thread Carolyn J Miller via R-help
Hi Boris,

It's hair cortisol so it shouldn't have an effect. My study species are 
ungulates, which retain their coat through the winter into the spring shedding 
out around April/May so in theory these two sampling periods should provide the 
same results as hair cort provides an average of accumulated cort levels 
released into the hair over that growth period until they shed out. Of course 
the individuals that had hair collected in March instead of December have had 
longer to incorporate more cort levels into the hair collected in comparison to 
their conspecifics captured in December.

I had a repeated measures approach to this previously but due to missing data 
from uneven captures the model gets angry since there's only 2 levels of 
replication and many are not repeated at all. We're considering dividing up the 
dataset by season to eliminate the need for repeated measures. I've had it 
suggested that we should use the single measure of cort (which is what most 
individuals have) in both rows (March and December) based on this logic, and 
then just run the models as separate seasons.

I ran the t-test between the march and december cort samples and they are not 
representing the same information.

The joys of data analysis!

Thanks for your feedback,

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology



From: Boris Steipe 
Sent: Tuesday, January 31, 2023 10:16 AM
To: Carolyn J Miller 
Cc: r-help@r-project.org 
Subject: Re: [R] question

Perhaps, rather than looking to compress your observations into a single 
number, you could simply visualize what you observed: use a boxplot to show the 
March and December observations, and overlay the three animals that were 
recaptured as individual points, connected with a line.

Feel free to ask again if you are not sure how to do that.

Cheers,
Boris


PS. Lets hope that the capture did not stress them to the degree that their 
cortisol is elevated at recapture :-)




> On 2023-01-31, at 09:52, Carolyn J Miller via R-help  
> wrote:
>
> Thank you!
>
> Carolyn J. Miller
> M.S. Student, Ecology
> SUNY-ESF, Environmental Biology
>
>
> 
> From: Ebert,Timothy Aaron 
> Sent: Tuesday, January 31, 2023 9:50 AM
> To: Carolyn J Miller ; PIKAL Petr ; 
> r-help@r-project.org 
> Subject: RE: question
>
>
> As indicated here: 
> https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/
>
> The cor() function needs two vectors. The only way that works is if you are 
> looking at the correlation between �Month� and �Cort.�
>
> If you interested in the correlation between  Cort measured in month 3 versus 
> month 12 then you are not getting the right answer.
>
>
>
> Animal ID is not relevant in this analysis (as presented).
>
> The animals that have been measured twice would be a repeated measures 
> analysis (by default) unless there is some reason to suspect that the six 
> month lag is too long for an outcome in month 3 to influence the outcome in 
> month 12. The remaining animals are an experimental design for avoiding a 
> repeated measures analysis. This would be something like a t-test to 
> determine if the animals in Month 3 are different than Month 12.
>
>
>
> Tim
>
>
>
> From: Carolyn J Miller 
> Sent: Tuesday, January 31, 2023 9:30 AM
> To: PIKAL Petr ; r-help@r-project.org; Ebert,Timothy 
> Aaron 
> Subject: Re: question
>
>
>
> [External Email]
>
> Hi Timothy,
>
>
>
> Here's some example data that might help to demonstrate how the data 
> currently looks.
>
>
>
> AnimalID
>
> Month
>
> Cort
>
> 1
>
> 12
>
> 0.00591
>
> 1
>
> 3
>
> 0.00583
>
> 2
>
> 3
>
> 0.005722
>
> 3
>
> 3
>
> 0.005838
>
> 4
>
> 3
>
> 0.005873
>
> 4
>
> 12
>
> 0.0059
>
> 5
>
> 3
>
> 0.005724
>
> 6
>
> 12
>
> 0.005924
>
> 7
>
> 12
>
> 0.005758
>
> 8
>
> 12
>
> 0.005901
>
> 9
>
> 12
>
> 0.005894
>
> 10
>
> 3
>
> 0.005731
>
> 11
>
> 3
>
> 0.005951
>
>
>
> So Animal ID represents individual, 3 or 12 for month represents either a 
> March capture event or a December capture event and then the corresponding 
> cort value (which I used a random number generator to create these values 
> above). Petr, I was afraid of that response, that by using cor() I'm 
> fundamentally just testing the correlation for the 3 individuals that have 
> both March and December samples.
>
>
>
> If you guys have other thoughts I'd appreciate any suggestions.
>
>
>
> Thanks for your h

Re: [R] question

2023-01-31 Thread Boris Steipe
Perhaps, rather than looking to compress your observations into a single 
number, you could simply visualize what you observed: use a boxplot to show the 
March and December observations, and overlay the three animals that were 
recaptured as individual points, connected with a line.

Feel free to ask again if you are not sure how to do that.

Cheers,
Boris


PS. Lets hope that the capture did not stress them to the degree that their 
cortisol is elevated at recapture :-)




> On 2023-01-31, at 09:52, Carolyn J Miller via R-help  
> wrote:
> 
> Thank you!
> 
> Carolyn J. Miller
> M.S. Student, Ecology
> SUNY-ESF, Environmental Biology
> 
> 
> 
> From: Ebert,Timothy Aaron 
> Sent: Tuesday, January 31, 2023 9:50 AM
> To: Carolyn J Miller ; PIKAL Petr ; 
> r-help@r-project.org 
> Subject: RE: question
> 
> 
> As indicated here: 
> https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/
> 
> The cor() function needs two vectors. The only way that works is if you are 
> looking at the correlation between �Month� and �Cort.�
> 
> If you interested in the correlation between  Cort measured in month 3 versus 
> month 12 then you are not getting the right answer.
> 
> 
> 
> Animal ID is not relevant in this analysis (as presented).
> 
> The animals that have been measured twice would be a repeated measures 
> analysis (by default) unless there is some reason to suspect that the six 
> month lag is too long for an outcome in month 3 to influence the outcome in 
> month 12. The remaining animals are an experimental design for avoiding a 
> repeated measures analysis. This would be something like a t-test to 
> determine if the animals in Month 3 are different than Month 12.
> 
> 
> 
> Tim
> 
> 
> 
> From: Carolyn J Miller 
> Sent: Tuesday, January 31, 2023 9:30 AM
> To: PIKAL Petr ; r-help@r-project.org; Ebert,Timothy 
> Aaron 
> Subject: Re: question
> 
> 
> 
> [External Email]
> 
> Hi Timothy,
> 
> 
> 
> Here's some example data that might help to demonstrate how the data 
> currently looks.
> 
> 
> 
> AnimalID
> 
> Month
> 
> Cort
> 
> 1
> 
> 12
> 
> 0.00591
> 
> 1
> 
> 3
> 
> 0.00583
> 
> 2
> 
> 3
> 
> 0.005722
> 
> 3
> 
> 3
> 
> 0.005838
> 
> 4
> 
> 3
> 
> 0.005873
> 
> 4
> 
> 12
> 
> 0.0059
> 
> 5
> 
> 3
> 
> 0.005724
> 
> 6
> 
> 12
> 
> 0.005924
> 
> 7
> 
> 12
> 
> 0.005758
> 
> 8
> 
> 12
> 
> 0.005901
> 
> 9
> 
> 12
> 
> 0.005894
> 
> 10
> 
> 3
> 
> 0.005731
> 
> 11
> 
> 3
> 
> 0.005951
> 
> 
> 
> So Animal ID represents individual, 3 or 12 for month represents either a 
> March capture event or a December capture event and then the corresponding 
> cort value (which I used a random number generator to create these values 
> above). Petr, I was afraid of that response, that by using cor() I'm 
> fundamentally just testing the correlation for the 3 individuals that have 
> both March and December samples.
> 
> 
> 
> If you guys have other thoughts I'd appreciate any suggestions.
> 
> 
> 
> Thanks for your help and clarifying that for me.
> 
> 
> 
> Carolyn J. Miller
> 
> M.S. Student, Ecology
> 
> SUNY-ESF, Environmental Biology
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> From: PIKAL Petr
> Sent: Tuesday, January 31, 2023 2:36 AM
> To: Carolyn J Miller; r-help@r-project.org
> Subject: RE: question
> 
> 
> 
> Hallo Carolyn
> 
> From what you describe you cannot calculate correlations.
> 
> You stated that you have two sets of data, one for December and one for
> March and that rows in one set is not related to the rows in another set and
> even persons tested in both months do not have their values on the same row.
> In that case cor is not appropriate. You should first adjust your data so
> that results of those 3 persons are on the same row but even after that only
> those 3 values could be evaluated by "cor".
> 
> From what you wrote I think that t.test or similar beast is the way you
> should take.
> 
> But without same data sample I may be wrong.
> 
> Cheers
> Petr
> 
>> -Original Message-
>> From: R-help 
>> mailto:r-help-boun...@r-project.org>> On 
>> Behalf Of Carolyn J Miller
> via
>> R-help
>> Sent: Monday, January 30, 2023 7:16 PM
>> To: r-help@r-project.org
>> Subject: [R] question
>> 
>> Hi guys,
>> 
>> I am using the cor() function to see if there are correlations between
> March
>> cortisol levels and December cortisol levels and I'm trying to figure out
> if the
>> function is doing what I want it to do.
>> 
>> Each sample has it's own separate row in the CSV file that I'm working out
> of.
>> March Cort and December Cort are different columns and they come from
>> separate samples, therefore their values would not be on the same row.
> There
>> are only 3 individuals that have both December cort values and March
> cortisol
>> values but they still have different sample ID values (from different
> seasons) so

Re: [R] question

2023-01-31 Thread Carolyn J Miller via R-help
Thank you!

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology



From: Ebert,Timothy Aaron 
Sent: Tuesday, January 31, 2023 9:50 AM
To: Carolyn J Miller ; PIKAL Petr ; 
r-help@r-project.org 
Subject: RE: question


As indicated here: 
https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/

The cor() function needs two vectors. The only way that works is if you are 
looking at the correlation between �Month� and �Cort.�

If you interested in the correlation between  Cort measured in month 3 versus 
month 12 then you are not getting the right answer.



Animal ID is not relevant in this analysis (as presented).

The animals that have been measured twice would be a repeated measures analysis 
(by default) unless there is some reason to suspect that the six month lag is 
too long for an outcome in month 3 to influence the outcome in month 12. The 
remaining animals are an experimental design for avoiding a repeated measures 
analysis. This would be something like a t-test to determine if the animals in 
Month 3 are different than Month 12.



Tim



From: Carolyn J Miller 
Sent: Tuesday, January 31, 2023 9:30 AM
To: PIKAL Petr ; r-help@r-project.org; Ebert,Timothy 
Aaron 
Subject: Re: question



[External Email]

Hi Timothy,



Here's some example data that might help to demonstrate how the data currently 
looks.



AnimalID

Month

Cort

1

12

0.00591

1

3

0.00583

2

3

0.005722

3

3

0.005838

4

3

0.005873

4

12

0.0059

5

3

0.005724

6

12

0.005924

7

12

0.005758

8

12

0.005901

9

12

0.005894

10

3

0.005731

11

3

0.005951



So Animal ID represents individual, 3 or 12 for month represents either a March 
capture event or a December capture event and then the corresponding cort value 
(which I used a random number generator to create these values above). Petr, I 
was afraid of that response, that by using cor() I'm fundamentally just testing 
the correlation for the 3 individuals that have both March and December samples.



If you guys have other thoughts I'd appreciate any suggestions.



Thanks for your help and clarifying that for me.



Carolyn J. Miller

M.S. Student, Ecology

SUNY-ESF, Environmental Biology











From: PIKAL Petr
Sent: Tuesday, January 31, 2023 2:36 AM
To: Carolyn J Miller; r-help@r-project.org
Subject: RE: question



Hallo Carolyn

From what you describe you cannot calculate correlations.

You stated that you have two sets of data, one for December and one for
March and that rows in one set is not related to the rows in another set and
even persons tested in both months do not have their values on the same row.
In that case cor is not appropriate. You should first adjust your data so
that results of those 3 persons are on the same row but even after that only
those 3 values could be evaluated by "cor".

From what you wrote I think that t.test or similar beast is the way you
should take.

But without same data sample I may be wrong.

Cheers
Petr

> -Original Message-
> From: R-help 
> mailto:r-help-boun...@r-project.org>> On Behalf 
> Of Carolyn J Miller
via
> R-help
> Sent: Monday, January 30, 2023 7:16 PM
> To: r-help@r-project.org
> Subject: [R] question
>
> Hi guys,
>
> I am using the cor() function to see if there are correlations between
March
> cortisol levels and December cortisol levels and I'm trying to figure out
if the
> function is doing what I want it to do.
>
> Each sample has it's own separate row in the CSV file that I'm working out
of.
> March Cort and December Cort are different columns and they come from
> separate samples, therefore their values would not be on the same row.
There
> are only 3 individuals that have both December cort values and March
cortisol
> values but they still have different sample ID values (from different
seasons) so
> they are also not on the same row.
>
>  I ran the function twice: once as cor(cortphcor, use = "complete.obs")
first
>
> and then cor(cortphcor, use = "pairwise.complete.obs", method =
"pearson").
>
> I received the same output both times. I guess what I'm asking is, is the
output
> simply the correlation just for those 3 samples or is the second pairwise.
> complete.obs version giving me the correlation for all of the cort samples
for
> March against all of the samples for December despite not being on the
same
> row? I'm trying to figure out how many sample values are contributing to
the
> correlation results I'm getting.
>
> Thanks,
>
> Carolyn
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To 
> UNSUBSCRIBE and more, see
> 

Re: [R] question

2023-01-31 Thread Ebert,Timothy Aaron
As indicated here: 
https://www.geeksforgeeks.org/compute-the-correlation-coefficient-value-between-two-vectors-in-r-programming-cor-function/
The cor() function needs two vectors. The only way that works is if you are 
looking at the correlation between "Month" and "Cort."
If you interested in the correlation between  Cort measured in month 3 versus 
month 12 then you are not getting the right answer.

Animal ID is not relevant in this analysis (as presented).
The animals that have been measured twice would be a repeated measures analysis 
(by default) unless there is some reason to suspect that the six month lag is 
too long for an outcome in month 3 to influence the outcome in month 12. The 
remaining animals are an experimental design for avoiding a repeated measures 
analysis. This would be something like a t-test to determine if the animals in 
Month 3 are different than Month 12.

Tim

From: Carolyn J Miller 
Sent: Tuesday, January 31, 2023 9:30 AM
To: PIKAL Petr ; r-help@r-project.org; Ebert,Timothy 
Aaron 
Subject: Re: question

[External Email]
Hi Timothy,

Here's some example data that might help to demonstrate how the data currently 
looks.

AnimalID
Month
Cort
1
12
0.00591
1
3
0.00583
2
3
0.005722
3
3
0.005838
4
3
0.005873
4
12
0.0059
5
3
0.005724
6
12
0.005924
7
12
0.005758
8
12
0.005901
9
12
0.005894
10
3
0.005731
11
3
0.005951

So Animal ID represents individual, 3 or 12 for month represents either a March 
capture event or a December capture event and then the corresponding cort value 
(which I used a random number generator to create these values above). Petr, I 
was afraid of that response, that by using cor() I'm fundamentally just testing 
the correlation for the 3 individuals that have both March and December samples.

If you guys have other thoughts I'd appreciate any suggestions.

Thanks for your help and clarifying that for me.

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology







From: PIKAL Petr
Sent: Tuesday, January 31, 2023 2:36 AM
To: Carolyn J Miller; r-help@r-project.org
Subject: RE: question

Hallo Carolyn

>From what you describe you cannot calculate correlations.

You stated that you have two sets of data, one for December and one for
March and that rows in one set is not related to the rows in another set and
even persons tested in both months do not have their values on the same row.
In that case cor is not appropriate. You should first adjust your data so
that results of those 3 persons are on the same row but even after that only
those 3 values could be evaluated by "cor".

>From what you wrote I think that t.test or similar beast is the way you
should take.

But without same data sample I may be wrong.

Cheers
Petr

> -Original Message-
> From: R-help 
> mailto:r-help-boun...@r-project.org>> On Behalf 
> Of Carolyn J Miller
via
> R-help
> Sent: Monday, January 30, 2023 7:16 PM
> To: r-help@r-project.org
> Subject: [R] question
>
> Hi guys,
>
> I am using the cor() function to see if there are correlations between
March
> cortisol levels and December cortisol levels and I'm trying to figure out
if the
> function is doing what I want it to do.
>
> Each sample has it's own separate row in the CSV file that I'm working out
of.
> March Cort and December Cort are different columns and they come from
> separate samples, therefore their values would not be on the same row.
There
> are only 3 individuals that have both December cort values and March
cortisol
> values but they still have different sample ID values (from different
seasons) so
> they are also not on the same row.
>
>  I ran the function twice: once as cor(cortphcor, use = "complete.obs")
first
>
> and then cor(cortphcor, use = "pairwise.complete.obs", method =
"pearson").
>
> I received the same output both times. I guess what I'm asking is, is the
output
> simply the correlation just for those 3 samples or is the second pairwise.
> complete.obs version giving me the correlation for all of the cort samples
for
> March against all of the samples for December despite not being on the
same
> row? I'm trying to figure out how many sample values are contributing to
the
> correlation results I'm getting.
>
> Thanks,
>
> Carolyn
>
>
>[[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

Re: [R] question

2023-01-31 Thread Carolyn J Miller via R-help
Hi Timothy,

Here's some example data that might help to demonstrate how the data currently 
looks.

AnimalIDMonth   Cort
1   12  0.00591
1   3   0.00583
2   3   0.005722
3   3   0.005838
4   3   0.005873
4   12  0.0059
5   3   0.005724
6   12  0.005924
7   12  0.005758
8   12  0.005901
9   12  0.005894
10  3   0.005731
11  3   0.005951

So Animal ID represents individual, 3 or 12 for month represents either a March 
capture event or a December capture event and then the corresponding cort value 
(which I used a random number generator to create these values above). Petr, I 
was afraid of that response, that by using cor() I'm fundamentally just testing 
the correlation for the 3 individuals that have both March and December samples.

If you guys have other thoughts I'd appreciate any suggestions.

Thanks for your help and clarifying that for me.

Carolyn J. Miller
M.S. Student, Ecology
SUNY-ESF, Environmental Biology





From: PIKAL Petr
Sent: Tuesday, January 31, 2023 2:36 AM
To: Carolyn J Miller; r-help@r-project.org
Subject: RE: question

Hallo Carolyn

>From what you describe you cannot calculate correlations.

You stated that you have two sets of data, one for December and one for
March and that rows in one set is not related to the rows in another set and
even persons tested in both months do not have their values on the same row.
In that case cor is not appropriate. You should first adjust your data so
that results of those 3 persons are on the same row but even after that only
those 3 values could be evaluated by "cor".

>From what you wrote I think that t.test or similar beast is the way you
should take.

But without same data sample I may be wrong.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Carolyn J Miller
via
> R-help
> Sent: Monday, January 30, 2023 7:16 PM
> To: r-help@r-project.org
> Subject: [R] question
>
> Hi guys,
>
> I am using the cor() function to see if there are correlations between
March
> cortisol levels and December cortisol levels and I'm trying to figure out
if the
> function is doing what I want it to do.
>
> Each sample has it's own separate row in the CSV file that I'm working out
of.
> March Cort and December Cort are different columns and they come from
> separate samples, therefore their values would not be on the same row.
There
> are only 3 individuals that have both December cort values and March
cortisol
> values but they still have different sample ID values (from different
seasons) so
> they are also not on the same row.
>
>  I ran the function twice: once as cor(cortphcor, use = "complete.obs")
first
>
> and then cor(cortphcor, use = "pairwise.complete.obs", method =
"pearson").
>
> I received the same output both times. I guess what I'm asking is, is the
output
> simply the correlation just for those 3 samples or is the second pairwise.
> complete.obs version giving me the correlation for all of the cort samples
for
> March against all of the samples for December despite not being on the
same
> row? I'm trying to figure out how many sample values are contributing to
the
> correlation results I'm getting.
>
> Thanks,
>
> Carolyn
>
>
>[[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] question

2023-01-30 Thread PIKAL Petr
Hallo Carolyn

>From what you describe you cannot calculate correlations.

You stated that you have two sets of data, one for December and one for
March and that rows in one set is not related to the rows in another set and
even persons tested in both months do not have their values on the same row.
In that case cor is not appropriate. You should first adjust your data so
that results of those 3 persons are on the same row but even after that only
those 3 values could be evaluated by "cor".

>From what you wrote I think that t.test or similar beast is the way you
should take.

But without same data sample I may be wrong.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Carolyn J Miller
via
> R-help
> Sent: Monday, January 30, 2023 7:16 PM
> To: r-help@r-project.org
> Subject: [R] question
> 
> Hi guys,
> 
> I am using the cor() function to see if there are correlations between
March
> cortisol levels and December cortisol levels and I'm trying to figure out
if the
> function is doing what I want it to do.
> 
> Each sample has it's own separate row in the CSV file that I'm working out
of.
> March Cort and December Cort are different columns and they come from
> separate samples, therefore their values would not be on the same row.
There
> are only 3 individuals that have both December cort values and March
cortisol
> values but they still have different sample ID values (from different
seasons) so
> they are also not on the same row.
> 
>  I ran the function twice: once as cor(cortphcor, use = "complete.obs")
first
> 
> and then cor(cortphcor, use = "pairwise.complete.obs", method =
"pearson").
> 
> I received the same output both times. I guess what I'm asking is, is the
output
> simply the correlation just for those 3 samples or is the second pairwise.
> complete.obs version giving me the correlation for all of the cort samples
for
> March against all of the samples for December despite not being on the
same
> row? I'm trying to figure out how many sample values are contributing to
the
> correlation results I'm getting.
> 
> Thanks,
> 
> Carolyn
> 
> 
>   [[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] question

2023-01-30 Thread Ebert,Timothy Aaron
Can you please show us a small sample of your data? The first 5 or 10 lines 
should be good enough.
Tim

-Original Message-
From: R-help  On Behalf Of Carolyn J Miller via 
R-help
Sent: Monday, January 30, 2023 1:16 PM
To: r-help@r-project.org
Subject: [R] question

[External Email]

Hi guys,

I am using the cor() function to see if there are correlations between March 
cortisol levels and December cortisol levels and I'm trying to figure out if 
the function is doing what I want it to do.

Each sample has it's own separate row in the CSV file that I'm working out of. 
March Cort and December Cort are different columns and they come from separate 
samples, therefore their values would not be on the same row. There are only 3 
individuals that have both December cort values and March cortisol values but 
they still have different sample ID values (from different seasons) so they are 
also not on the same row.

 I ran the function twice: once as cor(cortphcor, use = "complete.obs") first

and then cor(cortphcor, use = "pairwise.complete.obs", method = "pearson").

I received the same output both times. I guess what I'm asking is, is the 
output simply the correlation just for those 3 samples or is the second 
pairwise. complete.obs version giving me the correlation for all of the cort 
samples for March against all of the samples for December despite not being on 
the same row? I'm trying to figure out how many sample values are contributing 
to the correlation results I'm getting.

Thanks,

Carolyn


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu%7Cdd5773a499934ef0fd3a08db032d0447%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638107264114367125%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=YxPstnNkhcAvtY7SdBGpW3LFFubZl2WKaEuc29qh40Y%3D=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%7Cdd5773a499934ef0fd3a08db032d0447%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638107264114367125%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=OxrAXBA2yjPy%2B94tKkiQ34adp%2BPrNPcpp2SE81ZEUZ4%3D=0
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] Question about Line Ending Choice

2022-09-29 Thread Stephen H. Dawson, DSL via R-help

Awesome idea, Jorgen. Thanks for the input.

As expected, it was smart to ask about matter this before I undertook my 
build effort.



Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com


On 9/28/22 12:06, Jorgen Harmse via R-help wrote:

eol seems to be the parameter to use, but the answers so far appear to assume 
that the file is created on a Mac. For example, I think that �\r\n� on Windows 
would produce CR CR LF. I don�t have both systems handy (so I can�t test), but 
I think you should use raw to specify the bytes you want.

# I think the following are independent of the OS on which you are writing the 
file.
CR <- rawToChar(as.raw(13))
LF <- rawToChar(as.raw(10))
if missing(target)
   # Hope that it matches the machine on which you are writing the file.
   eol <- �\n�
else if (target==�Windows�)
   eol <- c(CR,LF)
else if (target %in% c(�Unix�,�Mac�))
   eol <- LF
else if �.
else
   stop(�Unexpected target.�)

write.table(eol=eol, �.)

Regards,
Jorgen Harmse.



Message: 7
Date: Tue, 27 Sep 2022 11:35:54 -0400
From: "Stephen H. Dawson, DSL" 
To: Bert Gunter 
Cc: r-help 
Subject: Re: [R] Question about Line Ending Choice
Message-ID: <04e458aa-e5f5-c932-da3c-1aa35db7d...@shdawson.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi Bert,


Thanks for the reply.

I did see the parameter, but was not sure if this is the correct
parameter to reference. I also see it in write.csv.

I take it you are saying the eol parameter is the best practice for
exporting from R using these functions. Am I correct or is there another
option other than write.csv and write.table I should be considering?


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com


On 9/27/22 11:29, Bert Gunter wrote:

Did you not see the "eol" parameter in write.table ?

Bert

On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help
 wrote:

 Hi All,


 I am writing with a question about choosing the line ending aspect
 of a
 file, please.

 I use write.csv and write.table to export work to CSV files and TXT
 files. I am planning now on how to share my work with the Windows
 crowd
 beyond only sharing with the Linux crowd. I use my text editor to
 flip
 the line ending option from Linux to Windows after exporting. This is
 inefficient for me to accomplish if I ramp up production as I expect
 will occur.

 Staying with the character encoding of UTF-8 seems fine for now from
 what I understand I need to deliver to my customers.

 What seems more efficient to me is to learn how to use R to define
 the
 line ending aspect of the exported file. I have not found if this
 is an
 option within R.

 QUESTION
 Is it possible within R to define the line ending aspect of file
 output?


 Kindest Regards,
 --
 *Stephen Dawson, DSL*
 /Executive Strategy Consultant/
 Business & Technology
 +1 (865) 804-3454
 http://www.shdawson.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
 <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] Question about Line Ending Choice

2022-09-29 Thread Stephen H. Dawson, DSL via R-help

Hi Enrico,


You bring me the missing piece of my understanding to my conceptual 
planning and cost counting to avoid delivery costs being greater than 
acceptable.


Much appreciated.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com


On 9/29/22 05:24, Enrico Schumann wrote:

On Tue, 27 Sep 2022, Stephen H. Dawson, DSL via R-help writes:


Hi All,


I am writing with a question about choosing the line
ending aspect of a file, please.

I use write.csv and write.table to export work to CSV
files and TXT files. I am planning now on how to share
my work with the Windows crowd beyond only sharing with
the Linux crowd. I use my text editor to flip the line
ending option from Linux to Windows after
exporting. This is inefficient for me to accomplish if
I ramp up production as I expect will occur.

Staying with the character encoding of UTF-8 seems fine
for now from what I understand I need to deliver to my
customers.

What seems more efficient to me is to learn how to use
R to define the line ending aspect of the exported
file. I have not found if this is an option within R.

QUESTION
Is it possible within R to define the line ending aspect of file output?


Kindest Regards,

Just a remark: there is a "standard" for CSV,
https://datatracker.ietf.org/doc/html/rfc4180.
It always requires CRLF as the line ending.



__
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] Question about Line Ending Choice

2022-09-29 Thread Enrico Schumann
On Tue, 27 Sep 2022, Stephen H. Dawson, DSL via R-help writes:

> Hi All,
>
>
> I am writing with a question about choosing the line
> ending aspect of a file, please.
>
> I use write.csv and write.table to export work to CSV
> files and TXT files. I am planning now on how to share
> my work with the Windows crowd beyond only sharing with
> the Linux crowd. I use my text editor to flip the line
> ending option from Linux to Windows after
> exporting. This is inefficient for me to accomplish if
> I ramp up production as I expect will occur.
>
> Staying with the character encoding of UTF-8 seems fine
> for now from what I understand I need to deliver to my
> customers.
>
> What seems more efficient to me is to learn how to use
> R to define the line ending aspect of the exported
> file. I have not found if this is an option within R.
>
> QUESTION
> Is it possible within R to define the line ending aspect of file output?
>
>
> Kindest Regards,

Just a remark: there is a "standard" for CSV,
https://datatracker.ietf.org/doc/html/rfc4180.
It always requires CRLF as the line ending.

-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] Question about Line Ending Choice

2022-09-28 Thread Jorgen Harmse via R-help
eol seems to be the parameter to use, but the answers so far appear to assume 
that the file is created on a Mac. For example, I think that �\r\n� on Windows 
would produce CR CR LF. I don�t have both systems handy (so I can�t test), but 
I think you should use raw to specify the bytes you want.

# I think the following are independent of the OS on which you are writing the 
file.
CR <- rawToChar(as.raw(13))
LF <- rawToChar(as.raw(10))
if missing(target)
  # Hope that it matches the machine on which you are writing the file.
  eol <- �\n�
else if (target==�Windows�)
  eol <- c(CR,LF)
else if (target %in% c(�Unix�,�Mac�))
  eol <- LF
else if �.
else
  stop(�Unexpected target.�)

write.table(eol=eol, �.)

Regards,
Jorgen Harmse.



Message: 7
Date: Tue, 27 Sep 2022 11:35:54 -0400
From: "Stephen H. Dawson, DSL" 
To: Bert Gunter 
Cc: r-help 
Subject: Re: [R] Question about Line Ending Choice
Message-ID: <04e458aa-e5f5-c932-da3c-1aa35db7d...@shdawson.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi Bert,


Thanks for the reply.

I did see the parameter, but was not sure if this is the correct
parameter to reference. I also see it in write.csv.

I take it you are saying the eol parameter is the best practice for
exporting from R using these functions. Am I correct or is there another
option other than write.csv and write.table I should be considering?


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com


On 9/27/22 11:29, Bert Gunter wrote:
> Did you not see the "eol" parameter in write.table ?
>
> Bert
>
> On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help
>  wrote:
>
> Hi All,
>
>
> I am writing with a question about choosing the line ending aspect
> of a
> file, please.
>
> I use write.csv and write.table to export work to CSV files and TXT
> files. I am planning now on how to share my work with the Windows
> crowd
> beyond only sharing with the Linux crowd. I use my text editor to
> flip
> the line ending option from Linux to Windows after exporting. This is
> inefficient for me to accomplish if I ramp up production as I expect
> will occur.
>
> Staying with the character encoding of UTF-8 seems fine for now from
> what I understand I need to deliver to my customers.
>
> What seems more efficient to me is to learn how to use R to define
> the
> line ending aspect of the exported file. I have not found if this
> is an
> option within R.
>
> QUESTION
> Is it possible within R to define the line ending aspect of file
> output?
>
>
> Kindest Regards,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.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
> <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] Question about Line Ending Choice

2022-09-27 Thread Stephen H. Dawson, DSL via R-help

Hi Bert,


Thanks for the reply.

I did see the parameter, but was not sure if this is the correct 
parameter to reference. I also see it in write.csv.


I take it you are saying the eol parameter is the best practice for 
exporting from R using these functions. Am I correct or is there another 
option other than write.csv and write.table I should be considering?



Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com


On 9/27/22 11:29, Bert Gunter wrote:

Did you not see the "eol" parameter in write.table ?

Bert

On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help 
 wrote:


Hi All,


I am writing with a question about choosing the line ending aspect
of a
file, please.

I use write.csv and write.table to export work to CSV files and TXT
files. I am planning now on how to share my work with the Windows
crowd
beyond only sharing with the Linux crowd. I use my text editor to
flip
the line ending option from Linux to Windows after exporting. This is
inefficient for me to accomplish if I ramp up production as I expect
will occur.

Staying with the character encoding of UTF-8 seems fine for now from
what I understand I need to deliver to my customers.

What seems more efficient to me is to learn how to use R to define
the
line ending aspect of the exported file. I have not found if this
is an
option within R.

QUESTION
Is it possible within R to define the line ending aspect of file
output?


Kindest Regards,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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.



__
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] Question about Line Ending Choice

2022-09-27 Thread Bert Gunter
Did you not see the "eol" parameter in write.table ?

Bert

On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help <
r-help@r-project.org> wrote:

> Hi All,
>
>
> I am writing with a question about choosing the line ending aspect of a
> file, please.
>
> I use write.csv and write.table to export work to CSV files and TXT
> files. I am planning now on how to share my work with the Windows crowd
> beyond only sharing with the Linux crowd. I use my text editor to flip
> the line ending option from Linux to Windows after exporting. This is
> inefficient for me to accomplish if I ramp up production as I expect
> will occur.
>
> Staying with the character encoding of UTF-8 seems fine for now from
> what I understand I need to deliver to my customers.
>
> What seems more efficient to me is to learn how to use R to define the
> line ending aspect of the exported file. I have not found if this is an
> option within R.
>
> QUESTION
> Is it possible within R to define the line ending aspect of file output?
>
>
> Kindest Regards,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.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.
>

[[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] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Ebert,Timothy Aaron
Hi Tibor,
   I'll try again. Your problem has nothing to do with factors and everything 
to do with trying to bind a vector to a dataframe and not understanding that a 
vector must be of one class and that a column in a data frame is a vector and 
therefore must also be of one class. If you want to add a new row of data to 
your existing data frame use a new data frame with one row.

df <- data.frame(
  P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
  ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
  RT = round(runif(6, 7000, 16000), 0)
)

dq<-data.frame(
  P = factor("in"),
  ANSWER = factor("V>N"),
  RT = round(runif(1,7000, 16000), 0)
)

df2 <- rbind(df,dq)
df2

In this approach R kindly adds the new class to the factor variables and the 
numeric value to the numeric variable.
Keeping in mind that a vector can only be of one class will save you many 
debugging hours later on.

Tim

-Original Message-
From: Sarah Goslee  
Sent: Tuesday, September 20, 2022 9:02 AM
To: tibor.k...@rub.de
Cc: Ebert,Timothy Aaron ; r-help@r-project.org
Subject: Re: [R] Question concerning side effects of treating invalid factor 
levels

[External Email]

Hi Tibor,

No, you are misunderstanding the source of the problem. It has nothing to do 
with factors.

Instead, it has to do with the inability of a vector to hold more than one 
class.

You are using rbind() to add a new row to your data frame, but that vector is 
being coerced to character. That's what is forcing your numeric column to 
become character: you're adding a character to it.

> c("in", "V>N", round(runif(1, 7000, 16000), 0))
[1] "in""V>N"   "15709"

It has nothing whatsoever to do with factors or factor levels, and would occur 
if you were adding it to a data frame with character values.

If you want to mix types, you cannot use a vector.

c2 <- data.frame(P = "in", ANSWER = "V>N", RT = round(runif(1, 7000, 16000), 0))
> str(rbind(df, c2))
'data.frame': 7 obs. of  3 variables:
 $ P : Factor w/ 4 levels "mit","mittels",..: 2 1 2 3 1 1 4
 $ ANSWER: Factor w/ 3 levels "OBJ>PP","PP>OBJ",..: 2 2 2 2 1 1 3
 $ RT: num  10867 14808 11600 15881 8984 ...


Sarah

On Tue, Sep 20, 2022 at 8:45 AM Tibor Kiss via R-help  
wrote:
>
> Hi,
>
> this is a misunderstanding of my question. I wasn't worried about invalid 
> factor levels that produce NA. My question was why a column changes its 
> class, which I thought was a side effect. If you add a vector containing one 
> character string, the class of the whole vector becomes _chr_. And after this 
> element has been added to a column, we have two NAs for the column which are 
> factors, and a character string, which is responsible for the change of a 
> numerical vector into a character string vector (see ?c, where you find: "The 
> output type is determined from the highest type of the components in the 
> hierarchy NULL < raw < logical < integer < double < complex < character < 
> list < expression.").
>
>
> Best
>
>
> Tibor
>
>
>
> > Am 19.09.2022 um 13:59 schrieb Ebert,Timothy Aaron :
> >
> > In your example code, the variable remains a class factor, and all entries 
> > are valid. The variables will behave as expected given the factor levels in 
> > the original dataframe.
> >
> > (At least on my system R 4.2, in RStudio, in Windows) R returns a couple of 
> > error messages warning me that I was bad.
> > What you get is NA for "not available", or "not appropriate" or a missing 
> > value. You gave the system an invalid factor level so it was entered as 
> > missing. If you get data that has a new factor level, you need to tell R to 
> > expect a new factor level first.
> >
> > levels(f1) <- c(levels(f1),"New Level")
> > levels(f1) <- c(levels(f1),c("NL1","NL2"))
> >
> >
> > Tim
> > -Original Message-
> > From: R-help  On Behalf Of Tibor Kiss 
> > via R-help
> > Sent: Monday, September 19, 2022 6:11 AM
> > To: r-help@r-project.org
> > Subject: [R] Question concerning side effects of treating invalid 
> > factor levels
> >
> > [External Email]
> >
> > Dear List members,
> >
> > I have tried now for several times to find out about a side effect of 
> > treating invalid factor levels, but did not find an answer. Various answers 
> > on stackexchange etc. produce the stuff that irritates me without even 
> > mentioning it.
> > So I am asking the list (apologies i

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Sarah Goslee
Hi Tibor,

No, you are misunderstanding the source of the problem. It has nothing
to do with factors.

Instead, it has to do with the inability of a vector to hold more than
one class.

You are using rbind() to add a new row to your data frame, but that
vector is being coerced to character. That's what is forcing your
numeric column to become character: you're adding a character to it.

> c("in", "V>N", round(runif(1, 7000, 16000), 0))
[1] "in""V>N"   "15709"

It has nothing whatsoever to do with factors or factor levels, and
would occur if you were adding it to a data frame with character
values.

If you want to mix types, you cannot use a vector.

c2 <- data.frame(P = "in", ANSWER = "V>N", RT = round(runif(1, 7000, 16000), 0))
> str(rbind(df, c2))
'data.frame': 7 obs. of  3 variables:
 $ P : Factor w/ 4 levels "mit","mittels",..: 2 1 2 3 1 1 4
 $ ANSWER: Factor w/ 3 levels "OBJ>PP","PP>OBJ",..: 2 2 2 2 1 1 3
 $ RT: num  10867 14808 11600 15881 8984 ...


Sarah

On Tue, Sep 20, 2022 at 8:45 AM Tibor Kiss via R-help
 wrote:
>
> Hi,
>
> this is a misunderstanding of my question. I wasn’t worried about invalid 
> factor levels that produce NA. My question was why a column changes its 
> class, which I thought was a side effect. If you add a vector containing one 
> character string, the class of the whole vector becomes _chr_. And after this 
> element has been added to a column, we have two NAs for the column which are 
> factors, and a character string, which is responsible for the change of a 
> numerical vector into a character string vector (see ?c, where you find: "The 
> output type is determined from the highest type of the components in the 
> hierarchy NULL < raw < logical < integer < double < complex < character < 
> list < expression.“).
>
>
> Best
>
>
> Tibor
>
>
>
> > Am 19.09.2022 um 13:59 schrieb Ebert,Timothy Aaron :
> >
> > In your example code, the variable remains a class factor, and all entries 
> > are valid. The variables will behave as expected given the factor levels in 
> > the original dataframe.
> >
> > (At least on my system R 4.2, in RStudio, in Windows) R returns a couple of 
> > error messages warning me that I was bad.
> > What you get is NA for "not available", or "not appropriate" or a missing 
> > value. You gave the system an invalid factor level so it was entered as 
> > missing. If you get data that has a new factor level, you need to tell R to 
> > expect a new factor level first.
> >
> > levels(f1) <- c(levels(f1),"New Level")
> > levels(f1) <- c(levels(f1),c("NL1","NL2"))
> >
> >
> > Tim
> > -Original Message-
> > From: R-help  On Behalf Of Tibor Kiss via 
> > R-help
> > Sent: Monday, September 19, 2022 6:11 AM
> > To: r-help@r-project.org
> > Subject: [R] Question concerning side effects of treating invalid factor 
> > levels
> >
> > [External Email]
> >
> > Dear List members,
> >
> > I have tried now for several times to find out about a side effect of 
> > treating invalid factor levels, but did not find an answer. Various answers 
> > on stackexchange etc. produce the stuff that irritates me without even 
> > mentioning it.
> > So I am asking the list (apologies if this has been treated in the past).
> >
> > If you add an invalid factor level to a column in a data frame, this has 
> > the side effect of turning a numerical column into a column with character 
> > strings. Here is a simple example:
> >
> >> df <- data.frame(
> >P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
> >ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
> >RT = round(runif(6, 7000, 16000), 0))
> >
> >> str(df)
> > 'data.frame':   6 obs. of  3 variables:
> > $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
> > $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
> > $ RT: num  11157 13719 14388 14527 14686 ..
> >
> >> df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))
> >
> >> str(df)
> > 'data.frame':   7 obs. of  3 variables:
> > $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
> > $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
> > $ RT: chr  "11478" "15819" "8305" "8852" ...
> >
> > You see that RT has changed from _num_ to _chr_ as a side effect of adding 
> > the invalid factor level as NA. I would appreciate understanding what the 
> > purpose of the type coercion is.
> >
> > Thanks in advance
> >
> >
> > Tibor
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=sNDYEJKhjSu%2FtrTIwZx5yVemKgDheQYXLrcQqJ2mOgo%3Dreserved=0
> > PLEASE 

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Tibor Kiss via R-help
Hi, 

this is a misunderstanding of my question. I wasn’t worried about invalid 
factor levels that produce NA. My question was why a column changes its class, 
which I thought was a side effect. If you add a vector containing one character 
string, the class of the whole vector becomes _chr_. And after this element has 
been added to a column, we have two NAs for the column which are factors, and a 
character string, which is responsible for the change of a numerical vector 
into a character string vector (see ?c, where you find: "The output type is 
determined from the highest type of the components in the hierarchy NULL < raw 
< logical < integer < double < complex < character < list < expression.“).

 
Best


Tibor



> Am 19.09.2022 um 13:59 schrieb Ebert,Timothy Aaron :
> 
> In your example code, the variable remains a class factor, and all entries 
> are valid. The variables will behave as expected given the factor levels in 
> the original dataframe.
> 
> (At least on my system R 4.2, in RStudio, in Windows) R returns a couple of 
> error messages warning me that I was bad.
> What you get is NA for "not available", or "not appropriate" or a missing 
> value. You gave the system an invalid factor level so it was entered as 
> missing. If you get data that has a new factor level, you need to tell R to 
> expect a new factor level first.
> 
> levels(f1) <- c(levels(f1),"New Level")
> levels(f1) <- c(levels(f1),c("NL1","NL2"))
> 
> 
> Tim
> -Original Message-
> From: R-help  On Behalf Of Tibor Kiss via R-help
> Sent: Monday, September 19, 2022 6:11 AM
> To: r-help@r-project.org
> Subject: [R] Question concerning side effects of treating invalid factor 
> levels
> 
> [External Email]
> 
> Dear List members,
> 
> I have tried now for several times to find out about a side effect of 
> treating invalid factor levels, but did not find an answer. Various answers 
> on stackexchange etc. produce the stuff that irritates me without even 
> mentioning it.
> So I am asking the list (apologies if this has been treated in the past).
> 
> If you add an invalid factor level to a column in a data frame, this has the 
> side effect of turning a numerical column into a column with character 
> strings. Here is a simple example:
> 
>> df <- data.frame(
>P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
>ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
>RT = round(runif(6, 7000, 16000), 0))
> 
>> str(df)
> 'data.frame':   6 obs. of  3 variables:
> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
> $ RT: num  11157 13719 14388 14527 14686 ..
> 
>> df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))
> 
>> str(df)
> 'data.frame':   7 obs. of  3 variables:
> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
> $ RT: chr  "11478" "15819" "8305" "8852" ...
> 
> You see that RT has changed from _num_ to _chr_ as a side effect of adding 
> the invalid factor level as NA. I would appreciate understanding what the 
> purpose of the type coercion is.
> 
> Thanks in advance
> 
> 
> Tibor
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=sNDYEJKhjSu%2FtrTIwZx5yVemKgDheQYXLrcQqJ2mOgo%3Dreserved=0
> PLEASE do read the posting guide 
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=AP%2B4fa5pvbGr3IfwdiQvjXwkOdY90CIWIWWWmpIHH7w%3Dreserved=0
> 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] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Tibor Kiss via R-help
Dear Eric,

thank you very much. I wouldn’t have come to the idea to look up the help page 
for _c()_, which of course explains the coercion to the highest type. 

Best

T.


> Am 19.09.2022 um 13:31 schrieb Eric Berger :
> 
> You are misinterpreting what is going on.
> The rbind command includes c(char, char, int) which produces a
> character vector of length 3.
> This is what you are rbind-ing which changes the type of the RT column.
> 
> If you do rbind(df, data.frame(P="in", ANSWER="V>N",
> RT=round(runif(1,7000,16000),0)))
> you will see that everything is fine. (New factor values are created.)
> 
> HTH,
> Eric
> 
> On Mon, Sep 19, 2022 at 2:14 PM Tibor Kiss via R-help
>  wrote:
>> 
>> Dear List members,
>> 
>> I have tried now for several times to find out about a side effect of 
>> treating invalid factor levels, but did not find an answer. Various answers 
>> on stackexchange etc. produce the stuff that irritates me without even 
>> mentioning it.
>> So I am asking the list (apologies if this has been treated in the past).
>> 
>> If you add an invalid factor level to a column in a data frame, this has the 
>> side effect of turning a numerical column into a column with character 
>> strings. Here is a simple example:
>> 
>>> df <- data.frame(
>>P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
>>ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
>>RT = round(runif(6, 7000, 16000), 0))
>> 
>>> str(df)
>> 'data.frame':   6 obs. of  3 variables:
>> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
>> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
>> $ RT: num  11157 13719 14388 14527 14686 ..
>> 
>>> df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))
>> 
>>> str(df)
>> 'data.frame':   7 obs. of  3 variables:
>> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
>> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
>> $ RT: chr  "11478" "15819" "8305" "8852" …
>> 
>> You see that RT has changed from _num_ to _chr_ as a side effect of adding 
>> the invalid factor level as NA. I would appreciate understanding what the 
>> purpose of the type coercion is.
>> 
>> Thanks in advance
>> 
>> 
>> Tibor
>> __
>> 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] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Ebert,Timothy Aaron


Sorry, My bad.
A vector must be of a single class. When you declare c("in", "V>N", 
round(runif(1, 7000, 16000), 0)) R will calculate the random number, but then 
convert it to a character class to conform with the other two elements in that 
vector. R then binds this to your original df and finds that it must add a 
character to a numeric vector. To keep the vector of all the same class it 
converts everything to character.

Better?

Tim

From: tibor.k...@rub.de 
Sent: Monday, September 19, 2022 8:07 AM
To: Ebert,Timothy Aaron 
Cc: r-help@r-project.org
Subject: Re: [R] Question concerning side effects of treating invalid factor 
levels

[External Email]
Hi,

this is a misunderstanding of my question. I wasn't worried about invalid 
factor levels that produce NA. My question was why a column changes its class, 
which I thought was a side effect. If you add a vector containing one character 
string, the class of the whole vector becomes _chr_. And after this element has 
been added to a column, we have two NAs for the column which are factors, and a 
character string, which is responsible for the change of a numerical vector 
into a character string vector (see ?c, where you find: "The output type is 
determined from the highest type of the components in the hierarchy NULL < raw 
< logical < integer < double < complex < character < list < expression.").


Best


Tibor




Am 19.09.2022 um 13:59 schrieb Ebert,Timothy Aaron 
mailto:teb...@ufl.edu>>:

In your example code, the variable remains a class factor, and all entries are 
valid. The variables will behave as expected given the factor levels in the 
original dataframe.

(At least on my system R 4.2, in RStudio, in Windows) R returns a couple of 
error messages warning me that I was bad.
What you get is NA for "not available", or "not appropriate" or a missing 
value. You gave the system an invalid factor level so it was entered as 
missing. If you get data that has a new factor level, you need to tell R to 
expect a new factor level first.

levels(f1) <- c(levels(f1),"New Level")
levels(f1) <- c(levels(f1),c("NL1","NL2"))


Tim
-Original Message-
From: R-help 
mailto:r-help-boun...@r-project.org>> On Behalf 
Of Tibor Kiss via R-help
Sent: Monday, September 19, 2022 6:11 AM
To: r-help@r-project.org<mailto:r-help@r-project.org>
Subject: [R] Question concerning side effects of treating invalid factor levels

[External Email]

Dear List members,

I have tried now for several times to find out about a side effect of treating 
invalid factor levels, but did not find an answer. Various answers on 
stackexchange etc. produce the stuff that irritates me without even mentioning 
it.
So I am asking the list (apologies if this has been treated in the past).

If you add an invalid factor level to a column in a data frame, this has the 
side effect of turning a numerical column into a column with character strings. 
Here is a simple example:


df <- data.frame(
   P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
   ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
   RT = round(runif(6, 7000, 16000), 0))


str(df)
'data.frame':   6 obs. of  3 variables:
$ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
$ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
$ RT: num  11157 13719 14388 14527 14686 ..


df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))


str(df)
'data.frame':   7 obs. of  3 variables:
$ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
$ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
$ RT: chr  "11478" "15819" "8305" "8852" ...

You see that RT has changed from _num_ to _chr_ as a side effect of adding the 
invalid factor level as NA. I would appreciate understanding what the purpose 
of the type coercion is.

Thanks in advance


Tibor
__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=sNDYEJKhjSu%2FtrTIwZx5yVemKgDheQYXLrcQqJ2mOgo%3Dreserved=0<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu%7C8befab72dd954eeba5fe08da9a378808%7C

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Ebert,Timothy Aaron
In your example code, the variable remains a class factor, and all entries are 
valid. The variables will behave as expected given the factor levels in the 
original dataframe.

(At least on my system R 4.2, in RStudio, in Windows) R returns a couple of 
error messages warning me that I was bad.
What you get is NA for "not available", or "not appropriate" or a missing 
value. You gave the system an invalid factor level so it was entered as 
missing. If you get data that has a new factor level, you need to tell R to 
expect a new factor level first.

levels(f1) <- c(levels(f1),"New Level")
levels(f1) <- c(levels(f1),c("NL1","NL2"))


Tim
-Original Message-
From: R-help  On Behalf Of Tibor Kiss via R-help
Sent: Monday, September 19, 2022 6:11 AM
To: r-help@r-project.org
Subject: [R] Question concerning side effects of treating invalid factor levels

[External Email]

Dear List members,

I have tried now for several times to find out about a side effect of treating 
invalid factor levels, but did not find an answer. Various answers on 
stackexchange etc. produce the stuff that irritates me without even mentioning 
it.
So I am asking the list (apologies if this has been treated in the past).

If you add an invalid factor level to a column in a data frame, this has the 
side effect of turning a numerical column into a column with character strings. 
Here is a simple example:

> df <- data.frame(
P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
RT = round(runif(6, 7000, 16000), 0))

> str(df)
'data.frame':   6 obs. of  3 variables:
$ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
$ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
$ RT: num  11157 13719 14388 14527 14686 ..

> df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))

> str(df)
'data.frame':   7 obs. of  3 variables:
$ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
$ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
$ RT: chr  "11478" "15819" "8305" "8852" ...

You see that RT has changed from _num_ to _chr_ as a side effect of adding the 
invalid factor level as NA. I would appreciate understanding what the purpose 
of the type coercion is.

Thanks in advance


Tibor
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=sNDYEJKhjSu%2FtrTIwZx5yVemKgDheQYXLrcQqJ2mOgo%3Dreserved=0
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C6ee1a1f50c14442beef508da9a301bde%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637991828670135028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=AP%2B4fa5pvbGr3IfwdiQvjXwkOdY90CIWIWWWmpIHH7w%3Dreserved=0
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] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Eric Berger
You are misinterpreting what is going on.
The rbind command includes c(char, char, int) which produces a
character vector of length 3.
This is what you are rbind-ing which changes the type of the RT column.

If you do rbind(df, data.frame(P="in", ANSWER="V>N",
RT=round(runif(1,7000,16000),0)))
you will see that everything is fine. (New factor values are created.)

HTH,
Eric

On Mon, Sep 19, 2022 at 2:14 PM Tibor Kiss via R-help
 wrote:
>
> Dear List members,
>
> I have tried now for several times to find out about a side effect of 
> treating invalid factor levels, but did not find an answer. Various answers 
> on stackexchange etc. produce the stuff that irritates me without even 
> mentioning it.
> So I am asking the list (apologies if this has been treated in the past).
>
> If you add an invalid factor level to a column in a data frame, this has the 
> side effect of turning a numerical column into a column with character 
> strings. Here is a simple example:
>
> > df <- data.frame(
> P = factor(c("mittels", "mit", "mittels", "ueber", "mit", "mit")),
> ANSWER = factor(c(rep("PP>OBJ", 4), rep("OBJ>PP", 2))),
> RT = round(runif(6, 7000, 16000), 0))
>
> > str(df)
> 'data.frame':   6 obs. of  3 variables:
> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1
> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1
> $ RT: num  11157 13719 14388 14527 14686 ..
>
> > df <- rbind(df, c("in", "V>N", round(runif(1, 7000, 16000), 0)))
>
> > str(df)
> 'data.frame':   7 obs. of  3 variables:
> $ P : Factor w/ 3 levels "mit","mittels",..: 2 1 2 3 1 1 NA
> $ ANSWER: Factor w/ 2 levels "OBJ>PP","PP>OBJ": 2 2 2 2 1 1 NA
> $ RT: chr  "11478" "15819" "8305" "8852" …
>
> You see that RT has changed from _num_ to _chr_ as a side effect of adding 
> the invalid factor level as NA. I would appreciate understanding what the 
> purpose of the type coercion is.
>
> Thanks in advance
>
>
> Tibor
> __
> 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] question

2022-03-15 Thread Rui Barradas

Hello,

RiverSmooth is not a function in package flowr it's a function in GitHub 
package PriorityFlow. This package is not on CRAN.



devtools::install_github("lecondon/PriorityFlow", subdir = "Rpkg")
library('PriorityFlow')

?RiverSmooth
RiverSmooth {PriorityFlow}  R Documentation
Apply smoothing to a DEM along a pre-defined stream network
Description
This function will smooth a DEM along a stream network. It requires 
pre-defined stream segments and subbasins which can be obtained using 
the CalcSubbasins function.



As for the error, I cannot say more than this (excet that the OP 
shouldn't write in all caps, like Ivan already said), I know nothing of 
this package. Try to contact


maintainer("PriorityFlow")
[1] "Laura Condon "

Hope this helps,

Rui Barradas

Às 21:31 de 15/03/2022, Ebert,Timothy Aaron escreveu:

There are some tutorials online.
https://cran.r-project.org/web/packages/flowr/vignettes/flowr_overview.html
https://github.com/flow-r/flowr
https://www.rdocumentation.org/packages/flowr/versions/0.9.11
https://flowr.readthedocs.io/en/latest/rd/vignettes/build-pipes.html

Can you get the examples in the tutorials to work?


Regards,
Tim

-Original Message-
From: R-help  On Behalf Of dalfardi.s
Sent: Tuesday, March 15, 2022 4:15 PM
To: Bert Gunter 
Cc: R-help 
Subject: Re: [R] question

[External Email]

Hello Dear Bert Gunter

Thank you for your answer it means alot to me.

by the way i am not profesional in R and faced a problem and need to fix it as 
soon as possible and it is the reason i ask here but absolutely i try to 
improve my skills. but now i need help and said to my self maybe some one could 
help me and have similar experience.

Thanks for your answer

Best

On 2022-03-15 21:50, Bert Gunter wrote:


1. RStudio is not R; it is a separate for profit organization/company
that contributes free packages to R and also provides both free and
non-free R-oriented software. RStudio.com is their website (as you
know) and
https://urldefense.proofpoint.com/v2/url?u=https-3A__community.rstudio.com_-23=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=yodeWPdITg41plvXqsIKQE3kAZQK8RTKQZ9yhs8FfhsW6yZEEls9W8uAyttddQBY=vBlYcBj5nepe5Rcfkv1USa9sbPabHwSrJC3dzvUB_wY=
  is where you can post questions about *their* products.

2. HOWEVER... your query seems to be related to a special (not
standard) R package, not RStudio, specifically the 'flowr' package.
This general r-help list is not usually a good place to post queries
about such specific packages -- there are thousands of them! Maybe you
will get lucky and someone here will be able to help you.  But it is
recommended in the posting guide (linked below) that a better option
is to contact the package maintainer, which you can find via the:

maintainer("flowr")

command at the R console prompt.

Hope this helps.

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 Tue, Mar 15, 2022 at 10:52 AM dalfardi.s  wrote:
hello everyone

I faced an problem in Rstudio version 4.1.2 and while i am new in R
and Rstudio, but i search alot in internet and have thaught about the
reason of it but all i done didnt fix it.

I have a function of a package named priority flow as bellow:

RIVSMOOTH=RIVERSMOOTH(DEM=TRAVHS$DEM, DIRECTION=TRAVHS$DIRECTION,
MASK=FARWATERSHED.MASK,RIVER.SUMMARY=SUBBASIN$SUMMARY,RIVER.SEGMENTS=S
UBBASIN$SEGMENTS,BANK.EPSILON =0.01,RIVER.EPSILON =
0,D4=C(1,2,3,4),PRINTFLAG = T)

and all needed inputs are available but when i run it give me the
bellow
error:

[1] "No terminal river segments provided, not adjusting DEM"
Error in RiverSmooth(dem = travHS$dem, direction = travHS$direction,
mask = FARwatershed.mask, :
object 'active' not found

I dont know what active object is here? but all other objects are here
available.i also assighned this needed inputs in different object
forinstance AA=travHS$dem and then defined AA in the function but it
return error again.

this is summary of two dataframe that included needed data:

SUMMARY(SUBBASIN)
Length Class Mode
segments 4200 -none- numeric
subbasins 4200 -none- numeric
RiverMask 4200 -none- numeric
summary 98 -none- numeric SUMMARY(TRAVHS) Length Class Mode dem 4200
-none- numeric mask 4200 -none- numeric marked 4200 -none- numeric
step 4200 -none- numeric direction 4200 -none- numeric basins 4200
-none- numeric

this is part of my work and i really stumbled in it. Is there any one
could help me?

I really appreciate it.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
man_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAs
Rzsn7AkP-g=yodeWPdITg41plvXqsIKQE3kAZQK8RTKQZ9yhs8FfhsW6yZEEls9W8uAy

Re: [R] question

2022-03-15 Thread dalfardi.s
Dear Ivan Krylov 

Thanks for your answer, I have no clue and dont know what is active
object mean! 

Best 

On 2022-03-16 00:20, Ivan Krylov wrote:

> On Tue, 15 Mar 2022 20:57:03 +0330
> "dalfardi.s"  wrote:
> 
>> I have a function of a package named priority flow as bellow: 
>> 
>> RIVSMOOTH=RIVERSMOOTH(DEM=TRAVHS$DEM, DIRECTION=TRAVHS$DIRECTION,
>> MASK=FARWATERSHED.MASK,RIVER.SUMMARY=SUBBASIN$SUMMARY,RIVER.SEGMENTS=SUBBASIN$SEGMENTS,BANK.EPSILON
>> =0.01,RIVER.EPSILON = 0,D4=C(1,2,3,4),PRINTFLAG = T) 
>> 
>> and all needed inputs are available but when i run it give me the
>> bellow error: 
>> 
>> [1] "No terminal river segments provided, not adjusting DEM"
>> Error in RiverSmooth(dem = travHS$dem, direction = travHS$direction,
>> mask = FARwatershed.mask, :
>> object 'active' not found
> 
> This could be a bug in the RiverSmooth function. It could be trying to
> access a variable called "active" without defining it first. Where did
> you get this function? It's not anywhere on CRAN, as far as I can tell:
> https://search.r-project.org/?P=RiverSmooth=r-manuals=r-help=cran-help
> 
>> [[alternative HTML version deleted]]
> 
> As you can see in my quoted part and in the archive at
> , the
> code in your message as we see it is somehow in ALL CAPS. When you
> compose your messages to this list in HTML, your mailer tries to
> automatically create a plain text version, typically mangling it in
> process, while the list strips the HTML part for security reasons.
> Please compose your messages in plain text.
[[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] question

2022-03-15 Thread Ivan Krylov
On Tue, 15 Mar 2022 20:57:03 +0330
"dalfardi.s"  wrote:

> I have a function of a package named priority flow as bellow: 
> 
> RIVSMOOTH=RIVERSMOOTH(DEM=TRAVHS$DEM, DIRECTION=TRAVHS$DIRECTION,
> MASK=FARWATERSHED.MASK,RIVER.SUMMARY=SUBBASIN$SUMMARY,RIVER.SEGMENTS=SUBBASIN$SEGMENTS,BANK.EPSILON
> =0.01,RIVER.EPSILON = 0,D4=C(1,2,3,4),PRINTFLAG = T) 
> 
> and all needed inputs are available but when i run it give me the
> bellow error: 
> 
> [1] "No terminal river segments provided, not adjusting DEM"
> Error in RiverSmooth(dem = travHS$dem, direction = travHS$direction,
> mask = FARwatershed.mask, :
> object 'active' not found 

This could be a bug in the RiverSmooth function. It could be trying to
access a variable called "active" without defining it first. Where did
you get this function? It's not anywhere on CRAN, as far as I can tell:
https://search.r-project.org/?P=RiverSmooth=r-manuals=r-help=cran-help

>   [[alternative HTML version deleted]]

As you can see in my quoted part and in the archive at
, the
code in your message as we see it is somehow in ALL CAPS. When you
compose your messages to this list in HTML, your mailer tries to
automatically create a plain text version, typically mangling it in
process, while the list strips the HTML part for security reasons.
Please compose your messages in plain text. 

-- 
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] question

2022-03-15 Thread dalfardi.s
Hello Dear Bert Gunter 

Thank you for your answer it means alot to me. 

by the way i am not profesional in R and faced a problem and need to fix
it as soon as possible and it is the reason i ask here but absolutely i
try to improve my skills. but now i need help and said to my self maybe
some one could help me and have similar experience. 

Thanks for your answer 

Best 

On 2022-03-15 21:50, Bert Gunter wrote:

> 1. RStudio is not R; it is a separate for profit organization/company
> that contributes free packages to R and also provides both free and
> non-free R-oriented software. RStudio.com is their website (as you
> know) and https://community.rstudio.com/# is where you can post
> questions about *their* products.
> 
> 2. HOWEVER... your query seems to be related to a special (not
> standard) R package, not RStudio, specifically the 'flowr' package.
> This general r-help list is not usually a good place to post queries
> about such specific packages -- there are thousands of them! Maybe you
> will get lucky and someone here will be able to help you.  But it is
> recommended in the posting guide (linked below) that a better option
> is to contact the package maintainer, which you can find via the:
> 
> maintainer("flowr")
> 
> command at the R console prompt.
> 
> Hope this helps.
> 
> 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 Tue, Mar 15, 2022 at 10:52 AM dalfardi.s  wrote: 
> hello everyone
> 
> I faced an problem in Rstudio version 4.1.2 and while i am new in R and
> Rstudio, but i search alot in internet and have thaught about the reason
> of it but all i done didnt fix it.
> 
> I have a function of a package named priority flow as bellow:
> 
> RIVSMOOTH=RIVERSMOOTH(DEM=TRAVHS$DEM, DIRECTION=TRAVHS$DIRECTION,
> MASK=FARWATERSHED.MASK,RIVER.SUMMARY=SUBBASIN$SUMMARY,RIVER.SEGMENTS=SUBBASIN$SEGMENTS,BANK.EPSILON
> =0.01,RIVER.EPSILON = 0,D4=C(1,2,3,4),PRINTFLAG = T)
> 
> and all needed inputs are available but when i run it give me the bellow
> error:
> 
> [1] "No terminal river segments provided, not adjusting DEM"
> Error in RiverSmooth(dem = travHS$dem, direction = travHS$direction,
> mask = FARwatershed.mask, :
> object 'active' not found
> 
> I dont know what active object is here? but all other objects are here
> available.i also assighned this needed inputs in different object
> forinstance AA=travHS$dem and then defined AA in the function but it
> return error again.
> 
> this is summary of two dataframe that included needed data:
> 
> SUMMARY(SUBBASIN)
> Length Class Mode
> segments 4200 -none- numeric
> subbasins 4200 -none- numeric
> RiverMask 4200 -none- numeric
> summary 98 -none- numeric SUMMARY(TRAVHS) Length Class Mode
> dem 4200 -none- numeric
> mask 4200 -none- numeric
> marked 4200 -none- numeric
> step 4200 -none- numeric
> direction 4200 -none- numeric
> basins 4200 -none- numeric
> 
> this is part of my work and i really stumbled in it. Is there any one
> could help me?
> 
> I really appreciate it.
> [[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] question

2022-03-15 Thread Bert Gunter
1. RStudio is not R; it is a separate for profit organization/company
that contributes free packages to R and also provides both free and
non-free R-oriented software. RStudio.com is their website (as you
know) and https://community.rstudio.com/# is where you can post
questions about *their* products.

2. HOWEVER... your query seems to be related to a special (not
standard) R package, not RStudio, specifically the 'flowr' package.
This general r-help list is not usually a good place to post queries
about such specific packages -- there are thousands of them! Maybe you
will get lucky and someone here will be able to help you.  But it is
recommended in the posting guide (linked below) that a better option
is to contact the package maintainer, which you can find via the:

maintainer("flowr")

command at the R console prompt.

Hope this helps.

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 Tue, Mar 15, 2022 at 10:52 AM dalfardi.s  wrote:
>
> hello everyone
>
> I faced an problem in Rstudio version 4.1.2 and while i am new in R and
> Rstudio, but i search alot in internet and have thaught about the reason
> of it but all i done didnt fix it.
>
> I have a function of a package named priority flow as bellow:
>
> RIVSMOOTH=RIVERSMOOTH(DEM=TRAVHS$DEM, DIRECTION=TRAVHS$DIRECTION,
> MASK=FARWATERSHED.MASK,RIVER.SUMMARY=SUBBASIN$SUMMARY,RIVER.SEGMENTS=SUBBASIN$SEGMENTS,BANK.EPSILON
> =0.01,RIVER.EPSILON = 0,D4=C(1,2,3,4),PRINTFLAG = T)
>
> and all needed inputs are available but when i run it give me the bellow
> error:
>
> [1] "No terminal river segments provided, not adjusting DEM"
> Error in RiverSmooth(dem = travHS$dem, direction = travHS$direction,
> mask = FARwatershed.mask, :
> object 'active' not found
>
> I dont know what active object is here? but all other objects are here
> available.i also assighned this needed inputs in different object
> forinstance AA=travHS$dem and then defined AA in the function but it
> return error again.
>
> this is summary of two dataframe that included needed data:
>
> SUMMARY(SUBBASIN)
> Length Class Mode
> segments 4200 -none- numeric
> subbasins 4200 -none- numeric
> RiverMask 4200 -none- numeric
> summary 98 -none- numeric
> > SUMMARY(TRAVHS)
> Length Class Mode
> dem 4200 -none- numeric
> mask 4200 -none- numeric
> marked 4200 -none- numeric
> step 4200 -none- numeric
> direction 4200 -none- numeric
> basins 4200 -none- numeric
>
> this is part of my work and i really stumbled in it. Is there any one
> could help me?
>
> I really appreciate it.
> [[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] Question re predict.glm & predict.lm in STATS

2022-02-16 Thread Bert Gunter
Ok, I looked at what you sent me privately and saw your error. I'll
reproduce and fix it just using a trivial example with lm(), for which
the predict() semantics are identical. Before I do, I note that your
claim:

"The predict.glm documentation says a warning will be given if the
length of newdata is not the same as the training set used to create
the model." is **completely wrong**. What predict.glm (and predict.lm)
actually says is:

"Variables are first looked for in newdata and then searched for in
the usual way (which will include the environment of the formula used
in the fit). A warning will be given if the variables found are not of
the same length as those in newdata if it was supplied."

This is *NOT AT ALL* what you claimed. The key point that you are
missing is the phrase 'searched for in the usual way.'  The details
are a bit technical but in many ways fundamental. They can be found in
any good tutorial or perhaps by searching on "scoping in R" or
"function environments in R". It's about how R finds the objects that
variable names point to. Section 10.7 of the Intro.R manual shipped
with R (and available to you therefore) on "Scope" gives a brief
overview.

Anyway, here's the example that explains your error:

> train <- data.frame( y = runif(10), x = runif(10)) ## 10 rows
> test <- data.frame(x = runif(5))  ## 5 rows

## The following line is the source of your error
## You have specified your model incorrectly

> mdl <- lm(train$y ~train$x, data = train)

## The model is properly fitted because the variables in it, "train$y"
and "train$x" are found  "in the usual way" in the global environment,
the "enclosing environment" of the formula. (This is the technical
bit).  This leads to the sort of problem you saw with the predict
call:

> predict(mdl, newdat = test)
1 2 3 4 5 6 7
0.6089476 0.6385268 0.9075589 0.3403276 0.2709199 0.5876634 0.8668307
8 910
0.4689961 0.2571259 0.3281054
Warning message:
'newdata' had 5 rows but variables found have 10 rows

##Explanation: predict() is looking for a variable 'train$x', but test
only has a variable 'x', not 'train$x'. Since it doesn't find it, it
goes looking for 'train$x' "in the usual way" in the global
environment and finds it -- all 10 values as before. The prediction is
done using that data (the original fit) and the warning message is
emitted as per the documentation. Predicting without the newdat
argument does the same thing.

The correct syntax for fitting the original model is:
> mdl <- lm(y ~ x, data = train)

## and then the predict() call works fine using the newdat argument
(as 'x' is found there)
> predict(mdl, newdat = test)
1 2 3 4 5
0.5134899 0.4619013 0.2458162 0.0446871 0.3146897

All of this is documented and exampled in ?glm or even ?lm or in any
tutorials on their use. Please spend the time to study these
carefully. Trying to mimic examples you find, which seems to be what
you are doing, is rarely sufficient.

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 )

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, Feb 16, 2022 at 7:24 AM Bert Gunter  wrote:
>
> You should (almost) always reply to the list to maximize your opportunity for 
> useful help. Also, I don't do private consulting.
>
> See ?dput and ?str for ways to put code and data as plain text into a post 
> via copying and pasting from the R Console. You can also just type the code 
> directly, of course. The RHelp server will strip most attachments (I think 
> .png is OK for graphs, though. You can ask on list) if necessary). I don't 
> recall whether Word makes it through, but you really shouldn't need such 
> attachments anyway.
>
> 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, Feb 16, 2022 at 3:39 AM STEPHEN KAISLER  wrote:
>>
>> Bert:
>>
>> Please see the attached file which shows the approach I used.
>> Thanks for any assistance that you can offer.
>>
>> Steve Kaisler
>>
>> On 02/15/2022 4:05 PM Bert Gunter  wrote:
>>
>>
>> ??
>> Show us the error. Show us the call.
>>
>>
>> On Tue, Feb 15, 2022, 12:14 PM STEPHEN KAISLER  wrote:
>>
>> Folks:
>>
>> I haved glm/lm to build a model on a training set derived from auto_mpg data 
>> of 274 records (70% sampling)
>>
>> The test data set has 118 records.
>>
>> I am trying to use predict.glm or predict.lm to predict the values of mpg 
>> from disp, hp,weight, accel, and cyl.
>>
>> However I get the following message:
>>
>>
>> So, the resulting vector has 274 rows, when I believe it 

Re: [R] Question About lm()

2022-02-09 Thread PIKAL Petr
Hi

Is it enough for explanation?

https://stats.stackexchange.com/questions/26176/removal-of-statistically-sig
nificant-intercept-term-increases-r2-in-linear-mo

https://stackoverflow.com/questions/57415793/r-squared-in-lm-for-zero-interc
ept-model

Cheers
Petr
> -Original Message-
> From: R-help  On Behalf Of Bromaghin,
Jeffrey
> F via R-help
> Sent: Wednesday, February 9, 2022 11:01 PM
> To: r-help@r-project.org
> Subject: [R] Question About lm()
> 
> Hello,
> 
> I was constructing a simple linear model with one categorical (3-levels)
and one
> quantitative predictor variable for a colleague. I estimated model
parameters
> with and without an intercept, sometimes called reference cell coding and
cell
> means coding.
> 
> Model 1: yResp ~ -1 + xCat + xCont
> Model 2: yResp ~ xCat + xCont
> 
> These models are equivalent and the estimated coefficients come out fine,
but
> the R-squared and F statistics returned by summary() differ markedly. I
spent
> some time looking at the code for both lm() and summary.lm() but did not
find
> the source of the difference. aov() and anova() results also differ, so I
suspect
> the issue involves how the sums of squares are being computed. I've also
spent
> some time trying to search online for information on this, without
success. I
> haven't used lm() for quite a while, but my memory is that these
differences
> didn't occur in the distant past when I was teaching.
> 
> Thanks in advance for any insights you might have, Jeff
> 
> Jeffrey F. Bromaghin
> Research Statistician
> USGS Alaska Science Center
> 907-786-7086
> Jeffrey Bromaghin, Ph.D. | U.S. Geological Survey
> (usgs.gov)
> Ecosystems Analytics | U.S. Geological Survey
> (usgs.gov) center/science/ecosystems-analytics>
> 
> 
>   [[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] Question About lm()

2022-02-09 Thread Ivan Krylov
On Wed, 9 Feb 2022 22:00:40 +
"Bromaghin, Jeffrey F via R-help"  wrote:

> These models are equivalent and the estimated coefficients come out
> fine, but the R-squared and F statistics returned by summary() differ
> markedly.

Is the mean of yResp far from zero? Here's what summary.lm says about
that:

>> r.squared: R^2, the ‘fraction of variance explained by the model’,
>> 
>>   R^2 = 1 - Sum(R[i]^2) / Sum((y[i] - y*)^2),
>> 
>>where y* is the mean of y[i] if there is an intercept and
>>zero otherwise.

-- 
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] Question About lm()

2022-02-09 Thread David Winsemius
The models are NOT equivalent. Why would you’ll think they were?

— 
David

Sent from my iPhone

> On Feb 9, 2022, at 11:10 PM, Bromaghin, Jeffrey F via R-help 
>  wrote:
> 
> Hello,
> 
> I was constructing a simple linear model with one categorical (3-levels) and 
> one quantitative predictor variable for a colleague. I estimated model 
> parameters with and without an intercept, sometimes called reference cell 
> coding and cell means coding.
> 
> Model 1: yResp ~ -1 + xCat + xCont
> Model 2: yResp ~ xCat + xCont
> 
> These models are equivalent and the estimated coefficients come out fine, but 
> the R-squared and F statistics returned by summary() differ markedly. I spent 
> some time looking at the code for both lm() and summary.lm() but did not find 
> the source of the difference. aov() and anova() results also differ, so I 
> suspect the issue involves how the sums of squares are being computed. I've 
> also spent some time trying to search online for information on this, without 
> success. I haven't used lm() for quite a while, but my memory is that these 
> differences didn't occur in the distant past when I was teaching.
> 
> Thanks in advance for any insights you might have,
> Jeff
> 
> Jeffrey F. Bromaghin
> Research Statistician
> USGS Alaska Science Center
> 907-786-7086
> Jeffrey Bromaghin, Ph.D. | U.S. Geological Survey 
> (usgs.gov)
> Ecosystems Analytics | U.S. Geological Survey 
> (usgs.gov)
> 
> 
>[[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] question about error message: "Aesthetics must be either length 1 or the same as the data (226): y and colour"

2021-12-30 Thread Kai Yang via R-help
 Thank you all of your help. I'm new in R. I'll follow Bert's and your 
suggestions to post the question in another area in future. 
Happy New Year
Kai
On Thursday, December 30, 2021, 02:05:12 PM PST, CALUM POLWART 
 wrote:  
 
 You will get shot down in flames for posting this here. This list is for 
base-R and your query is tidyverse related so belongs on somewhere tidy 
specific...
But...
mpg[[y]]
Is returning the column mpg[[y]] unfiltered but displ is filtered.
It would be possible to use mpg[[y]][ mpg$hwy<35]
But I suspect there is a better solution involving . As a data source or 
perhaps select to pick only the data you want...

On 30 Dec 2021 18:42, Kai Yang via R-help  wrote:


Hi R team,
I can create a plot using the code below:
library(ggplot2)
library(dplyr)
mpg %>%
  filter(hwy <35) %>% 
  ggplot(aes(x = displ, y = hwy, color = cyl)) + 
  geom_point()
ggsave("c:/temp/hwy_cyl.jpg",width = 9, height = 6, dpi = 1200, units = "in")


I want to do the exactly same work using function. Below is the function I 
created:
plot1 <- function(y, c, f){
          mpg %>%
            filter(hwy <35) %>% 
            ggplot(aes(x = displ, y = mpg[[y]], color = mpg[[c]] )) + 
            geom_point()  
          ggsave(paste0("c:/temp/", f ,".jpg"), width = 9, height = 6, dpi = 
1200, units = "in")  
} 
plot1("hwy","cyl","hwy_cyl_f")

But I got error message when I run the code: "Aesthetics must be either length 
1 or the same as the data (226): y and colour" . I checked online about the 
message. My understanding is: I need to add "fill" in geom_point() statement. 
My questions are:
1. is it possible to make the code work without add 'fill' in geom_point() 
statement, but keep the color as same as the first code? 
2. if I must add 'fill' option in geom_point() statement, how to add them in? 
Should I add 266 colors name after 'fill'?
3. this is my first function in R, I'm sure there are many problems in the 
code. please point out my error in the code.


Thank you,
Kai

 [[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] question about error message: "Aesthetics must be either length 1 or the same as the data (226): y and colour"

2021-12-30 Thread Rui Barradas

Hello,

This seems like a repetition of a question you already asked and it has 
nothing to do with the fill aesthetic.


The error message is caused by the maps

y = mpg[[y]]
color = mpg[[c]]


First you filter the data keeping only a subset of the rows but now you 
are using the full data. This causes the error, the sizes of the 
filtered data and of the full data are not the same.



mpg %>% filter(hwy < 35) %>% dim()
#[1] 226  11

y <- "hwy"
length(mpg[[y]])
#[1] 234


If you pass a string as variable, you must ?get the variable value, like 
in the first function below, plot1.





plot1 <- function(y, c, f){
  mpg %>%
filter(hwy <35) %>%
ggplot(aes(x = displ, y = get(y), color = get(c))) +
geom_point()
  ggsave(paste0("~/tmp/", f ,".jpg"), width = 9, height = 6, dpi = 
1200, units = "in")

}
plot1("hwy","cyl","hwy_cyl_f")




Or you can use aes_string. But since the x axis is fixed, not variable, 
pay attention to not mix a variable (displ) with variables' names (hwy 
and cyl). So in the next function I use aes() in the initial call to 
ggplot and aes_string in the geom_point layer.





plot2 <- function(y, c, f){
  mpg %>%
filter(hwy <35) %>%
ggplot(aes(x = displ)) +
geom_point(aes_string(y = y, color = c))
  ggsave(paste0("~/tmp/", f ,".jpg"), width = 9, height = 6, dpi = 
1200, units = "in")

}
plot2("hwy","cyl","hwy_cyl_f2")



Hope this helps,

Rui Barradas

Às 18:42 de 30/12/21, Kai Yang via R-help escreveu:

Hi R team,
I can create a plot using the code below:
library(ggplot2)
library(dplyr)
mpg %>%
   filter(hwy <35) %>%
   ggplot(aes(x = displ, y = hwy, color = cyl)) +
   geom_point()
ggsave("c:/temp/hwy_cyl.jpg",width = 9, height = 6, dpi = 1200, units = "in")


I want to do the exactly same work using function. Below is the function I 
created:
plot1 <- function(y, c, f){
           mpg %>%
             filter(hwy <35) %>%
             ggplot(aes(x = displ, y = mpg[[y]], color = mpg[[c]] )) +
             geom_point()
           ggsave(paste0("c:/temp/", f ,".jpg"), width = 9, height = 6, dpi = 1200, units 
= "in")
}
plot1("hwy","cyl","hwy_cyl_f")

But I got error message when I run the code: "Aesthetics must be either length 1 or the same 
as the data (226): y and colour" . I checked online about the message. My understanding is: I 
need to add "fill" in geom_point() statement. My questions are:
1. is it possible to make the code work without add 'fill' in geom_point() 
statement, but keep the color as same as the first code?
2. if I must add 'fill' option in geom_point() statement, how to add them in? 
Should I add 266 colors name after 'fill'?
3. this is my first function in R, I'm sure there are many problems in the 
code. please point out my error in the code.


Thank you,
Kai

[[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] question about error message: "Aesthetics must be either length 1 or the same as the data (226): y and colour"

2021-12-30 Thread Bert Gunter
1. Please read and follow the Posting Guide linked below. Among other
things, it says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help."
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

"If the question relates to a contributed package [ggplot is such a
package] , e.g., one downloaded from CRAN, try contacting the package
maintainer first. You can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.

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 Thu, Dec 30, 2021 at 10:43 AM Kai Yang via R-help
 wrote:
>
> Hi R team,
> I can create a plot using the code below:
> library(ggplot2)
> library(dplyr)
> mpg %>%
>   filter(hwy <35) %>%
>   ggplot(aes(x = displ, y = hwy, color = cyl)) +
>   geom_point()
> ggsave("c:/temp/hwy_cyl.jpg",width = 9, height = 6, dpi = 1200, units = "in")
>
>
> I want to do the exactly same work using function. Below is the function I 
> created:
> plot1 <- function(y, c, f){
>   mpg %>%
> filter(hwy <35) %>%
> ggplot(aes(x = displ, y = mpg[[y]], color = mpg[[c]] )) +
> geom_point()
>   ggsave(paste0("c:/temp/", f ,".jpg"), width = 9, height = 6, dpi = 
> 1200, units = "in")
> }
> plot1("hwy","cyl","hwy_cyl_f")
>
> But I got error message when I run the code: "Aesthetics must be either 
> length 1 or the same as the data (226): y and colour" . I checked online 
> about the message. My understanding is: I need to add "fill" in geom_point() 
> statement. My questions are:
> 1. is it possible to make the code work without add 'fill' in geom_point() 
> statement, but keep the color as same as the first code?
> 2. if I must add 'fill' option in geom_point() statement, how to add them in? 
> Should I add 266 colors name after 'fill'?
> 3. this is my first function in R, I'm sure there are many problems in the 
> code. please point out my error in the code.
>
>
> Thank you,
> Kai
>
> [[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] question about for loop

2021-12-24 Thread Kai Yang via R-help
 Thanks Avi. This is a good idea. I'm learning how to create a function in R 
now and may have more questions for you. I really apricate all of your help. 
Wish you have a great holiday and happy new year !Kai
On Friday, December 24, 2021, 04:54:36 PM PST, Avi Gross via R-help 
 wrote:  
 
 Suggestion to consider another approach:

Once various errors are fixed, the program being done basically sounds like
you want to repeat a sequence of actions one per ROW of a data.frame. As it
happens, the action to perform is based on a second data.frame given to
ggplot, with parts dynamically inserted from the variables in one row.

So consider making a function with a name like graph_it() that does what you
want when passed three named arguments. I mean it takes arguments with names
like alpha, beta and gamma and then use the pmap() function (part of the
tidyverse unfortunately in the purr package) along with the function you
want:

Typing:

pmap(.l=mac2, .f=graph_it)

Will implicitly perform your functionality one row after another without an
explicit loop and often faster than nested loops would be. I have used the
technique to replace a deeply nested loop that generates all combinations of
multiple categorical variables (about a million) into a data.frame, then do
something with each one fairly efficiently.

If nothing else, it would make this problem a tad simpler by not needing
subscripts.

-Original Message-
From: R-help  On Behalf Of Andrew Simmons
Sent: Friday, December 24, 2021 5:37 PM
To: Kai Yang 
Cc: R-help Mailing List 
Subject: Re: [R] question about for loop

y, c, and f only exist in the context of mac2 If you want to use them,
you'll have to write mac2$y, mac2$c, or mac2$f (or the [[ versions
mac2[["y"]], mac2[["c"]], or mac2[["f"]]) Combining that with index i would
then look like mac2$y[[i]] or mac2[[i, "y"]]

Also, I think you want to use aes_string instead of aes (since you want
those expressions within aes to be evaluated) Something like this seems to
work for me:


`%>%` <- magrittr::`%>%`


writeLines(FILE <- tempfile(), text =
r"{y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2}")


mac2 <- readr::read_csv(FILE)
for (i in seq_len(nrow(mac2))) {
    ggplt <- ggplot2::mpg %>%
        dplyr::filter(hwy < 35) %>%
        ggplot2::ggplot(
            ggplot2::aes_string(
                x = "displ",
                y = mac2[[i, "y"]],
                color = mac2[[i, "c"]]
            )
        ) +
        ggplot2::geom_point() +
        ggplot2::ylab(mac2[[i, "y"]]) +
        ggplot2::guides(
            color = ggplot2::guide_legend(title = mac2[[i, "c"]])
        )
    ggplot2::ggsave(
        filename = tempfile(
            mac2[[i, "f"]],
            fileext = ".jpg"
        ),
        plot = ggplt,
        width = 9, height = 6, dpi = 1200
    )
}


unlink(FILE)


runs fine on my computer, but might look more like this for you:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
    ggplt <- mpg %>%
        filter(hwy < 35) %>%
        ggplot(
            aes_string(
                x = "displ",
                y = mac2[[i, "y"]],
                color = mac2[[i, "c"]]
            )
        ) +
        geom_point() +
        ylab(mac2[[i, "y"]]) +
        guides(
            color = guide_legend(title = mac2[[i, "c"]])
        )
    ggsave(
        filename = paste0("C:/temp/", mac2[[i, "f"]], ".jpg"),
        plot = ggplt,
        width = 9, height = 6, dpi = 1200
    )
}


try reading through aes and aes_string, and keep in mind that columns in
data frames aren't R variables (where they are in Excel). If you want to use
columns like they are variables, you can try using `with`. For example:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
    with(mac2[i, ], {
        ggplt <- mpg %>%
            filter(hwy < 35) %>%
            ggplot(
                aes_string(
                    x = "displ",
                    y = y,
                    color = c
                )
            ) +
            geom_point() +
            ylab(y) +
            guides(
                color = guide_legend(title = c)
            )
        ggsave(
            filename = paste0("C:/temp/", f, ".jpg"),
            plot = ggplt,
            width = 9, height = 6, dpi = 1200
        )
    })
}




On Fri, Dec 24, 2021 at 4:48 PM Kai Yang via R-help 
wrote:

> Hello Team,
> I create a csv file (mac2) to save parameter values. the file looks like:
>
> y,c,f
> hwy,cyl,hwy_cyl2
> cty,class,cty_class2
>
&g

Re: [R] question about for loop

2021-12-24 Thread Avi Gross via R-help
Suggestion to consider another approach:

Once various errors are fixed, the program being done basically sounds like
you want to repeat a sequence of actions one per ROW of a data.frame. As it
happens, the action to perform is based on a second data.frame given to
ggplot, with parts dynamically inserted from the variables in one row.

So consider making a function with a name like graph_it() that does what you
want when passed three named arguments. I mean it takes arguments with names
like alpha, beta and gamma and then use the pmap() function (part of the
tidyverse unfortunately in the purr package) along with the function you
want:

Typing:

pmap(.l=mac2, .f=graph_it)

Will implicitly perform your functionality one row after another without an
explicit loop and often faster than nested loops would be. I have used the
technique to replace a deeply nested loop that generates all combinations of
multiple categorical variables (about a million) into a data.frame, then do
something with each one fairly efficiently.

If nothing else, it would make this problem a tad simpler by not needing
subscripts.

-Original Message-
From: R-help  On Behalf Of Andrew Simmons
Sent: Friday, December 24, 2021 5:37 PM
To: Kai Yang 
Cc: R-help Mailing List 
Subject: Re: [R] question about for loop

y, c, and f only exist in the context of mac2 If you want to use them,
you'll have to write mac2$y, mac2$c, or mac2$f (or the [[ versions
mac2[["y"]], mac2[["c"]], or mac2[["f"]]) Combining that with index i would
then look like mac2$y[[i]] or mac2[[i, "y"]]

Also, I think you want to use aes_string instead of aes (since you want
those expressions within aes to be evaluated) Something like this seems to
work for me:


`%>%` <- magrittr::`%>%`


writeLines(FILE <- tempfile(), text =
r"{y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2}")


mac2 <- readr::read_csv(FILE)
for (i in seq_len(nrow(mac2))) {
ggplt <- ggplot2::mpg %>%
dplyr::filter(hwy < 35) %>%
ggplot2::ggplot(
ggplot2::aes_string(
x = "displ",
y = mac2[[i, "y"]],
color = mac2[[i, "c"]]
)
) +
ggplot2::geom_point() +
ggplot2::ylab(mac2[[i, "y"]]) +
ggplot2::guides(
color = ggplot2::guide_legend(title = mac2[[i, "c"]])
)
ggplot2::ggsave(
filename = tempfile(
mac2[[i, "f"]],
fileext = ".jpg"
),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
}


unlink(FILE)


runs fine on my computer, but might look more like this for you:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
ggplt <- mpg %>%
filter(hwy < 35) %>%
ggplot(
aes_string(
x = "displ",
y = mac2[[i, "y"]],
color = mac2[[i, "c"]]
)
) +
geom_point() +
ylab(mac2[[i, "y"]]) +
guides(
color = guide_legend(title = mac2[[i, "c"]])
)
ggsave(
filename = paste0("C:/temp/", mac2[[i, "f"]], ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
}


try reading through aes and aes_string, and keep in mind that columns in
data frames aren't R variables (where they are in Excel). If you want to use
columns like they are variables, you can try using `with`. For example:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
with(mac2[i, ], {
ggplt <- mpg %>%
filter(hwy < 35) %>%
ggplot(
aes_string(
x = "displ",
y = y,
color = c
)
) +
geom_point() +
ylab(y) +
guides(
color = guide_legend(title = c)
)
ggsave(
filename = paste0("C:/temp/", f, ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
})
}




On Fri, Dec 24, 2021 at 4:48 PM Kai Yang via R-help 
wrote:

> Hello Team,
> I create a csv file (mac2) to save parameter values. the file looks like:
>
> y,c,f
> hwy,cyl,hwy_cyl2
> cty,class,cty_class2
>
> Then I load the file into R and apply the parameters y, c, f in for 
> loop, see my code below:
> library(ggplot2)
> library(tidyverse)
> library(readr)
> mac2 <- read_csv("C:/temp/mac2.csv")
> View(mac2)
> for (i in seq(nrow(mac2))){
>   mpg %>%
>   

Re: [R] question about for loop

2021-12-24 Thread Kai Yang via R-help
 Thanks Andrew. This is super helpful. --- Kai
On Friday, December 24, 2021, 02:37:14 PM PST, Andrew Simmons 
 wrote:  
 
 y, c, and f only exist in the context of mac2If you want to use them, you'll 
have to write mac2$y, mac2$c, or mac2$f (or the [[ versions mac2[["y"]], 
mac2[["c"]], or mac2[["f"]])Combining that with index i would then look like 
mac2$y[[i]] or mac2[[i, "y"]]
Also, I think you want to use aes_string instead of aes (since you want those 
expressions within aes to be evaluated)Something like this seems to work for me:

`%>%` <- magrittr::`%>%`


writeLines(FILE <- tempfile(), text =
r"{y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2}")


mac2 <- readr::read_csv(FILE)
for (i in seq_len(nrow(mac2))) {
    ggplt <- ggplot2::mpg %>%
        dplyr::filter(hwy < 35) %>%
        ggplot2::ggplot(
            ggplot2::aes_string(
                x = "displ",
                y = mac2[[i, "y"]],
                color = mac2[[i, "c"]]
            )
        ) +
        ggplot2::geom_point() +
        ggplot2::ylab(mac2[[i, "y"]]) +
        ggplot2::guides(
            color = ggplot2::guide_legend(title = mac2[[i, "c"]])
        )
    ggplot2::ggsave(
        filename = tempfile(
            mac2[[i, "f"]],
            fileext = ".jpg"
        ),
        plot = ggplt,
        width = 9, height = 6, dpi = 1200
    )
}


unlink(FILE)


runs fine on my computer, but might look more like this for you:

library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
    ggplt <- mpg %>%
        filter(hwy < 35) %>%
        ggplot(
            aes_string(
                x = "displ",
                y = mac2[[i, "y"]],
                color = mac2[[i, "c"]]
            )
        ) +
        geom_point() +
        ylab(mac2[[i, "y"]]) +
        guides(
            color = guide_legend(title = mac2[[i, "c"]])
        )
    ggsave(
        filename = paste0("C:/temp/", mac2[[i, "f"]], ".jpg"),
        plot = ggplt,
        width = 9, height = 6, dpi = 1200
    )
}


try reading through aes and aes_string, and keep in mind that columns in data 
frames aren't R variables (where they are in Excel). If you want to use columns 
like they are variables, you can try using `with`. For example:

library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
    with(mac2[i, ], {
        ggplt <- mpg %>%
            filter(hwy < 35) %>%
            ggplot(
                aes_string(
                    x = "displ",
                    y = y,
                    color = c
                )
            ) +
            geom_point() +
            ylab(y) +
            guides(
                color = guide_legend(title = c)
            )
        ggsave(
            filename = paste0("C:/temp/", f, ".jpg"),
            plot = ggplt,
            width = 9, height = 6, dpi = 1200
        )
    })
}




On Fri, Dec 24, 2021 at 4:48 PM Kai Yang via R-help  
wrote:

Hello Team,
I create a csv file (mac2) to save parameter values. the file looks like:

y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2

Then I load the file into R and apply the parameters y, c, f in for loop, see 
my code below:
library(ggplot2)
library(tidyverse)
library(readr)
mac2 <- read_csv("C:/temp/mac2.csv")
View(mac2)
for (i in seq(nrow(mac2))){
  mpg %>%
    filter(hwy <35) %>% 
    ggplot(aes(x = displ, y = get(y[i]), color = get(c[i]) )) + 
    geom_point()+
    ylab(y[i]) +                              
    guides(color = guide_legend(title = c[i]))    
ggsave(paste0("c:/temp/",f[i],".jpg"),width = 9, height = 6, dpi = 1200, units 
= "in")
}

but I got an error message: "Error in dots_list(..., title = title, subtitle = 
subtitle, caption = caption,  :  object 'y' not found"
Does anyone know how to fix the problem?
Thanks,
Kai


        [[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] question about for loop

2021-12-24 Thread Andrew Simmons
y, c, and f only exist in the context of mac2
If you want to use them, you'll have to write mac2$y, mac2$c, or mac2$f (or
the [[ versions mac2[["y"]], mac2[["c"]], or mac2[["f"]])
Combining that with index i would then look like mac2$y[[i]] or mac2[[i,
"y"]]

Also, I think you want to use aes_string instead of aes (since you want
those expressions within aes to be evaluated)
Something like this seems to work for me:


`%>%` <- magrittr::`%>%`


writeLines(FILE <- tempfile(), text =
r"{y,c,f
hwy,cyl,hwy_cyl2
cty,class,cty_class2}")


mac2 <- readr::read_csv(FILE)
for (i in seq_len(nrow(mac2))) {
ggplt <- ggplot2::mpg %>%
dplyr::filter(hwy < 35) %>%
ggplot2::ggplot(
ggplot2::aes_string(
x = "displ",
y = mac2[[i, "y"]],
color = mac2[[i, "c"]]
)
) +
ggplot2::geom_point() +
ggplot2::ylab(mac2[[i, "y"]]) +
ggplot2::guides(
color = ggplot2::guide_legend(title = mac2[[i, "c"]])
)
ggplot2::ggsave(
filename = tempfile(
mac2[[i, "f"]],
fileext = ".jpg"
),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
}


unlink(FILE)


runs fine on my computer, but might look more like this for you:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
ggplt <- mpg %>%
filter(hwy < 35) %>%
ggplot(
aes_string(
x = "displ",
y = mac2[[i, "y"]],
color = mac2[[i, "c"]]
)
) +
geom_point() +
ylab(mac2[[i, "y"]]) +
guides(
color = guide_legend(title = mac2[[i, "c"]])
)
ggsave(
filename = paste0("C:/temp/", mac2[[i, "f"]], ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
}


try reading through aes and aes_string, and keep in mind that columns in
data frames aren't R variables (where they are in Excel). If you want to
use columns like they are variables, you can try using `with`. For example:


library(magrittr)
library(ggplot2)
library(dplyr)
library(readr)


mac2 <- read_csv("C:/temp/mac2.csv")
for (i in seq_len(nrow(mac2))) {
with(mac2[i, ], {
ggplt <- mpg %>%
filter(hwy < 35) %>%
ggplot(
aes_string(
x = "displ",
y = y,
color = c
)
) +
geom_point() +
ylab(y) +
guides(
color = guide_legend(title = c)
)
ggsave(
filename = paste0("C:/temp/", f, ".jpg"),
plot = ggplt,
width = 9, height = 6, dpi = 1200
)
})
}




On Fri, Dec 24, 2021 at 4:48 PM Kai Yang via R-help 
wrote:

> Hello Team,
> I create a csv file (mac2) to save parameter values. the file looks like:
>
> y,c,f
> hwy,cyl,hwy_cyl2
> cty,class,cty_class2
>
> Then I load the file into R and apply the parameters y, c, f in for loop,
> see my code below:
> library(ggplot2)
> library(tidyverse)
> library(readr)
> mac2 <- read_csv("C:/temp/mac2.csv")
> View(mac2)
> for (i in seq(nrow(mac2))){
>   mpg %>%
> filter(hwy <35) %>%
> ggplot(aes(x = displ, y = get(y[i]), color = get(c[i]) )) +
> geom_point()+
> ylab(y[i]) +
> guides(color = guide_legend(title = c[i]))
> ggsave(paste0("c:/temp/",f[i],".jpg"),width = 9, height = 6, dpi = 1200,
> units = "in")
> }
>
> but I got an error message: "Error in dots_list(..., title = title,
> subtitle = subtitle, caption = caption,  :  object 'y' not found"
> Does anyone know how to fix the problem?
> Thanks,
> Kai
>
>
> [[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] Question about Rfast colMins and colMaxs

2021-12-03 Thread Stephen H. Dawson, DSL via R-help

Thanks, Richard.

I am researching other library options for data inspection. I have many 
csv files I am reviewing with different column names and data types. 
Flexibility of a quick review of max and min is quite valuable at this 
juncture.


I will implement your code recommendation next week and see how it performs.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 12/2/21 11:06 PM, Richard O'Keefe wrote:

What puzzles me is why you are not just using
lapply(some.data.frame, min)
lapply(some.data.frame, max)
or as.vector(lapply(...))
Why go to another package for this?
Is it the indices you want?

col.min.indices <- function (some.data.frame) {
    v <- sapply(some.data.frame, function (column)
which(column == min(column))[1])
    names(v) <- colnames(some.data.frame)
    v
}


On Wed, 1 Dec 2021 at 07:55, Stephen H. Dawson, DSL via R-help 
mailto:r-help@r-project.org>> wrote:


Hi,


I am working to understand the Rfast functions of colMins and
colMaxs. I
worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html


https://cran.r-project.org/web/packages/Rfast/Rfast.pdf


My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF
saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is
looking
for a matrix but finds a dataframe.

 > colMaxs(Data)
Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].
 > colMins(Data, na.rm = TRUE)
Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)
 > colMins(Data, value = FALSE, parallel = FALSE)
Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it
can be
accessed by colMaxs and colMins, please?


Thanks,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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.



__
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] Question about Rfast colMins and colMaxs

2021-12-02 Thread Richard O'Keefe
What puzzles me is why you are not just using
lapply(some.data.frame, min)
lapply(some.data.frame, max)
or as.vector(lapply(...))
Why go to another package for this?
Is it the indices you want?

col.min.indices <- function (some.data.frame) {
v <- sapply(some.data.frame, function (column)
   which(column == min(column))[1])
names(v) <- colnames(some.data.frame)
v
}


On Wed, 1 Dec 2021 at 07:55, Stephen H. Dawson, DSL via R-help <
r-help@r-project.org> wrote:

> Hi,
>
>
> I am working to understand the Rfast functions of colMins and colMaxs. I
> worked through the example listed on page 54 of the PDF.
>
> https://cran.r-project.org/web/packages/Rfast/index.html
>
> https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
>
> My data is in a CSV file. So, I bring it into R Studio using:
> Data <- read.csv("./input/DataSet05.csv", header=T)
>
> However, I read the instructions listed on page 54 of the PDF saying I
> need to bring data into R using a matrix. I think read.csv brings the
> data in as a dataframe. I think colMins is failing because it is looking
> for a matrix but finds a dataframe.
>
>  > colMaxs(Data)
> Error in colMaxs(Data) :
>Not compatible with requested type: [type=list; target=double].
>  > colMins(Data, na.rm = TRUE)
> Error in colMins(Data, na.rm = TRUE) :
>unused argument (na.rm = TRUE)
>  > colMins(Data, value = FALSE, parallel = FALSE)
> Error in colMins(Data, value = FALSE, parallel = FALSE) :
>Not compatible with requested type: [type=list; target=double].
>
> QUESTION
> What is the best practice to bring a csv file into R Studio so it can be
> accessed by colMaxs and colMins, please?
>
>
> Thanks,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.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.
>

[[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] Question about Rfast colMins and colMaxs

2021-12-02 Thread Stephen H. Dawson, DSL via R-help
he purpose here is not that broad.

But since I use some packages like the tidyverse extensively, and I am far

>from alone, I wonder if someday the powers that be realize it is a losing

battle to exclude at least some of it. It would be so nice not having to
include a long list of packages for some programs or somehow arrange that
people using something you shared had installed and loaded them. But there
are too many packages out there of varying quality and usefulness and
popularity with more every day being added. Worse, many are somewhat
incompatible such as having functions with the same names that hide earlier
ones loaded.

Base R doe come with functions like colSums and colMeans and similar row
functions. But as mentioned, a data.frame is a list of vectors and R
supports certain functional programming constructs over lists using things
like:

lapply(df, min)
sapply(df, min)

And actually quite a few ways depending on what info you want back and
whether you insist it be returned as a list or vector or other things . You
can even supply additional arguments that might be needed such as if you
want to ignore any NA values,

lapply(df, min, na.rm=TRUE

The package you looked at it is trying to be fast and uses what looks like
compiled external code but so does lapply.

If this is too bothersome for you, consider making a one-liner function like
this:

mycolMins <- function(df, ...) lapply(df, min, ...)

Once defined, you can use that just fine and not think about it again and I
note this answer (like others) is offering you something in base R that
works fine on data.frames and the like.

You can extend to many similar ideas like this one that calulates the min
unless you over-ride it with max or mean or sd or a bizarre function like
`[` so a call to:

mycolCalc(df, `[`, 3)

Will return exactly the third items in each row!

I find it to be very common for someone these days to do a quick search for
a way to do something in a language like R and not really look to see if it
is a standard way or something special/ Matrices in R are not quite the same
as some other objects like a data.frame or tibble and a package written to
be used on one may (or may not) happen to work with another. Some packages
are carefully written to try to detect what kind of object it gets and when
possible convert it to another. The "apply" function is meant for matrices
but if it sees something else it looks ta the dimensionality and tries to
coerce it with as.matrix or as.array first. As others have noted, this mean
a data.frame containing non-numeric parts may fail or should have any other
columns hidden/removed as in this df that has some non-numeric fields:


df

i   s   f b i2
1 1   hello 1.2  TRUE  5
2 2   there 2.3 FALSE  4
3 3 goodbye 3.4  TRUE  3

So a bit more complex one-liner removes any non-numeric columns like this:


mycolMins(df[, sapply(df, is.numeric)])

$i
[1] 1

$f
[1] 1.2

$i2
[1] 3

Clearly converting that to a matrix while whole would result in everything
being converted to character and a minimum may be elusive.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Tuesday, November 30, 2021 5:37 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am not
clear on a standard versus non-standard list. I will look into this aspect
and see what I can learn going forward.


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:26 PM, Bert Gunter wrote:

... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the maintainer and ask him/her what they
think the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

https://cran.r-project.org/web/packages/Rfast/index.html

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse
consists of all *non*-standard contributed packages, about which the PG

says:

"For questions about functions in standard packages distributed with
R (see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of cu

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Bert Gunter
ons about all kinds of
> >add-on packages and in particular, lots of the ones in the tidyverse.
> >Clearly the purpose here is not that broad.
> >
> >But since I use some packages like the tidyverse extensively, and I am far
> >from alone, I wonder if someday the powers that be realize it is a losing
> >battle to exclude at least some of it. It would be so nice not having to
> >include a long list of packages for some programs or somehow arrange that
> >people using something you shared had installed and loaded them. But there
> >are too many packages out there of varying quality and usefulness and
> >popularity with more every day being added. Worse, many are somewhat
> >incompatible such as having functions with the same names that hide earlier
> >ones loaded.
> >
> >Base R doe come with functions like colSums and colMeans and similar row
> >functions. But as mentioned, a data.frame is a list of vectors and R
> >supports certain functional programming constructs over lists using things
> >like:
> >
> >lapply(df, min)
> >sapply(df, min)
> >
> >And actually quite a few ways depending on what info you want back and
> >whether you insist it be returned as a list or vector or other things . You
> >can even supply additional arguments that might be needed such as if you
> >want to ignore any NA values,
> >
> >lapply(df, min, na.rm=TRUE
> >
> >The package you looked at it is trying to be fast and uses what looks like
> >compiled external code but so does lapply.
> >
> >If this is too bothersome for you, consider making a one-liner function like
> >this:
> >
> >mycolMins <- function(df, ...) lapply(df, min, ...)
> >
> >Once defined, you can use that just fine and not think about it again and I
> >note this answer (like others) is offering you something in base R that
> >works fine on data.frames and the like.
> >
> >You can extend to many similar ideas like this one that calulates the min
> >unless you over-ride it with max or mean or sd or a bizarre function like
> >`[` so a call to:
> >
> >mycolCalc(df, `[`, 3)
> >
> >Will return exactly the third items in each row!
> >
> >I find it to be very common for someone these days to do a quick search for
> >a way to do something in a language like R and not really look to see if it
> >is a standard way or something special/ Matrices in R are not quite the same
> >as some other objects like a data.frame or tibble and a package written to
> >be used on one may (or may not) happen to work with another. Some packages
> >are carefully written to try to detect what kind of object it gets and when
> >possible convert it to another. The "apply" function is meant for matrices
> >but if it sees something else it looks ta the dimensionality and tries to
> >coerce it with as.matrix or as.array first. As others have noted, this mean
> >a data.frame containing non-numeric parts may fail or should have any other
> >columns hidden/removed as in this df that has some non-numeric fields:
> >
> >> df
> >i   s   f b i2
> >1 1   hello 1.2  TRUE  5
> >2 2   there 2.3 FALSE  4
> >3 3 goodbye 3.4  TRUE  3
> >
> >So a bit more complex one-liner removes any non-numeric columns like this:
> >
> >> mycolMins(df[, sapply(df, is.numeric)])
> >$i
> >[1] 1
> >
> >$f
> >[1] 1.2
> >
> >$i2
> >[1] 3
> >
> >Clearly converting that to a matrix while whole would result in everything
> >being converted to character and a minimum may be elusive.
> >
> >-Original Message-
> >From: R-help  On Behalf Of Stephen H. Dawson,
> >DSL via R-help
> >Sent: Tuesday, November 30, 2021 5:37 PM
> >To: Bert Gunter 
> >Cc: r-help@r-project.org
> >Subject: Re: [R] Question about Rfast colMins and colMaxs
> >
> >Oh, you are segmenting standard R from the rest of R.
> >
> >Well, that part did not come across to me in your original reply. I am not
> >clear on a standard versus non-standard list. I will look into this aspect
> >and see what I can learn going forward.
> >
> >
> >Thanks,
> >*Stephen Dawson, DSL*
> >/Executive Strategy Consultant/
> >Business & Technology
> >+1 (865) 804-3454
> >http://www.shdawson.com <http://www.shdawson.com>
> >
> >
> >On 11/30/21 5:26 PM, Bert Gunter wrote:
> >> ... but Rfast is *not* a "standard" package, as the rest of the PG
> >> excerpt says. So contact the maintainer and ask him/her what they
> 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Thanks, Avi.

Yes, loading packages by library command is necessary to access a 
function not resident in the standard R code.


The data set I am reviewing has column names changing. The thought is to 
do a review of max and min for whatever the column names happen to be 
for the data input I am reviewing.



*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 10:42 PM, Avi Gross via R-help wrote:

Stephen,

Although what is in the STANDARD R distribution can vary several ways, in
general, if you need to add a line like:

library(something)
or
require(something)

and your code does not work unless you have done that, then you can imagine
it is not sort of built in to R as it starts.

Having said that, tons of exceptions may exist that cause R to load in
things on your machine for everyone or just for you without you having to
notice.

I think this forum lately has been deluged with questions about all kinds of
add-on packages and in particular, lots of the ones in the tidyverse.
Clearly the purpose here is not that broad.

But since I use some packages like the tidyverse extensively, and I am far
from alone, I wonder if someday the powers that be realize it is a losing
battle to exclude at least some of it. It would be so nice not having to
include a long list of packages for some programs or somehow arrange that
people using something you shared had installed and loaded them. But there
are too many packages out there of varying quality and usefulness and
popularity with more every day being added. Worse, many are somewhat
incompatible such as having functions with the same names that hide earlier
ones loaded.

Base R doe come with functions like colSums and colMeans and similar row
functions. But as mentioned, a data.frame is a list of vectors and R
supports certain functional programming constructs over lists using things
like:

lapply(df, min)
sapply(df, min)

And actually quite a few ways depending on what info you want back and
whether you insist it be returned as a list or vector or other things . You
can even supply additional arguments that might be needed such as if you
want to ignore any NA values,

lapply(df, min, na.rm=TRUE

The package you looked at it is trying to be fast and uses what looks like
compiled external code but so does lapply.

If this is too bothersome for you, consider making a one-liner function like
this:

mycolMins <- function(df, ...) lapply(df, min, ...)

Once defined, you can use that just fine and not think about it again and I
note this answer (like others) is offering you something in base R that
works fine on data.frames and the like.

You can extend to many similar ideas like this one that calulates the min
unless you over-ride it with max or mean or sd or a bizarre function like
`[` so a call to:

mycolCalc(df, `[`, 3)

Will return exactly the third items in each row!

I find it to be very common for someone these days to do a quick search for
a way to do something in a language like R and not really look to see if it
is a standard way or something special/ Matrices in R are not quite the same
as some other objects like a data.frame or tibble and a package written to
be used on one may (or may not) happen to work with another. Some packages
are carefully written to try to detect what kind of object it gets and when
possible convert it to another. The "apply" function is meant for matrices
but if it sees something else it looks ta the dimensionality and tries to
coerce it with as.matrix or as.array first. As others have noted, this mean
a data.frame containing non-numeric parts may fail or should have any other
columns hidden/removed as in this df that has some non-numeric fields:


df

i   s   f b i2
1 1   hello 1.2  TRUE  5
2 2   there 2.3 FALSE  4
3 3 goodbye 3.4  TRUE  3

So a bit more complex one-liner removes any non-numeric columns like this:


mycolMins(df[, sapply(df, is.numeric)])

$i
[1] 1

$f
[1] 1.2

$i2
[1] 3

Clearly converting that to a matrix while whole would result in everything
being converted to character and a minimum may be elusive.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Tuesday, November 30, 2021 5:37 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am not
clear on a standard versus non-standard list. I will look into this aspect
and see what I can learn going forward.


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:26 PM, Bert Gunter wrote:

... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Thank you, Petr, for the kind explanation.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 12/1/21 11:19 AM, PIKAL Petr wrote:

Hi.

It is always worth to consult excellent R help.

max and min return the maximum or minimum of all the values present in their 
arguments, as integer if all are logical or integer, as double if all are 
numeric, and character otherwise.

Character versions are sorted lexicographically, and this depends on the collating sequence of the 
locale in use: the help for ‘Comparison’ gives details. The max/min of an empty character vector is 
defined to be character NA. (One could argue that as "" is the smallest character 
element, the maximum should be "", but there is no obvious candidate for the minimum.)

Cheers
Petr


-Original Message-
From: R-help  On Behalf Of Stephen H.
Dawson, DSL via R-help
Sent: Wednesday, December 1, 2021 5:11 PM
To: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Jeff,

Can you use max and min evaluations on any other data type then numeric?
If so, how do you evaluate max or min of text content? String length?
Ascii values of text characters?


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:

Well, no it is not. The email list stripped off the attachment.

The data is numeric, happens to be all whole numbers.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 3:29 PM, Jeff Newmiller wrote:

I don't know anything about this package, but read.csv returns a
data frame. How you go about forming a matrix using that data frame
depends what is in it. If it is all numeric then as.matrix may be
all you need.

Half of any R data analysis is data... and the details are almost
always crucial. Since you have told us nothing useful about the
data, it is up to you to inspect your data and figure out what to do
with it.

On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via
R-help"  wrote:

Hi,


I am working to understand the Rfast functions of colMins and
colMaxs. I worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF
saying I need to bring data into R using a matrix. I think read.csv
brings the data in as a dataframe. I think colMins is failing
because it is looking for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it
can be accessed by colMaxs and colMins, please?


Thanks,

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


__
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] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help
 extend to many similar ideas like this one that calulates the min
unless you over-ride it with max or mean or sd or a bizarre function like
`[` so a call to:

mycolCalc(df, `[`, 3)

Will return exactly the third items in each row!

I find it to be very common for someone these days to do a quick search for
a way to do something in a language like R and not really look to see if it
is a standard way or something special/ Matrices in R are not quite the same
as some other objects like a data.frame or tibble and a package written to
be used on one may (or may not) happen to work with another. Some packages
are carefully written to try to detect what kind of object it gets and when
possible convert it to another. The "apply" function is meant for matrices
but if it sees something else it looks ta the dimensionality and tries to
coerce it with as.matrix or as.array first. As others have noted, this mean
a data.frame containing non-numeric parts may fail or should have any other
columns hidden/removed as in this df that has some non-numeric fields:


df

i   s   f b i2
1 1   hello 1.2  TRUE  5
2 2   there 2.3 FALSE  4
3 3 goodbye 3.4  TRUE  3

So a bit more complex one-liner removes any non-numeric columns like this:


mycolMins(df[, sapply(df, is.numeric)])

$i
[1] 1

$f
[1] 1.2

$i2
[1] 3

Clearly converting that to a matrix while whole would result in everything
being converted to character and a minimum may be elusive.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Tuesday, November 30, 2021 5:37 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am not
clear on a standard versus non-standard list. I will look into this aspect
and see what I can learn going forward.


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:26 PM, Bert Gunter wrote:

... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the maintainer and ask him/her what they
think the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

https://cran.r-project.org/web/packages/Rfast/index.html

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse
consists of all *non*-standard contributed packages, about which the PG

says:

"For questions about functions in standard packages distributed with
R (see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first.
You can also use find("functionname") and
packageDescription("packagename") to find this information. Only
send such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to
bug reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be

posted.



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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
 wrote:

Hi,


I am working to understand the Rfast functions of colMins and
colMaxs. I worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF
saying I need to bring data into R using a matrix. I think read.csv
brings the data in as a dataframe. I think colMins is failing
because it is looking for a matrix but finds a dataframe.

> colMaxs(Data)
Error in colMaxs(Data) :
  Not compatible with requested type: [type=list; target=dou

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Jeff Newmiller
calulates the min
>unless you over-ride it with max or mean or sd or a bizarre function like
>`[` so a call to:
>
>mycolCalc(df, `[`, 3)
>
>Will return exactly the third items in each row!
>
>I find it to be very common for someone these days to do a quick search for
>a way to do something in a language like R and not really look to see if it
>is a standard way or something special/ Matrices in R are not quite the same
>as some other objects like a data.frame or tibble and a package written to
>be used on one may (or may not) happen to work with another. Some packages
>are carefully written to try to detect what kind of object it gets and when
>possible convert it to another. The "apply" function is meant for matrices
>but if it sees something else it looks ta the dimensionality and tries to
>coerce it with as.matrix or as.array first. As others have noted, this mean
>a data.frame containing non-numeric parts may fail or should have any other
>columns hidden/removed as in this df that has some non-numeric fields:
>
>> df
>i   s   f b i2
>1 1   hello 1.2  TRUE  5
>2 2   there 2.3 FALSE  4
>3 3 goodbye 3.4  TRUE  3
>
>So a bit more complex one-liner removes any non-numeric columns like this:
>
>> mycolMins(df[, sapply(df, is.numeric)])
>$i
>[1] 1
>
>$f
>[1] 1.2
>
>$i2
>[1] 3
>
>Clearly converting that to a matrix while whole would result in everything
>being converted to character and a minimum may be elusive.
>
>-Original Message-
>From: R-help  On Behalf Of Stephen H. Dawson,
>DSL via R-help
>Sent: Tuesday, November 30, 2021 5:37 PM
>To: Bert Gunter 
>Cc: r-help@r-project.org
>Subject: Re: [R] Question about Rfast colMins and colMaxs
>
>Oh, you are segmenting standard R from the rest of R.
>
>Well, that part did not come across to me in your original reply. I am not
>clear on a standard versus non-standard list. I will look into this aspect
>and see what I can learn going forward.
>
>
>Thanks,
>*Stephen Dawson, DSL*
>/Executive Strategy Consultant/
>Business & Technology
>+1 (865) 804-3454
>http://www.shdawson.com <http://www.shdawson.com>
>
>
>On 11/30/21 5:26 PM, Bert Gunter wrote:
>> ... but Rfast is *not* a "standard" package, as the rest of the PG 
>> excerpt says. So contact the maintainer and ask him/her what they 
>> think the best practice should be for their package. As has been 
>> pointed out already, it appears to differ from the usual "read it in 
>> as a data frame" procedure.
>>
>> Bert
>>
>> On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL 
>>  wrote:
>>> Right, R Studio is not R.
>>>
>>> However, the Rfast package is part of R.
>>>
>>> https://cran.r-project.org/web/packages/Rfast/index.html
>>>
>>> So, rephrasing my question...
>>> What is the best practice to bring a csv file into R so it can be 
>>> accessed by colMaxs and colMins, please?
>>>
>>> *Stephen Dawson, DSL*
>>> /Executive Strategy Consultant/
>>> Business & Technology
>>> +1 (865) 804-3454
>>> http://www.shdawson.com <http://www.shdawson.com>
>>>
>>>
>>> On 11/30/21 3:19 PM, Bert Gunter wrote:
>>>> RStudio is **not** R. In particular, the so-called TidyVerse 
>>>> consists of all *non*-standard contributed packages, about which the PG
>says:
>>>>
>>>> "For questions about functions in standard packages distributed with 
>>>> R (see the FAQ Add-on packages in R), ask questions on R-help.
>>>> [The link is:
>>>> https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
>>>> This gives the list of current _standard_ packages]
>>>>
>>>> If the question relates to a contributed package , e.g., one 
>>>> downloaded from CRAN, try contacting the package maintainer first. 
>>>> You can also use find("functionname") and
>>>> packageDescription("packagename") to find this information. Only 
>>>> send such questions to R-help or R-devel if you get no reply or need 
>>>> further assistance. This applies to both requests for help and to 
>>>> bug reports."
>>>>
>>>> Note that RStudio maintains its own help resources at:
>>>> https://community.rstudio.com/
>>>> This is where questions about the TidyVerse, ggplot, etc. should be
>posted.
>>>>
>>>>
>>>>
>>>> Bert Gunter
>>>>
>>>> "The trouble with having an open

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread PIKAL Petr
Hi.

It is always worth to consult excellent R help.

max and min return the maximum or minimum of all the values present in their 
arguments, as integer if all are logical or integer, as double if all are 
numeric, and character otherwise.

Character versions are sorted lexicographically, and this depends on the 
collating sequence of the locale in use: the help for ‘Comparison’ gives 
details. The max/min of an empty character vector is defined to be character 
NA. (One could argue that as "" is the smallest character element, the maximum 
should be "", but there is no obvious candidate for the minimum.)

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Stephen H.
> Dawson, DSL via R-help
> Sent: Wednesday, December 1, 2021 5:11 PM
> To: r-help@r-project.org
> Subject: Re: [R] Question about Rfast colMins and colMaxs
> 
> Jeff,
> 
> Can you use max and min evaluations on any other data type then numeric?
> If so, how do you evaluate max or min of text content? String length?
> Ascii values of text characters?
> 
> 
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com <http://www.shdawson.com>
> 
> 
> On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:
> > Well, no it is not. The email list stripped off the attachment.
> >
> > The data is numeric, happens to be all whole numbers.
> >
> >
> > Kindest Regards,
> > *Stephen Dawson, DSL*
> > /Executive Strategy Consultant/
> > Business & Technology
> > +1 (865) 804-3454
> > http://www.shdawson.com <http://www.shdawson.com>
> >
> >
> > On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:
> >> Hi Jeff,
> >>
> >>
> >> Thanks for the data review offer. Attached is the CSV.
> >>
> >>
> >> *Stephen Dawson, DSL*
> >> /Executive Strategy Consultant/
> >> Business & Technology
> >> +1 (865) 804-3454
> >> http://www.shdawson.com <http://www.shdawson.com>
> >>
> >>
> >> On 11/30/21 3:29 PM, Jeff Newmiller wrote:
> >>> I don't know anything about this package, but read.csv returns a
> >>> data frame. How you go about forming a matrix using that data frame
> >>> depends what is in it. If it is all numeric then as.matrix may be
> >>> all you need.
> >>>
> >>> Half of any R data analysis is data... and the details are almost
> >>> always crucial. Since you have told us nothing useful about the
> >>> data, it is up to you to inspect your data and figure out what to do
> >>> with it.
> >>>
> >>> On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via
> >>> R-help"  wrote:
> >>>> Hi,
> >>>>
> >>>>
> >>>> I am working to understand the Rfast functions of colMins and
> >>>> colMaxs. I worked through the example listed on page 54 of the PDF.
> >>>>
> >>>> https://cran.r-project.org/web/packages/Rfast/index.html
> >>>>
> >>>> https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
> >>>>
> >>>> My data is in a CSV file. So, I bring it into R Studio using:
> >>>> Data <- read.csv("./input/DataSet05.csv", header=T)
> >>>>
> >>>> However, I read the instructions listed on page 54 of the PDF
> >>>> saying I need to bring data into R using a matrix. I think read.csv
> >>>> brings the data in as a dataframe. I think colMins is failing
> >>>> because it is looking for a matrix but finds a dataframe.
> >>>>
> >>>>> colMaxs(Data)
> >>>> Error in colMaxs(Data) :
> >>>>Not compatible with requested type: [type=list; target=double].
> >>>>> colMins(Data, na.rm = TRUE)
> >>>> Error in colMins(Data, na.rm = TRUE) :
> >>>>unused argument (na.rm = TRUE)
> >>>>> colMins(Data, value = FALSE, parallel = FALSE)
> >>>> Error in colMins(Data, value = FALSE, parallel = FALSE) :
> >>>>Not compatible with requested type: [type=list; target=double].
> >>>>
> >>>> QUESTION
> >>>> What is the best practice to bring a csv file into R Studio so it
> >>>> can be accessed by colMaxs and colMins, please?
> >>>>
> >>>>
> >>>> Thanks,
> >>
> >> _

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Jeff,

Can you use max and min evaluations on any other data type then numeric? 
If so, how do you evaluate max or min of text content? String length? 
Ascii values of text characters?



*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:

Well, no it is not. The email list stripped off the attachment.

The data is numeric, happens to be all whole numbers.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:29 PM, Jeff Newmiller wrote:
I don't know anything about this package, but read.csv returns a 
data frame. How you go about forming a matrix using that data frame 
depends what is in it. If it is all numeric then as.matrix may be 
all you need.


Half of any R data analysis is data... and the details are almost 
always crucial. Since you have told us nothing useful about the 
data, it is up to you to inspect your data and figure out what to do 
with it.


On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via 
R-help"  wrote:

Hi,


I am working to understand the Rfast functions of colMins and 
colMaxs. I

worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is 
looking

for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it 
can be

accessed by colMaxs and colMins, please?


Thanks,


__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Avi Gross via R-help
Stephen,

Although what is in the STANDARD R distribution can vary several ways, in
general, if you need to add a line like:

library(something)
or
require(something)

and your code does not work unless you have done that, then you can imagine
it is not sort of built in to R as it starts.

Having said that, tons of exceptions may exist that cause R to load in
things on your machine for everyone or just for you without you having to
notice.

I think this forum lately has been deluged with questions about all kinds of
add-on packages and in particular, lots of the ones in the tidyverse.
Clearly the purpose here is not that broad.

But since I use some packages like the tidyverse extensively, and I am far
from alone, I wonder if someday the powers that be realize it is a losing
battle to exclude at least some of it. It would be so nice not having to
include a long list of packages for some programs or somehow arrange that
people using something you shared had installed and loaded them. But there
are too many packages out there of varying quality and usefulness and
popularity with more every day being added. Worse, many are somewhat
incompatible such as having functions with the same names that hide earlier
ones loaded.

Base R doe come with functions like colSums and colMeans and similar row
functions. But as mentioned, a data.frame is a list of vectors and R
supports certain functional programming constructs over lists using things
like:

lapply(df, min)
sapply(df, min)

And actually quite a few ways depending on what info you want back and
whether you insist it be returned as a list or vector or other things . You
can even supply additional arguments that might be needed such as if you
want to ignore any NA values,

lapply(df, min, na.rm=TRUE

The package you looked at it is trying to be fast and uses what looks like
compiled external code but so does lapply.

If this is too bothersome for you, consider making a one-liner function like
this:

mycolMins <- function(df, ...) lapply(df, min, ...)

Once defined, you can use that just fine and not think about it again and I
note this answer (like others) is offering you something in base R that
works fine on data.frames and the like.

You can extend to many similar ideas like this one that calulates the min
unless you over-ride it with max or mean or sd or a bizarre function like
`[` so a call to:

mycolCalc(df, `[`, 3)

Will return exactly the third items in each row!

I find it to be very common for someone these days to do a quick search for
a way to do something in a language like R and not really look to see if it
is a standard way or something special/ Matrices in R are not quite the same
as some other objects like a data.frame or tibble and a package written to
be used on one may (or may not) happen to work with another. Some packages
are carefully written to try to detect what kind of object it gets and when
possible convert it to another. The "apply" function is meant for matrices
but if it sees something else it looks ta the dimensionality and tries to
coerce it with as.matrix or as.array first. As others have noted, this mean
a data.frame containing non-numeric parts may fail or should have any other
columns hidden/removed as in this df that has some non-numeric fields:

> df
i   s   f b i2
1 1   hello 1.2  TRUE  5
2 2   there 2.3 FALSE  4
3 3 goodbye 3.4  TRUE  3

So a bit more complex one-liner removes any non-numeric columns like this:

> mycolMins(df[, sapply(df, is.numeric)])
$i
[1] 1

$f
[1] 1.2

$i2
[1] 3

Clearly converting that to a matrix while whole would result in everything
being converted to character and a minimum may be elusive.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Tuesday, November 30, 2021 5:37 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am not
clear on a standard versus non-standard list. I will look into this aspect
and see what I can learn going forward.


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 11/30/21 5:26 PM, Bert Gunter wrote:
> ... but Rfast is *not* a "standard" package, as the rest of the PG 
> excerpt says. So contact the maintainer and ask him/her what they 
> think the best practice should be for their package. As has been 
> pointed out already, it appears to differ from the usual "read it in 
> as a data frame" procedure.
>
> Bert
>
> On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL 
>  wrote:
>> Right, R Studio is not R.
>>
>> However, the Rfast package is part of R.
>>
>> https://cran.r-project.org/web/packages/Rfast/index.html
>>

Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Bert Gunter
If you look at my original reply, it gives the link that tells you
*exactly* what packages are "standard" (and all the thousands of
others which therefore are not).

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 Tue, Nov 30, 2021 at 2:37 PM Stephen H. Dawson, DSL
 wrote:
>
> Oh, you are segmenting standard R from the rest of R.
>
> Well, that part did not come across to me in your original reply. I am
> not clear on a standard versus non-standard list. I will look into this
> aspect and see what I can learn going forward.
>
>
> Thanks,
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com 
>
>
> On 11/30/21 5:26 PM, Bert Gunter wrote:
> > ... but Rfast is *not* a "standard" package, as the rest of the PG
> > excerpt says. So contact the maintainer and ask him/her what they
> > think the best practice should be for their package. As has been
> > pointed out already, it appears to differ from the usual "read it in
> > as a data frame" procedure.
> >
> > Bert
> >
> > On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
> >  wrote:
> >> Right, R Studio is not R.
> >>
> >> However, the Rfast package is part of R.
> >>
> >> https://cran.r-project.org/web/packages/Rfast/index.html
> >>
> >> So, rephrasing my question...
> >> What is the best practice to bring a csv file into R so it can be
> >> accessed by colMaxs and colMins, please?
> >>
> >> *Stephen Dawson, DSL*
> >> /Executive Strategy Consultant/
> >> Business & Technology
> >> +1 (865) 804-3454
> >> http://www.shdawson.com 
> >>
> >>
> >> On 11/30/21 3:19 PM, Bert Gunter wrote:
> >>> RStudio is **not** R. In particular, the so-called TidyVerse consists
> >>> of all *non*-standard contributed packages, about which the PG says:
> >>>
> >>> "For questions about functions in standard packages distributed with R
> >>> (see the FAQ Add-on packages in R), ask questions on R-help.
> >>> [The link is:
> >>> https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
> >>> This gives the list of current _standard_ packages]
> >>>
> >>> If the question relates to a contributed package , e.g., one
> >>> downloaded from CRAN, try contacting the package maintainer first. You
> >>> can also use find("functionname") and
> >>> packageDescription("packagename") to find this information. Only send
> >>> such questions to R-help or R-devel if you get no reply or need
> >>> further assistance. This applies to both requests for help and to bug
> >>> reports."
> >>>
> >>> Note that RStudio maintains its own help resources at:
> >>> https://community.rstudio.com/
> >>> This is where questions about the TidyVerse, ggplot, etc. should be 
> >>> posted.
> >>>
> >>>
> >>>
> >>> 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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
> >>>  wrote:
>  Hi,
> 
> 
>  I am working to understand the Rfast functions of colMins and colMaxs. I
>  worked through the example listed on page 54 of the PDF.
> 
>  https://cran.r-project.org/web/packages/Rfast/index.html
> 
>  https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
> 
>  My data is in a CSV file. So, I bring it into R Studio using:
>  Data <- read.csv("./input/DataSet05.csv", header=T)
> 
>  However, I read the instructions listed on page 54 of the PDF saying I
>  need to bring data into R using a matrix. I think read.csv brings the
>  data in as a dataframe. I think colMins is failing because it is looking
>  for a matrix but finds a dataframe.
> 
> > colMaxs(Data)
>  Error in colMaxs(Data) :
>   Not compatible with requested type: [type=list; target=double].
> > colMins(Data, na.rm = TRUE)
>  Error in colMins(Data, na.rm = TRUE) :
>   unused argument (na.rm = TRUE)
> > colMins(Data, value = FALSE, parallel = FALSE)
>  Error in colMins(Data, value = FALSE, parallel = FALSE) :
>   Not compatible with requested type: [type=list; target=double].
> 
>  QUESTION
>  What is the best practice to bring a csv file into R Studio so it can be
>  accessed by colMaxs and colMins, please?
> 
> 
>  Thanks,
>  --
>  *Stephen Dawson, DSL*
>  /Executive Strategy Consultant/
>  Business & Technology
>  +1 (865) 804-3454
>  http://www.shdawson.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 

Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am 
not clear on a standard versus non-standard list. I will look into this 
aspect and see what I can learn going forward.



Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:26 PM, Bert Gunter wrote:

... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the maintainer and ask him/her what they
think the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

https://cran.r-project.org/web/packages/Rfast/index.html

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the PG says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.



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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
 wrote:

Hi,


I am working to understand the Rfast functions of colMins and colMaxs. I
worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is looking
for a matrix but finds a dataframe.

   > colMaxs(Data)
Error in colMaxs(Data) :
 Not compatible with requested type: [type=list; target=double].
   > colMins(Data, na.rm = TRUE)
Error in colMins(Data, na.rm = TRUE) :
 unused argument (na.rm = TRUE)
   > colMins(Data, value = FALSE, parallel = FALSE)
Error in colMins(Data, value = FALSE, parallel = FALSE) :
 Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it can be
accessed by colMaxs and colMins, please?


Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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.




__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Bert Gunter
... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the maintainer and ask him/her what they
think the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:
>
> Right, R Studio is not R.
>
> However, the Rfast package is part of R.
>
> https://cran.r-project.org/web/packages/Rfast/index.html
>
> So, rephrasing my question...
> What is the best practice to bring a csv file into R so it can be
> accessed by colMaxs and colMins, please?
>
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com 
>
>
> On 11/30/21 3:19 PM, Bert Gunter wrote:
> > RStudio is **not** R. In particular, the so-called TidyVerse consists
> > of all *non*-standard contributed packages, about which the PG says:
> >
> > "For questions about functions in standard packages distributed with R
> > (see the FAQ Add-on packages in R), ask questions on R-help.
> > [The link is:
> > https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
> > This gives the list of current _standard_ packages]
> >
> > If the question relates to a contributed package , e.g., one
> > downloaded from CRAN, try contacting the package maintainer first. You
> > can also use find("functionname") and
> > packageDescription("packagename") to find this information. Only send
> > such questions to R-help or R-devel if you get no reply or need
> > further assistance. This applies to both requests for help and to bug
> > reports."
> >
> > Note that RStudio maintains its own help resources at:
> > https://community.rstudio.com/
> > This is where questions about the TidyVerse, ggplot, etc. should be posted.
> >
> >
> >
> > 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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
> >  wrote:
> >> Hi,
> >>
> >>
> >> I am working to understand the Rfast functions of colMins and colMaxs. I
> >> worked through the example listed on page 54 of the PDF.
> >>
> >> https://cran.r-project.org/web/packages/Rfast/index.html
> >>
> >> https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
> >>
> >> My data is in a CSV file. So, I bring it into R Studio using:
> >> Data <- read.csv("./input/DataSet05.csv", header=T)
> >>
> >> However, I read the instructions listed on page 54 of the PDF saying I
> >> need to bring data into R using a matrix. I think read.csv brings the
> >> data in as a dataframe. I think colMins is failing because it is looking
> >> for a matrix but finds a dataframe.
> >>
> >>   > colMaxs(Data)
> >> Error in colMaxs(Data) :
> >> Not compatible with requested type: [type=list; target=double].
> >>   > colMins(Data, na.rm = TRUE)
> >> Error in colMins(Data, na.rm = TRUE) :
> >> unused argument (na.rm = TRUE)
> >>   > colMins(Data, value = FALSE, parallel = FALSE)
> >> Error in colMins(Data, value = FALSE, parallel = FALSE) :
> >> Not compatible with requested type: [type=list; target=double].
> >>
> >> QUESTION
> >> What is the best practice to bring a csv file into R Studio so it can be
> >> accessed by colMaxs and colMins, please?
> >>
> >>
> >> Thanks,
> >> --
> >> *Stephen Dawson, DSL*
> >> /Executive Strategy Consultant/
> >> Business & Technology
> >> +1 (865) 804-3454
> >> http://www.shdawson.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.
>
>

__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Well, no it is not. The email list stripped off the attachment.

The data is numeric, happens to be all whole numbers.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:29 PM, Jeff Newmiller wrote:
I don't know anything about this package, but read.csv returns a data 
frame. How you go about forming a matrix using that data frame 
depends what is in it. If it is all numeric then as.matrix may be all 
you need.


Half of any R data analysis is data... and the details are almost 
always crucial. Since you have told us nothing useful about the data, 
it is up to you to inspect your data and figure out what to do with it.


On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via 
R-help"  wrote:

Hi,


I am working to understand the Rfast functions of colMins and 
colMaxs. I

worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is 
looking

for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it 
can be

accessed by colMaxs and colMins, please?


Thanks,


__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Thanks, Bill.

How do you go about getting maximum and minimum values from your 
columns? Do you simply do them one column at a time? The functions I am 
identifying from Rfast do this work in bulk.



*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:24 PM, Bill Dunlap wrote:
You can use as.matrix() to convert your data.frame to a matrix, but 
that loses the speed/space advantages of colMins (as well as causing 
issues if some columns are not numeric).  You could write to the 
maintainer of the package to ask that data.frames be directly 
supported.  In the meantime you could use

   vapply(yourDataFrame, which.min, FUN.VALUE=NA_real_)
or
    vapply(yourDataFrame, min, FUN.VALUE=NA_real_)
instead of colMins.

-Bill

On Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help 
mailto:r-help@r-project.org>> wrote:


Hi,


I am working to understand the Rfast functions of colMins and
colMaxs. I
worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html


https://cran.r-project.org/web/packages/Rfast/Rfast.pdf


My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF
saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is
looking
for a matrix but finds a dataframe.

 > colMaxs(Data)
Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].
 > colMins(Data, na.rm = TRUE)
Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)
 > colMins(Data, value = FALSE, parallel = FALSE)
Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it
can be
accessed by colMaxs and colMins, please?


Thanks,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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.



__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:29 PM, Jeff Newmiller wrote:

I don't know anything about this package, but read.csv returns a data frame. 
How you go about forming a matrix using that data frame depends what is in it. 
If it is all numeric then as.matrix may be all you need.

Half of any R data analysis is data... and the details are almost always 
crucial. Since you have told us nothing useful about the data, it is up to you 
to inspect your data and figure out what to do with it.

On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via R-help" 
 wrote:

Hi,


I am working to understand the Rfast functions of colMins and colMaxs. I
worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is looking
for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it can be
accessed by colMaxs and colMins, please?


Thanks,


__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Right, R Studio is not R.

However, the Rfast package is part of R.

https://cran.r-project.org/web/packages/Rfast/index.html

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be 
accessed by colMaxs and colMins, please?


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the PG says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.



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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
 wrote:

Hi,


I am working to understand the Rfast functions of colMins and colMaxs. I
worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is looking
for a matrix but finds a dataframe.

  > colMaxs(Data)
Error in colMaxs(Data) :
Not compatible with requested type: [type=list; target=double].
  > colMins(Data, na.rm = TRUE)
Error in colMins(Data, na.rm = TRUE) :
unused argument (na.rm = TRUE)
  > colMins(Data, value = FALSE, parallel = FALSE)
Error in colMins(Data, value = FALSE, parallel = FALSE) :
Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it can be
accessed by colMaxs and colMins, please?


Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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.


__
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Jeff Newmiller
I don't know anything about this package, but read.csv returns a data frame. 
How you go about forming a matrix using that data frame depends what is in it. 
If it is all numeric then as.matrix may be all you need.

Half of any R data analysis is data... and the details are almost always 
crucial. Since you have told us nothing useful about the data, it is up to you 
to inspect your data and figure out what to do with it.

On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via R-help" 
 wrote:
>Hi,
>
>
>I am working to understand the Rfast functions of colMins and colMaxs. I 
>worked through the example listed on page 54 of the PDF.
>
>https://cran.r-project.org/web/packages/Rfast/index.html
>
>https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
>
>My data is in a CSV file. So, I bring it into R Studio using:
>Data <- read.csv("./input/DataSet05.csv", header=T)
>
>However, I read the instructions listed on page 54 of the PDF saying I 
>need to bring data into R using a matrix. I think read.csv brings the 
>data in as a dataframe. I think colMins is failing because it is looking 
>for a matrix but finds a dataframe.
>
> > colMaxs(Data)
>Error in colMaxs(Data) :
>   Not compatible with requested type: [type=list; target=double].
> > colMins(Data, na.rm = TRUE)
>Error in colMins(Data, na.rm = TRUE) :
>   unused argument (na.rm = TRUE)
> > colMins(Data, value = FALSE, parallel = FALSE)
>Error in colMins(Data, value = FALSE, parallel = FALSE) :
>   Not compatible with requested type: [type=list; target=double].
>
>QUESTION
>What is the best practice to bring a csv file into R Studio so it can be 
>accessed by colMaxs and colMins, please?
>
>
>Thanks,

-- 
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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Bill Dunlap
You can use as.matrix() to convert your data.frame to a matrix, but that
loses the speed/space advantages of colMins (as well as causing issues if
some columns are not numeric).  You could write to the maintainer of the
package to ask that data.frames be directly supported.  In the meantime you
could use
   vapply(yourDataFrame, which.min, FUN.VALUE=NA_real_)
or
vapply(yourDataFrame, min, FUN.VALUE=NA_real_)
instead of colMins.

-Bill

On Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help <
r-help@r-project.org> wrote:

> Hi,
>
>
> I am working to understand the Rfast functions of colMins and colMaxs. I
> worked through the example listed on page 54 of the PDF.
>
> https://cran.r-project.org/web/packages/Rfast/index.html
>
> https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
>
> My data is in a CSV file. So, I bring it into R Studio using:
> Data <- read.csv("./input/DataSet05.csv", header=T)
>
> However, I read the instructions listed on page 54 of the PDF saying I
> need to bring data into R using a matrix. I think read.csv brings the
> data in as a dataframe. I think colMins is failing because it is looking
> for a matrix but finds a dataframe.
>
>  > colMaxs(Data)
> Error in colMaxs(Data) :
>Not compatible with requested type: [type=list; target=double].
>  > colMins(Data, na.rm = TRUE)
> Error in colMins(Data, na.rm = TRUE) :
>unused argument (na.rm = TRUE)
>  > colMins(Data, value = FALSE, parallel = FALSE)
> Error in colMins(Data, value = FALSE, parallel = FALSE) :
>Not compatible with requested type: [type=list; target=double].
>
> QUESTION
> What is the best practice to bring a csv file into R Studio so it can be
> accessed by colMaxs and colMins, please?
>
>
> Thanks,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.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.
>

[[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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Bert Gunter
RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the PG says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.



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 Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help
 wrote:
>
> Hi,
>
>
> I am working to understand the Rfast functions of colMins and colMaxs. I
> worked through the example listed on page 54 of the PDF.
>
> https://cran.r-project.org/web/packages/Rfast/index.html
>
> https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
>
> My data is in a CSV file. So, I bring it into R Studio using:
> Data <- read.csv("./input/DataSet05.csv", header=T)
>
> However, I read the instructions listed on page 54 of the PDF saying I
> need to bring data into R using a matrix. I think read.csv brings the
> data in as a dataframe. I think colMins is failing because it is looking
> for a matrix but finds a dataframe.
>
>  > colMaxs(Data)
> Error in colMaxs(Data) :
>Not compatible with requested type: [type=list; target=double].
>  > colMins(Data, na.rm = TRUE)
> Error in colMins(Data, na.rm = TRUE) :
>unused argument (na.rm = TRUE)
>  > colMins(Data, value = FALSE, parallel = FALSE)
> Error in colMins(Data, value = FALSE, parallel = FALSE) :
>Not compatible with requested type: [type=list; target=double].
>
> QUESTION
> What is the best practice to bring a csv file into R Studio so it can be
> accessed by colMaxs and colMins, please?
>
>
> Thanks,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.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.

__
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] Question about .Rhistory in Windows

2021-06-22 Thread PIKAL Petr
Hallo

I increased number of lines which .Rhistory stores before the lines start to
be overwritten.
You can do this by changing number in
Sys.setenv(R_HISTSIZE = 2000)
in Rprofile.site located in etc folder of your installation.

And from time to time I rename Rhistory to something like "210621.r"

Rhistory is plain text file so it can be viewed in any suitable text editor.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Gabriel Toro
> Sent: Monday, June 21, 2021 10:16 PM
> To: r-help@r-project.org
> Subject: [R] Question about .Rhistory in Windows
> 
> I am using version 3.6.3 on Windows. For some reason, the .Rhistory file
gets
> over-written once in a while. I would like to avoid this so I have a
complete
> history over multiple R sessions. Under what conditions can the .Rhistory
file
> be over-written?  Is there a way to keep this file from being
over-written?
> Any change in the startup settings?
> 
> Thanks in advance,
> 
> Gabriel
> 
> 
>   [[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] question re: tidycensus

2021-06-11 Thread Milton O Faison
The problem is resolved.

o

M. Omar Faison, Ph.D.
Associate Professor, Biology
Associate Vice President, Research, Economic Development, and Graduate Studies
Virginia State University
Petersburg, VA 23806
(804) 524-6793
http://twitter.com/omarfaison
At VSU, we are proudly committed to providing a transformative experience for 
our students, strategically investing in our academic programs, embracing our 
position as a top Land Grant University, embracing our role as Virginia’s 
Opportunity University, and partnering together as a University to tell our 
story.

-Original Message-
From: R-help  On Behalf Of Milton O Faison
Sent: Friday, June 11, 2021 11:04 AM
To: r-help@R-project.org
Subject: [R] question re: tidycensus

[EMAIL FROM EXTERNAL SENDER] [Do not click links or open attachments unless you 
can confirm the sender and know the content is safe.]

Hi, all,

I'm having a new (for me) problem with tidycensus. When I attempt to pull data 
at the zcta level using get_acs, I get "GEOMETRYCOLLECTION EMPTY" in the 
geometry column. It does not happen when I pull data at the census tract level. 
This is also a fairly new problem, because I was using old code that I wrote 
and successfully generated maps from in the past. Any thoughts? Here are some 
code snippets that you can run to see what I am talking about:

zcta_test<-get_acs(geography="zcta",
   variables=(c(all_pop = "B03002_001",
white_pop = "B03002_003",
black_pop = "B03002_004",
latin_pop = "B03002_012")),
   geometry=T, cache=T )

ct_test<-get_acs(geography="tract", state="51",
 variables=(c(all_pop = "B03002_001",
  white_pop = "B03002_003",
  black_pop = "B03002_004",
  latin_pop = "B03002_012")),
 geometry=T, cache=T )

Thanks in advance for any help you can provide.

o
M. Omar Faison, Ph.D.
Associate Professor, Biology
Associate Vice President, Research, Economic Development, and Graduate Studies 
Virginia State University Petersburg, VA 23806
(804) 524-6793
https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_omarfaison=DwICAg=x0kF_uL9Aj8Nho9NV_Y5N0VRgus3JhNu4ET-UrQfa2c=IxtcqU8MuUxaq7uVsaxQkg=XhPOfl_j7ZHB6bCZibPPH67hk0TqkCT-EryOLREjd30=-Dr4LICOMPZZPalYZfcnmLhGdBAqE9yJZXjX-nGQpow=
 

At VSU, we are proudly committed to providing a transformative experience for 
our students, strategically investing in our academic programs, embracing our 
position as a top Land Grant University, embracing our role as Virginia's 
Opportunity University, and partnering together as a University to tell our 
story.

"The information in this email and any attachments may be confidential and 
privileged. Access to this email by anyone other than the intended addressee is 
unauthorized. If you are not the intended recipient (or the employee or agent 
responsible for delivering this information to the intended recipient) please 
notify the sender by reply email and immediately delete this email and any 
copies from your computer and/or storage system. The sender does not authorize 
the use, distribution, disclosure or reproduction of this email (or any part of 
its contents) by anyone other than the intended recipient(s). No representation 
is made that this email and any attachments are free of viruses. Virus scanning 
is recommended and is the responsibility of the recipient."

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=x0kF_uL9Aj8Nho9NV_Y5N0VRgus3JhNu4ET-UrQfa2c=IxtcqU8MuUxaq7uVsaxQkg=XhPOfl_j7ZHB6bCZibPPH67hk0TqkCT-EryOLREjd30=QRP2OKyBRcfl93mIq6F159UuDSgEC62WqRDYl8ZPUf0=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=x0kF_uL9Aj8Nho9NV_Y5N0VRgus3JhNu4ET-UrQfa2c=IxtcqU8MuUxaq7uVsaxQkg=XhPOfl_j7ZHB6bCZibPPH67hk0TqkCT-EryOLREjd30=VG60V4vdazTZv1wM5Q0nvEh46A33pFBwkB0Bxa9jzEw=
and provide commented, minimal, self-contained, reproducible code.
“The information in this email and any attachments may be confidential and 
privileged. Access to this email by anyone other than the intended addressee is 
unauthorized. If you are not the intended recipient (or the employee or agent 
responsible for delivering this information to the intended recipient) please 
notify the sender by reply email and immediately delete this email and any 
copies from your computer and/or 

Re: [R] question re: tidycensus

2021-06-11 Thread Bert Gunter
Have you read the posting guide, linked below, which says:

"For questions about functions in standard packages distributed with R (see
the FAQ Add-on packages in R
), ask
questions on R-help.
If the question relates to a *contributed package* , e.g., one downloaded
from CRAN, try contacting the package maintainer first. You can also use
find("functionname") and packageDescription("packagename") to find this
information. *Only* send such questions to R-help or R-devel if you get no
reply or need further assistance. This applies to both requests for help
and to bug reports."

The "tidyverse" consists of contributed packages, so do not be surprised if
you do not receive a response here. Of course, if you have contacted the
maintainers, say so, but of course that doesn't guarantee a response.

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 Fri, Jun 11, 2021 at 8:04 AM Milton O Faison  wrote:

> Hi, all,
>
> I'm having a new (for me) problem with tidycensus. When I attempt to pull
> data at the zcta level using get_acs, I get "GEOMETRYCOLLECTION EMPTY" in
> the geometry column. It does not happen when I pull data at the census
> tract level. This is also a fairly new problem, because I was using old
> code that I wrote and successfully generated maps from in the past. Any
> thoughts? Here are some code snippets that you can run to see what I am
> talking about:
>
> zcta_test<-get_acs(geography="zcta",
>variables=(c(all_pop = "B03002_001",
> white_pop = "B03002_003",
> black_pop = "B03002_004",
> latin_pop = "B03002_012")),
>geometry=T, cache=T )
>
> ct_test<-get_acs(geography="tract", state="51",
>  variables=(c(all_pop = "B03002_001",
>   white_pop = "B03002_003",
>   black_pop = "B03002_004",
>   latin_pop = "B03002_012")),
>  geometry=T, cache=T )
>
> Thanks in advance for any help you can provide.
>
> o
> M. Omar Faison, Ph.D.
> Associate Professor, Biology
> Associate Vice President, Research, Economic Development, and Graduate
> Studies
> Virginia State University
> Petersburg, VA 23806
> (804) 524-6793
> http://twitter.com/omarfaison<
> https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_omarfaison=DwMFaQ=x0kF_uL9Aj8Nho9NV_Y5N0VRgus3JhNu4ET-UrQfa2c=IxtcqU8MuUxaq7uVsaxQkg=c2Jz-ZN8dT7jr1ymvzj06YmlEcGQKIlxGcJ241xeVvc=9hWiMv7VHiP6W763kVu0J8RpEijbsKpHXY9CDrs7buc=
> >
> At VSU, we are proudly committed to providing a transformative experience
> for our students, strategically investing in our academic programs,
> embracing our position as a top Land Grant University, embracing our role
> as Virginia's Opportunity University, and partnering together as a
> University to tell our story.
>
> "The information in this email and any attachments may be confidential and
> privileged. Access to this email by anyone other than the intended
> addressee is unauthorized. If you are not the intended recipient (or the
> employee or agent responsible for delivering this information to the
> intended recipient) please notify the sender by reply email and immediately
> delete this email and any copies from your computer and/or storage system.
> The sender does not authorize the use, distribution, disclosure or
> reproduction of this email (or any part of its contents) by anyone other
> than the intended recipient(s). No representation is made that this email
> and any attachments are free of viruses. Virus scanning is recommended and
> is the responsibility of the recipient."
>
> [[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] question about the difference of AIC()

2021-05-12 Thread Søren Højsgaard
In the first model, I believe you estimate two parameters: the mean and
the variance:
> fm <- lm(y ~ 1)
> 2*2 - 2 * logLik(fm)
'log Lik.' 40.49275 (df=2)
>
AIC(fm)
[1] 40.49275


A zero mean model:

fm0 <- lm(y ~ -1)
> 2*1 - 2 * logLik(fm0)
'log Lik.' 39.00611 (df=1)
> AIC(fm0)
[1] 39.00611

Regards
Søren


On Wed, 2021-05-12 at 19:49 +0800, Jinsong Zhao wrote:
> Hi there,
> 
> I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is
> the 
> number of estimated parameters in the model.
> 
> For examle:
>  > set.seed(123)
>  > y <- rnorm(15)
>  > fm <- lm(y ~ 1)
> In this example, npar should be 1, so, AIC is:
>  > 2*1 - 2 * logLik(fm)
> 'log Lik.' 38.49275 (df=2)
> 
> However, AIC() give:
>  > AIC(fm)
> [1] 40.49275
> 
> I also try another AIC extract function:
>  > extractAIC(fm)
> [1]  1.00 -4.075406
> 
> Since extractAIC() does not include the constant: n + n * log(2 *
> pi), so:
>  > extractAIC(fm)[2] + 15 + 15 * log(2 * pi)
> [1] 38.49275
> 
> It equals to the AIC calculated by 2*1 - 2 * logLik(fm), but
> different 
> with the return of AIC().
> 
> It seems that AIC use 2 * (npar + 1) instead of 2 * npar.
> 
> In the help page of logLik, it said:
>   '"df"' (*d*egrees of *f*reedom), giving the number of (estimated) 
> parameters in the model.
> 
> The "df" is used by AIC() as npar, however, "df" is not number of 
> estimated parameters in the model, df - 1 is. Am I correct?
> 
> Best wishes,
> Jinsong
> 
> __
> 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] question about the difference of AIC()

2021-05-12 Thread Jinsong Zhao

On 2021/5/12 19:49, Jinsong Zhao wrote:

Hi there,

I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is the 
number of estimated parameters in the model.


k should be npar in the above sentence. Sorry for the mistake.



For examle:
 > set.seed(123)
 > y <- rnorm(15)
 > fm <- lm(y ~ 1)
In this example, npar should be 1, so, AIC is:
 > 2*1 - 2 * logLik(fm)
'log Lik.' 38.49275 (df=2)

However, AIC() give:
 > AIC(fm)
[1] 40.49275

I also try another AIC extract function:
 > extractAIC(fm)
[1]  1.00 -4.075406

Since extractAIC() does not include the constant: n + n * log(2 * pi), so:
 > extractAIC(fm)[2] + 15 + 15 * log(2 * pi)
[1] 38.49275

It equals to the AIC calculated by 2*1 - 2 * logLik(fm), but different 
with the return of AIC().


It seems that AIC use 2 * (npar + 1) instead of 2 * npar.

In the help page of logLik, it said:
  '"df"' (*d*egrees of *f*reedom), giving the number of (estimated) 
parameters in the model.


The "df" is used by AIC() as npar, however, "df" is not number of 
estimated parameters in the model, df - 1 is. Am I correct?


Best wishes,
Jinsong


__
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] Question about using R sample datasets

2021-05-02 Thread Jeff Newmiller
You have already been reminded that none of us are lawyers. There is license 
text associated with every package and base R, and it is not necessarily the 
same for all parts of R, so there is no way for us to answer your question in 
its vague form and no way for you to rely our opinions even if you do clarify.

On May 2, 2021 1:38:49 AM PDT, Maja Analytics  
wrote:
>Thanks for the advice.
>
>What about R code? Is that free to share? I would use my own dataset or
>made up dataset, so I am only now interested what about R code, can I
>screenshot it and then explain what is on the photo?
>
>Maja
>
>ned, 2. svi 2021. u 01:17 David Winsemius 
>napisao
>je:
>
>> Any answer you get here will will have all the authority of "some guy
>on
>> the Internet", but my reading of the licenses is that as long as you
>give
>> proper credit that you can use any material in teaching or commercial
>> purposes AND derivative works are likewise copy-able on an open
>source
>> (FOSS) basis. You should read the LinkedIn TOS and make sure that
>posting
>> there is not subject to some sort of publisher's copyright. That
>might be a
>> violation fo the licensing for material copied from CRAN sources.
>> Acknowledgment alone might not be an acceptable use. You may need to
>seek
>> appropriate legal counsel or get opinions from the creators of the
>> licensing language, since there are a variety of license.
>>
>> David Winsemius, MD, (IANAL)
>>
>>
>> > On May 1, 2021, at 12:17 PM, Maja Analytics <
>> maja.analytics.b...@gmail.com> wrote:
>> >
>> > Hello!
>> >
>> > I would like to make tutorials for non-data scientists in R on
>Medium and
>> > as LinkedIn articles. Could you tell me if I can use R sample
>datasets (I
>> > would note the acknowledgements on the end) for that?
>> >
>> > Thanks in advance, kind regards,
>> > Maja
>> >
>> >   [[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.

-- 
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] Question about using R sample datasets

2021-05-02 Thread Maja Analytics
Thanks for the advice.

What about R code? Is that free to share? I would use my own dataset or
made up dataset, so I am only now interested what about R code, can I
screenshot it and then explain what is on the photo?

Maja

ned, 2. svi 2021. u 01:17 David Winsemius  napisao
je:

> Any answer you get here will will have all the authority of "some guy on
> the Internet", but my reading of the licenses is that as long as you give
> proper credit that you can use any material in teaching or commercial
> purposes AND derivative works are likewise copy-able on an open source
> (FOSS) basis. You should read the LinkedIn TOS and make sure that posting
> there is not subject to some sort of publisher's copyright. That might be a
> violation fo the licensing for material copied from CRAN sources.
> Acknowledgment alone might not be an acceptable use. You may need to seek
> appropriate legal counsel or get opinions from the creators of the
> licensing language, since there are a variety of license.
>
> David Winsemius, MD, (IANAL)
>
>
> > On May 1, 2021, at 12:17 PM, Maja Analytics <
> maja.analytics.b...@gmail.com> wrote:
> >
> > Hello!
> >
> > I would like to make tutorials for non-data scientists in R on Medium and
> > as LinkedIn articles. Could you tell me if I can use R sample datasets (I
> > would note the acknowledgements on the end) for that?
> >
> > Thanks in advance, kind regards,
> > Maja
> >
> >   [[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] Question about using R sample datasets

2021-05-02 Thread David Winsemius
Again, the terms of the license govern the legalities. I don’t think you would 
need any further efforts at licensing your commentary. Screenshots or text 
copies would both be just copies and the appropriate citations would probably 
be all that were needed. I do not think your commentary or explanatory work 
would need to be considered FOSS or a copyleft license. There are many 
instances of commercial, copyrighted books that contain portions of R source 
code. Several businesses exist that sell accessories or packages that depend on 
but are not part of core R. Some of them seem to me to be skirting the line of 
legality but I don’t think there have been any cases brought before judicial 
authorities. So your plans seems completely safe and well inside accepted and 
legal boundaries to my understanding. 

David 

Sent from my iPhone

> On May 2, 2021, at 2:39 AM, Maja Analytics  
> wrote:
> 
> 
> Thanks for the advice.
> 
> What about R code? Is that free to share? I would use my own dataset or made 
> up dataset, so I am only now interested what about R code, can I screenshot 
> it and then explain what is on the photo?
> 
> Maja
> 
> ned, 2. svi 2021. u 01:17 David Winsemius  napisao je:
>> Any answer you get here will will have all the authority of "some guy on the 
>> Internet", but my reading of the licenses is that as long as you give proper 
>> credit that you can use any material in teaching or commercial purposes AND 
>> derivative works are likewise copy-able on an open source (FOSS) basis. You 
>> should read the LinkedIn TOS and make sure that posting there is not subject 
>> to some sort of publisher's copyright. That might be a violation fo the 
>> licensing for material copied from CRAN sources. Acknowledgment alone might 
>> not be an acceptable use. You may need to seek appropriate legal counsel or 
>> get opinions from the creators of the licensing language, since there are a 
>> variety of license.
>> 
>> David Winsemius, MD, (IANAL)
>> 
>> 
>> > On May 1, 2021, at 12:17 PM, Maja Analytics 
>> >  wrote:
>> > 
>> > Hello!
>> > 
>> > I would like to make tutorials for non-data scientists in R on Medium and
>> > as LinkedIn articles. Could you tell me if I can use R sample datasets (I
>> > would note the acknowledgements on the end) for that?
>> > 
>> > Thanks in advance, kind regards,
>> > Maja
>> > 
>> >   [[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] Question

2021-05-02 Thread Jim Lemon
Hi Myungjin,
The funnel plot is no more than the precision of the estimates of
related studies plotted against the estimates. That is, if your
measure of precision is the sample size (SS) and the estimate is named
E,

plot(E,SS)

Look at the metafor package for good funnel plot functions. Egger's
test can be misleading, see:

https://training.cochrane.org/resource/identifying-publication-bias-meta-analyses-continuous-outcomes

for a good introduction.

Jim


produces a very basic funnel plot. Enclosing lines or curves are
usually added, forming the inverted "funnel".

On Sun, May 2, 2021 at 11:00 AM Myungjin Jung  wrote:
>
> Good evening,
>
> I have a quick question about the "robumeta" package in R software. Below
> is my question:
>
> Is it possible to create funnel plots as well as assess (Egger's test) and
> adjust (Trim and fill approach) for publication bias in meta-analysis with
> RVE methods?
>
> Thank you so much for your help.
>
> Best regards,
> Myungjin
>
> *Myungjin Jung*
> Doctoral Graduate Assistant
> The University of Mississippi
> Department of Health, Exercise Science, and Recreation Management
> P.O. Box 1848
> 234 Turner Center
> University, MS 38677-1848
> *mju...@go.olemiss.ed u*
>
> [[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] Question

2021-05-01 Thread Bert Gunter
Do note, per the posting guide linked below (which you should read):

"For questions about functions in standard packages distributed with R (see
the FAQ Add-on packages in R
), ask
questions on R-help.

If the question relates to a *contributed package* , e.g., one downloaded
from CRAN, try contacting the package maintainer first. You can also use
find("functionname") and packageDescription("packagename") to find this
information. *Only* send such questions to R-help or R-devel if you get no
reply or need further assistance. This applies to both requests for help
and to bug reports."

So do not be surprised if you do not receive a response here. You would
probably have a better chance for success on the SIG devoted to
meta-analysis:
https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis  .

Also per the posting guide, post in plain text not html. Not a problem
here, but it can be when one posts code.

Cheers,
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 Sat, May 1, 2021 at 5:59 PM Myungjin Jung  wrote:

> Good evening,
>
> I have a quick question about the "robumeta" package in R software. Below
> is my question:
>
> Is it possible to create funnel plots as well as assess (Egger's test) and
> adjust (Trim and fill approach) for publication bias in meta-analysis with
> RVE methods?
>
> Thank you so much for your help.
>
> Best regards,
> Myungjin
>
> *Myungjin Jung*
> Doctoral Graduate Assistant
> The University of Mississippi
> Department of Health, Exercise Science, and Recreation Management
> P.O. Box 1848
> 234 Turner Center
> University, MS 38677-1848
> *mju...@go.olemiss.ed u*
>
> [[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] Question about using R sample datasets

2021-05-01 Thread David Winsemius
Any answer you get here will will have all the authority of "some guy on the 
Internet", but my reading of the licenses is that as long as you give proper 
credit that you can use any material in teaching or commercial purposes AND 
derivative works are likewise copy-able on an open source (FOSS) basis. You 
should read the LinkedIn TOS and make sure that posting there is not subject to 
some sort of publisher's copyright. That might be a violation fo the licensing 
for material copied from CRAN sources. Acknowledgment alone might not be an 
acceptable use. You may need to seek appropriate legal counsel or get opinions 
from the creators of the licensing language, since there are a variety of 
license.

David Winsemius, MD, (IANAL)


> On May 1, 2021, at 12:17 PM, Maja Analytics  
> wrote:
> 
> Hello!
> 
> I would like to make tutorials for non-data scientists in R on Medium and
> as LinkedIn articles. Could you tell me if I can use R sample datasets (I
> would note the acknowledgements on the end) for that?
> 
> Thanks in advance, kind regards,
> Maja
> 
>   [[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] Question about dotwhisker

2020-12-19 Thread Dan Bolser
Sorry, forgot to link the actual vignette:
https://cran.r-project.org/web/packages/dotwhisker/vignettes/dotwhisker-vignette.html

In fact the vignette states:
dwplot(m1_df) #same as dwplot(m1)

where m1_df is m1_df <- tidy(m1)

They are not the same in either the vignette itself or on my computer.

I don't understand the part about "rescale the coefficients", but it seems
that that is now the default... Just visually at least...

If the plots in the vignette are auto-generated from code, then that would
explain why the discrepancy isn't mentioned in the text.





On Fri, 18 Dec 2020 at 13:47, Dan Bolser  wrote:

> Hello,
>
> I'm reading this and one part is confusing me (the most ;-)
>
> library(dotwhisker)
> library(broom)
> library(dplyr)
>
> m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
>
> # Please compare:
> dwplot(m1)
> dwplot(tidy(m1))
>
> Why is the dwplot of tidy(m1) so different from the dwplot of m1?
>
> I had thought that tidy just gathers data from m1 and that that is what
> dwplot is showing, but the latter shows results that are closer to what you
> get from inspecting m1:
>
> Coefficients:
> (Intercept)   wt  cyl disp gear
>   43.539847-3.792867-1.784296 0.006944-0.490445
>
> Sorry if I'm being stupid, but the latter looks right while the former
> looks wrong (i.e. I can't work out what the former is actually plotting).
>
>
> Many thanks,
> Dan.
>

[[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] Question about the package "MatchIt"

2020-10-10 Thread Ehsan Karim
Maria:

What you are looking for (propensity score matching on survey data) is
discussed in lab 5 components of this series using matchit and matching
package:

https://www.youtube.com/playlist?list=PL2yD6frXhFob_Mvfg21Y01t_yu1aC9NnP

Regards,

Ehsan
https://ehsank.com/


On Fri., Oct. 9, 2020, 4:02 p.m. Maria Cristina Maurizio, <
mariacristina.mauri...@gmail.com> wrote:

> Hi! I'm trying to perform propensity score matching on survey data and so
> for each individual observation I have a statistical weight attached. My
> question is: is there a way within the package to consider these weights in
> the matching procedure?
> Thank you very much.
>
> --
> Maria Cristina Maurizio
>
> [[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] Question about the package "MatchIt"

2020-10-10 Thread Patrick (Malone Quantitative)
Maria Cristina,

The MatchIt homepage at https://gking.harvard.edu/matchit has a link
to a mailing list specific to the package and it has searchable
archives. You will probably have better luck there than a general R
programming list. Though a quick perusal of the user guide at that
site makes me think the answer is probably "no."

Pat


On Fri, Oct 9, 2020 at 7:02 PM Maria Cristina Maurizio
 wrote:
>
> Hi! I'm trying to perform propensity score matching on survey data and so
> for each individual observation I have a statistical weight attached. My
> question is: is there a way within the package to consider these weights in
> the matching procedure?
> Thank you very much.
>
> --
> Maria Cristina Maurizio
>
> [[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.



-- 
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His

__
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] Question about the package "MatchIt"

2020-10-10 Thread Jeremie Juste
Hello Maria Cristina,

On Friday,  9 Oct 2020 at 19:39, Maria Cristina Maurizio wrote:
> Hi! I'm trying to perform propensity score matching on survey data and so
> for each individual observation I have a statistical weight attached. My
> question is: is there a way within the package to consider these weights in
> the matching procedure?
I'm afraid it is difficult to help you based on the information you have 
provided.

Could you please provide more information about your issue ?
A minimal reproducible code would be of great help to have a more
precise idea of the problem you are facing.


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Best regards,
-- 
Jeremie Juste

__
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] question including crossover trials in meta-analysis

2020-09-15 Thread Belgers, V. (Vera)
Dear mr. Schwartz and mw Gunter,
Thank you both for your reply. I did google but did not find these sources, so 
thank you.
With kind regards,
Vera Belgers

Van: Bert Gunter 
Verzonden: maandag 14 september 2020 21:14
Aan: Belgers, V. (Vera) 
CC: r-help@R-project.org 
Onderwerp: Re: [R] question including crossover trials in meta-analysis

Did you first try a web search? -- you should always do this before posting 
here.

"meta-analysis in R" brought up this:

https://CRAN.R-project.org/view=MetaAnalysis<https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.r-project.org%2Fview%3DMetaAnalysis=02%7C01%7Cv.belgers%40amsterdamumc.nl%7C460c6129ebd54ce61bb308d858e27bae%7C68dfab1a11bb4cc6beb528d756984fb6%7C0%7C0%7C637357077046991635=wtUat277Ectic3FwPyRh92uhm7Am%2FAvsam97590UJ0o%3D=0>

Have you looked at this task view yet?


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 Mon, Sep 14, 2020 at 11:50 AM Belgers, V. (Vera) 
mailto:v.belg...@amsterdamumc.nl>> wrote:
Dear sir/madam,
Thank you in advance for taking the time to read my question. I am currently 
trying to conduct a meta-analysis combining parallel and crossover trials. 
According to the Cochrane Handbook, I can include crossover trials by using 
t-paired statistics. So far, I have managed to conduct a meta-analysis and 
forest plot of the parallel trials using the dmetar package, but I did not 
succeed in including the crossover trials. I do have the raw data of most of 
these crossover trials.
Does anybody know how to add crossover trials to the meta-analysis?
With kind regards,
Vera Belgers
__
VUmc disclaimer : www.vumc.nl/disclaimer<http://www.vumc.nl/disclaimer>
AMC disclaimer : www.amc.nl/disclaimer<http://www.amc.nl/disclaimer>

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=02%7C01%7Cv.belgers%40amsterdamumc.nl%7C460c6129ebd54ce61bb308d858e27bae%7C68dfab1a11bb4cc6beb528d756984fb6%7C0%7C0%7C637357077047001589=yv4KfT6v%2FaTfTEXar7PgjBuYsy6STJpZjsbeieMTpEU%3D=0>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=02%7C01%7Cv.belgers%40amsterdamumc.nl%7C460c6129ebd54ce61bb308d858e27bae%7C68dfab1a11bb4cc6beb528d756984fb6%7C0%7C0%7C637357077047001589=YwGAWSIcazrcvZ%2B7sSC2CoaUvffAEh6Gt2dr45lweYo%3D=0>
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] question including crossover trials in meta-analysis

2020-09-15 Thread Michael Dewey

Dear Vera

In addition to what you already have you might like to know about the 
mailing list specifically dedicated to meta-analysis in R.


https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis//

You might like to search the archives first as this sort of issue does 
come up there. You are also likely to get more immediate help if you 
frame your question in terms of either meta or metafor the two packages 
which dmetar uses. The authors of meta and metafor all frequent the list


Michael

On 14/09/2020 20:41, Marc Schwartz via R-help wrote:

Hi,

Bert has pointed you to some R specific packages for meta-analyses via the Task 
View.

It sounds like you may need to first address some underlying conceptual issues, 
which strictly speaking, is off-topic for this list.

That being said, a quick Google search came up with some possible resources, 
beyond the Cochrane reference:

   https://academic.oup.com/ije/article/31/1/140/655940

   https://onlinelibrary.wiley.com/doi/abs/10.1002/jrsm.1236

   https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0133023


Perhaps with additional conceptual background, that might assist in enabling 
you to make use of the R packages that provide relevant functionality.

Another option, if you want to stay with the dmetar package, would be to 
contact the package maintainer for some guidance relative to how to use the 
functionality in the package given your specific use case.

Regards,

Marc Schwartz



On Sep 14, 2020, at 3:14 PM, Bert Gunter  wrote:

Did you first try a web search? -- you should always do this before posting
here.

"meta-analysis in R" brought up this:

https://CRAN.R-project.org/view=MetaAnalysis

Have you looked at this task view yet?


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 Mon, Sep 14, 2020 at 11:50 AM Belgers, V. (Vera) <
v.belg...@amsterdamumc.nl> wrote:


Dear sir/madam,
Thank you in advance for taking the time to read my question. I am
currently trying to conduct a meta-analysis combining parallel and
crossover trials. According to the Cochrane Handbook, I can include
crossover trials by using t-paired statistics. So far, I have managed to
conduct a meta-analysis and forest plot of the parallel trials using the
dmetar package, but I did not succeed in including the crossover trials. I
do have the raw data of most of these crossover trials.
Does anybody know how to add crossover trials to the meta-analysis?
With kind regards,
Vera Belgers


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



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] question including crossover trials in meta-analysis

2020-09-14 Thread Marc Schwartz via R-help
Hi,

Bert has pointed you to some R specific packages for meta-analyses via the Task 
View.

It sounds like you may need to first address some underlying conceptual issues, 
which strictly speaking, is off-topic for this list.

That being said, a quick Google search came up with some possible resources, 
beyond the Cochrane reference:

  https://academic.oup.com/ije/article/31/1/140/655940

  https://onlinelibrary.wiley.com/doi/abs/10.1002/jrsm.1236

  https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0133023


Perhaps with additional conceptual background, that might assist in enabling 
you to make use of the R packages that provide relevant functionality.

Another option, if you want to stay with the dmetar package, would be to 
contact the package maintainer for some guidance relative to how to use the 
functionality in the package given your specific use case.

Regards,

Marc Schwartz


> On Sep 14, 2020, at 3:14 PM, Bert Gunter  wrote:
> 
> Did you first try a web search? -- you should always do this before posting
> here.
> 
> "meta-analysis in R" brought up this:
> 
> https://CRAN.R-project.org/view=MetaAnalysis
> 
> Have you looked at this task view yet?
> 
> 
> 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 Mon, Sep 14, 2020 at 11:50 AM Belgers, V. (Vera) <
> v.belg...@amsterdamumc.nl> wrote:
> 
>> Dear sir/madam,
>> Thank you in advance for taking the time to read my question. I am
>> currently trying to conduct a meta-analysis combining parallel and
>> crossover trials. According to the Cochrane Handbook, I can include
>> crossover trials by using t-paired statistics. So far, I have managed to
>> conduct a meta-analysis and forest plot of the parallel trials using the
>> dmetar package, but I did not succeed in including the crossover trials. I
>> do have the raw data of most of these crossover trials.
>> Does anybody know how to add crossover trials to the meta-analysis?
>> With kind regards,
>> Vera Belgers

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


  1   2   3   4   5   6   7   8   9   10   >