Re: [R] Fwd: r-stats: Geometric Distribution

2023-10-18 Thread Jim Lemon
Please delete drjimle...@gmail.com from your mailing lists. He passed away
a mknth ago.
Regards,
Juel
Wife

On Tue, 17 Oct 2023, 22:58 Sahil Sharma  -- Forwarded message -
> From: Sahil Sharma 
> Date: Tue, Oct 17, 2023 at 12:10 PM
> Subject: r-stats: Geometric Distribution
> To: 
>
>
> Hey I want to raise one issue in *r-stats **geometric distribution *
> function.
>
> I have found the dgeom(x,p) which denotes probability density function of
> geometric distribution, is not reducing 1 from x.
>
> The original formula for Geometric Distribution PDF is *((1-p)^x-1)*P*.
> However, the current r function *dgeom(x, p)* is doing this: *((1-p)^x)*P,
> *it
> is not reducing 1 from x.
>
> I don't know whether this it is kept as it is intentionally, but I thought
> of just informing you, in case it's an error, so you can correct it.
>
> Thanks.
>
> [[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] Best way to test for numeric digits?

2023-10-18 Thread Jim Lemon
Please delete drjimle...@bitwrit.com from your mailing list. He passed away
a month ago.
Regards,
Juel (wife)

On Thu, 19 Oct 2023, 02:09 Ben Bolker  There are some answers on Stack Overflow:
>
>
> https://stackoverflow.com/questions/14984989/how-to-avoid-warning-when-introducing-nas-by-coercion
>
>
>
> On 2023-10-18 10:59 a.m., Leonard Mada via R-help wrote:
> > Dear List members,
> >
> > What is the best way to test for numeric digits?
> >
> > suppressWarnings(as.double(c("Li", "Na", "K",  "2", "Rb", "Ca", "3")))
> > # [1] NA NA NA  2 NA NA  3
> > The above requires the use of the suppressWarnings function. Are there
> > any better ways?
> >
> > I was working to extract chemical elements from a formula, something
> > like this:
> > split.symbol.character = function(x, rm.digits = TRUE) {
> >  # Perl is partly broken in R 4.3, but this works:
> >  regex =
> "(?<=[A-Z])(?![a-z]|$)|(?<=.)(?=[A-Z])|(?<=[a-z])(?=[^a-z])";
> >  # stringi::stri_split(x, regex = regex);
> >  s = strsplit(x, regex, perl = TRUE);
> >  if(rm.digits) {
> >  s = lapply(s, function(s) {
> >  isNotD = is.na(suppressWarnings(as.numeric(s)));
> >  s = s[isNotD];
> >  });
> >  }
> >  return(s);
> > }
> >
> > split.symbol.character(c("CCl3F", "Li4Al4H16", "CCl2CO2AlPO4SiO4Cl"))
> >
> >
> > Sincerely,
> >
> >
> > Leonard
> >
> >
> > Note:
> > # works:
> > regex = "(?<=[A-Z])(?![a-z]|$)|(?<=.)(?=[A-Z])|(?<=[a-z])(?=[^a-z])";
> > strsplit(c("CCl3F", "Li4Al4H16", "CCl2CO2AlPO4SiO4Cl"), regex, perl = T)
> >
> >
> > # broken in R 4.3.1
> > # only slightly "erroneous" with stringi::stri_split
> > regex = "(?<=[A-Z])(?![a-z]|$)|(?=[A-Z])|(?<=[a-z])(?=[^a-z])";
> > strsplit(c("CCl3F", "Li4Al4H16", "CCl2CO2AlPO4SiO4Cl"), regex, perl = T)
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] save(), load(), saveRDS(), and readRDS()

2023-10-04 Thread Jim Lemon
Hello,
I am very sad to let you know that my husband Jim died on 18th September. I
apologise for not letting you know earlier but I had trouble finding the
password for his phone.
Kind regards,
Juel

On Fri, 29 Sep 2023, 01:48 Shu Fai Cheung  Hi All,
>
> There is a thread about the use of save(), load(), saveRDS(), and
> loadRDS(). It led me to think about a question regarding them.
>
> In my personal work, I prefer using saveRDS() and loadRDS() as I don't like
> the risk of overwriting anything in the global environment. I also like the
> freedom to name an object when reading it from a file.
>
> However, for teaching, I have to teach save() and load() because, in my
> discipline, it is common for researchers to share their datasets on the
> internet using the format saved by save(), and so students need to know how
> to use load() and what will happen when using it. Actually, I can't recall
> encountering datasets shared by the .rds format. I have been wondering why
> save() was usually used in that case.
>
> That discussion led me to read the help pages again and I noticed the
> following warning, from the help page of saveRDS():
>
> "Files produced by saveRDS (or serialize to a file connection) are not
> suitable as an interchange format between machines, for example to download
> from a website. The files produced by save
>  have a header identifying
> the file type and so are better protected against erroneous use."
>
> When will the problem mentioned in the warning occur? That is, when will a
> file saved by saveRDS() not be read correctly? Saved in Linux and then read
> in Windows? Is it possible to create a reproducible error?
>
> Regards,
> Shu Fai
>
> [[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] Problems Structuring My Data

2023-10-04 Thread Jim Lemon
Hello,
I am very sad to let you know that my husband Jim died in 18th September. I
apologise for not letting you know earlier but I had trouble finding the
password for his phone.
If you wish to do an obituary please let me know by emailing
juelsallybri...@gmail.com, I can send info through.
Kind regards,
Juel

On Wed, 4 Oct 2023, 09:18 Paul Bernal  Dear friends,
>
> Hope you are all doing great. I am working with a dataset which is a subset
> of the original one, that has the following columns: FAILDATE, REM_NAME,
> and Days_At_Failure.
>
> I want to structure the data in such a way that I have the unique FAILDATE
> in "%Y-%m-%d" format, then a column for each REM_NAME and then the
> Days_At_Failure displayed for each REM_NAME and FAILDATE (just as if I was
> using a pivot table).
>
> The structure I want is the following:
> FAILDATE  REM1 REM2  REM3  REM N
> 2000-01-01 # days at failure #days at
> failure
> 2000-01-02 # days at failure #days at
> failure
> 2000-01-03 # days at failure #days at
> failure
>
> Here is the dput() of my dataframe:
> #I don´t know why R is showing the dates as numbers
> #when I do str, it actually shows that FAIL date has type Date
>  dput(head(failure_subset2, n=1000))
> structure(list(FAILDATE = structure(c(17597, 17597, 17347, 17334,
> 17148, 17168, 17299, 17402, 17406, 17347, 17505, 17449, 17352,
> 17931, 17424, 17439, 17406, 17292, 17390, 17373, 17259, 17561,
> 17563, 17550, 17723, 17814, 17564, 17299, 17307, 17296, 17483,
> 17644, 17394, 17360, 17850, 17744, 17719, 17712, 17710, 18048,
> 18069, 17876, 17506, 17821, 18041, 17586, 18069, 18069, 18048,
> 17899, 17899, 17759, 17732, 17822, 17771, 17821, 17837, 17824,
> 17469, 17483, 17582, 17613, 18016, 18036, 18030, 17862, 17871,
> 17899, 17651, 17684, 17844, 17632, 17784, 17855, 17764, 17915,
> 18245, 18260, 18166, 18295, 18094, 18062, 18083, 18223, 18237,
> 18197, 18284, 18289, 18218, 18218, 18298, 18297, 18299, 17910,
> 18089, 18304, 18141, 18272, 18387, 18183, 18184, 18422, 18422,
> 18422, 18038, 17988, 18413, 17836, 18328, 18230, 18011, 18011,
> 17991, 18041, 18041, 18070, 18432, 18031, 18165, 18345, 18386,
> 17899, 18374, 18427, 18098, 18416, 18397, 18458, 18126, 18126,
> 18123, 18286, 17827, 18069, 18081, 18505, 18508, 18086, 18468,
> 18482, 18107, 18146, 18371, 18368, 18186, 18270, 17772, 18054,
> 17959, 18106, 18148, 18380, 18398, 17921, 18265, 18273, 18030,
> 18473, 18166, 18006, 18006, 18006, 18000, 17938, 18155, 18175,
> 18047, 18503, 18042, 18072, 17964, 18223, 17850, 17871, 18071,
> 18174, 18154, 18153, 18344, 18384, 18512, 18112, 18131, 18085,
> 18094, 18096, 18100, 18477, 17967, 17752, 17964, 18491, 18124,
> 18115, 18166, 17912, 18489, 18087, 18130, 18170, 18169, 18175,
> 18177, 18226, 18376, 18374, 18217, 18226, 18135, 18136, 17942,
> 18099, 18031, 18032, 18107, 18041, 18062, 18078, 18087, 18249,
> 18081, 18231, 18195, 18192, 18213, 18209, 18156, 18157, 18157,
> 18158, 18159, 18053, 18221, 18185, 18311, 18239, 18258, 18390,
> 18390, 17997, 18197, 18095, 18145, 18101, 18194, 18260, 18260,
> 18202, 18447, 18450, 18088, 18249, 18206, 18290, 17995, 18270,
> 18282, 18251, 18157, 18094, 18437, 18299, 18333, 18035, 18146,
> 18010, 18395, 18204, 18259, 18311, 18335, 18444, 18444, 18453,
> 18453, 18192, 18098, 17969, 17680, 18147, 18147, 17977, 17996,
> 18001, 18399, 18432, 18354, 18147, 17912, 17995, 17995, 18221,
> 18428, 18447, 18452, 18264, 18321, 18334, 18386, 18156, 18371,
> 18345, 18156, 18164, 18029, 18433, 17602, 17931, 18290, 18339,
> 18424, 18052, 18052, 18166, 18540, 18783, 18166, 18607, 18606,
> 18606, 18594, 18592, 18805, 18648, 18768, 18887, 1, 18648,
> 18630, 18812, 18812, 18845, 18932, 18418, 18950, 18166, 18702,
> 18684, 18812, 18589, 18597, 18611, 18648, 18577, 19024, 19041,
> 19043, 18768, 19216, 18787, 19159, 18529, 18589, 18646, 18166,
> 18571, 18637, 18624, 18716, 18166, 18568, 18527, 18535, 18542,
> 18494, 18846, 18166, 18877, 18548, 18659, 18839, 18905, 18632,
> 18804, 18648, 18892, 18921, 18718, 18805, 18805, 18561, 18682,
> 18943, 18949, 18542, 18927, 18409, 19047, 19059, 18524, 18941,
> 18941, 18941, 18648, 19044, 18758, 19034, 18609, 18788, 18812,
> 18676, 19194, 18740, 18812, 18842, 18659, 19042, 18230, 19036,
> 19144, 19032, 18542, 19097, 18564, 18166, 18552, 18557, 18467,
> 19002, 19174, 18624, 18828, 18542, 18542, 18686, 18628, 18702,
> 19227, 19239, 19264, 17597, 17470, 17401, 17344, 17562, 17578,
> 17476, 17539, 17348, 17326, 17420, 17423, 17427, 17347, 17359,
> 17372, 17385, 17365, 17365, 17598, 17977, 17977, 17736, 17684,
> 17612, 17792, 17220, 17310, 17452, 17641, 17813, 17407, 17712,
> 17697, 17752, 17694, 17724, 17862, 17865, 17633, 18048, 17815,
> 17911, 17753, 17818, 17784, 17619, 17697, 17381, 17641, 17449,
> 17456, 17555, 17564, 17574, 17793, 17889, 17869, 17885, 17890,
> 17903, 17912, 17809, 17891, 17846, 17916, 18019, 18234, 18180,
> 18181, 18292, 

Re: [R] download.file strict certificate revocation check

2023-10-04 Thread Jim Lemon
Hello,
I am very sad to let you know that my husband Jim died in 18th September. I
apologise for not letting you know earlier but I had trouble finding the
password for his phone.
Kind regards,
Juel Briggs

On Thu, 5 Oct 2023, 02:07 Ivan Krylov  В Wed, 4 Oct 2023 14:32:49 +
> John Neset  пишет:
>
> > No change with True or False with R_LIBCURL_SSL_REVOKE_BEST_EFFORT
>
> Judging by the screenshot, it looks like you've set an R variable
> R_LIBCURL_SSL_REVOKE_BEST_EFFORT instead of setting an environment
> variable using Sys.setenv:
>
>  Sys.setenv('R_LIBCURL_SSL_REVOKE_BEST_EFFORT' = 'TRUE')
>
> (Use Sys.getenv to verify the result.)
>
> For the next time, most people on the R-help mailing list would
> probably appreciate it if you copied and pasted the text from the R
> console instead of attaching screenshots.
>
> --
> 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.
>

[[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] How to create an R input

2023-08-30 Thread Jim Lemon
HI Jeff,
This might give you a start.

add_stuff<-function(x) {
 x<-xinc<-NA
 finished<-FALSE
 while(is.na(x))
  x<-as.numeric(readline("What number do you want to start? "))
 while(is.na(xinc) || !finished) {
  xinc<-as.numeric(readline("What number do you want to add? "))
  if(is.numeric(xinc)) x<-x+xinc
  answer<-unlist(strsplit(readline("Do you want to keep doing this?
(y/n) "),""))[1]
  finished<-toupper(answer)!="Y"
 }
 return(x)
}

Jim

On Thu, Aug 31, 2023 at 11:46 AM Jeff Reichman  wrote:
>
> R Help
>
>
>
> Trying to figure out how to create a simple program that will as the user
> from a value input and simply add 5 units to that value then ask the user
> for another value  and add 45 units to it  and on and on. Then how does one
> exit the loop of program?
>
>
>
> # Create a function called `add_five`
>
> add_five <- function(x) {
>
>   # Add 5 to the input value
>
>   x + 5
>
> }
>
>
>
> readline(prompt = "Enter a number: ")
>
>
>
> Jeff
>
>
> [[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] OFF TOPIC: chatGPT glibly produces a lot of wrong answers?

2023-08-13 Thread Jim Lemon
Hi Bert,
The article notes that chatGPT often gets the concept wrong, rather
than the facts. I think this can be traced to the one who poses the
question. I have often encountered requests for help that did not ask
for what was really wanted. I was recently asked if I could
graphically concatenate years of derived quantities that were based on
an aggregation of daily cycles. You get an average daily cycle for
each year, but this doesn't necessarily connect to the average daily
cycle for the next year. It didn't work, but it was a case of YKWIM
(You Know What I Mean). In this failure of communication, the
questioner frames the question in a way that may be figured out by a
human, but is not logically consistent. It is the basis for some very
funny scenes in Douglas Adams' "Hitchhiker" series, but can be
intensely frustrating to both parties in real life.

Jim

On Mon, Aug 14, 2023 at 3:50 AM Bert Gunter  wrote:
>
> **OFF TOPIC** but perhaps of interest to some on this list. I apologize in
> advance to those who may be offended.
>
> The byline:
> 
> "ChatGPT's odds of getting code questions correct are worse than a coin flip
>
> But its suggestions are so annoyingly plausible"
> *
> from here:
> https://www.theregister.com/2023/08/07/chatgpt_stack_overflow_ai/
>
> Hmm... Perhaps not surprising. Sounds like some expert consultants I've
> met. 
>
> Just for amusement. I am ignorant about this and have no strongly held
> views,
>
> Cheers to all,
> Bert
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
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] Seeking Assistance: Plotting Sea Current Vectors in R

2023-07-25 Thread Jim Lemon
Hi Kostas,
The function vectorField in the plotrix package may do what you want.
See the example.

Jim

On Tue, Jul 25, 2023 at 9:30 PM konstantinos christodoulou
 wrote:
>
> Dear Rcommunity,
>
> I hope this email finds you well. I am writing to seek your assistance with
> a data visualization problem I am facing while working with R.
>
> Problem Description:
>
> I have a dataframe named "df" containing the following columns:
> "longitude", "latitude", "sea_currents_mag", and "sea_currents_direction".
> The dataframe includes sea current estimations, with information about
> magnitude (m/s) and direction (degrees) at various longitude and latitude
> coordinates. The study domain covers the Eastern Mediterranean Sea (23E to
> 36W) and extends from 31S to 37N. It is important to note that the
> longitude and latitude coordinates are not evenly spaced across the domain.
>
> Objective: I am seeking guidance on how to create a plot that visualizes
> the sea current vectors (arrows) at each coordinate. Additionally, if
> possible, I would like the borders of the surrounding countries to be
> included in the plot to provide geographic context.
>
> Specific Requests:
>
>1. Help with plotting sea current vectors (arrows) based on
>"sea_currents_mag" and "sea_currents_direction" at each corresponding
>longitude and latitude coordinate.
>2. Assistance with including the borders of the surrounding countries in
>the plot to provide geographic context.
>
> I would highly appreciate any advice, code examples, or packages that could
> assist me in achieving this visualization goal.
>
> Thank you very much for taking the time to read my email, and I look
> forward to any assistance you can provide.
>
> Best regards,
> Kostas
>
> [[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] Off-topic: ChatGPT Code Interpreter

2023-07-17 Thread Jim Lemon
I haven't really focused on the statistical capabilities of AI, that
marriage of massive memory and associative learning. I am impressed by
its ability to perform text-to-image conversion, something I have
recently needed. My artistic ability is that of the average three year
old, yet I can employ AI to translate my mental images into realistic
pictures. Perhaps we really are learning about how we think. As far as
I am aware, it just does what we tell it to do. Like other tools, it
is as good or bad as the user.

Jim

__
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] ggplot: Can plot graphs with points, can't plot graph with points and line

2023-07-12 Thread Jim Lemon
Hi John,
I'm not sure how to do this with ggplot, but:

Time<- c("Age.25","Age.35","Age.45","Age.55")
Medians<-c(128.25,148.75,158.5,168.75)
> is.character(Time)
# [1] TRUE - thus it has no intrinsic numeric value to plot
> is.numeric(Medians)
# [1] TRUE
# coerce Medians to factor and then plot against Time, but can't do point/line
plot(as.factor(Time),Medians,type="p")
# let R determine the x values (1:4) and omit the x-axis
plot(Medians,type="b",xaxt="n")
# add the x-axis with the "Time" labels
axis(1,at=1:4,labels=Time)


On Thu, Jul 13, 2023 at 11:18 AM Sorkin, John  wrote:
>
> I am trying to plot four points, and join the points with lines. I can plot 
> the points, but I can't plot the points and the line.
> I hope someone can help my with my ggplot code.
>
> # load ggplot2
> if(!require(ggplot2)){install.packages("ggplot2")}
> library(ggplot2)
>
> # Create data
> Time   <- c("Age.25","Age.35","Age.45","Age.55")
> Medians<-c(128.25,148.75,158.5,168.75)
> themedians <- matrix(data=cbind(Time,Medians),nrow=4,ncol=2)
> dimnames(themedians) <- list(NULL,c("Time","Median"))
> # Convert to dataframe the data format used by ggplot
> themedians <- data.frame(themedians)
> themedians
>
> # This plot works
> ggplot(themedians,aes(x=Time,y=Median))+
>   geom_point()
> # This plot does not work!
> ggplot(themedians,aes(x=Time,y=Median))+
>   geom_point()+
>   geom_line()
>
> Thank you,
> John
>
> __
> 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] Plotting factors in graph panel

2023-06-29 Thread Jim Lemon
Okay. Here is a modification that does four single line plots.

at_df<-read.table(text=
 "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
Bank_Savings Bank_NA
 $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
 $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
 $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
 $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
 >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208
 No_Answer 9 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
 header=TRUE,stringsAsFactors=FALSE)
at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
png("Income_pcts.png",height=700)
par(mfrow=c(4,1))
plot(at_df[,"Bank_Current"],
 type="l",lwd=3,main="Bsnk_Current",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"Bank_Savings"],
 type="l",lwd=3,main="Bank_Sasvings",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"MF_Equity"],
 type="l",lwd=3,main="MF_Equity",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
plot(at_df[,"MF_Debt"],
 type="l",lwd=3,main="MF_Debt",
 xlab="Income",ylab="%",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
dev.off()

Jim

On Thu, Jun 29, 2023 at 1:49 PM Anupam Tyagi  wrote:
>
> Thanks, Pikal and Jim. Yes, it has been a long time Jim. I hope you have
> been well.
>
> Pikal, thanks. Your solution may be close to what I want. I did not know
> that I was posting in HTML. I just copied the data from Excel and posted in
> the email in Gmail. The data is still in Excel, because I have not yet
> figured out what is a good way to organize it in R. I am posting it again
> below as text. These are rows in Excel: 1,2,3,5,9 after MF are income
> categories and No Answer category (9). Down the second column are
> categories of MF and Bank AC. Rest of the columns are percentages.
>
> Jim, thanks for the graph. I am looking to plot only one line (category)
> each in many small plots on the same page. I don't want to compare
> different categories on the same graph as you do, but see how each category
> varies by income, one category in each graph. Like Excel does with
> Sparklines (Top menu: Insert, Sparklines, Lines). I have many categories
> for many variables. I am only showing two MF and Bank AC.
>
> Income $10 $25 $40 $75 > $75 No Answer
> MF 1 2 3 4 5 9
> None 1 3.05 2.29 2.24 1.71 1.30 2.83
> Equity 2 29.76 28.79 29.51 28.90 31.67 36.77
> Debt 3 31.18 32.64 34.31 35.65 37.59 33.15
> Hybrid 4 36.00 36.27 33.94 33.74 29.44 27.25
> Bank AC
> None 1 46.54 54.01 59.1 62.17 67.67 60.87
> Current 2 24.75 24.4 25 24.61 24.02 21.09
> Savings 3 25.4 18.7 29 11.48 7.103 13.46
> No Answer 9 3.307 2.891 13.4 1.746 1.208 4.577
>
>
> On Wed, 28 Jun 2023 at 17:30, Jim Lemon  wrote:
>
> > Hi Anupam,
> > Haven't heard from you in a long time. Perhaps you want something like
> > this:
> >
> > at_df<-read.table(text=
> >  "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
> > Bank_Savings Bank_NA
> >  $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
> >  $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
> >  $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
> >  $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
> >  >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208
> >  No_Answer 9 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
> >  header=TRUE,stringsAsFactors=FALSE)
> > at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
> > png("MF_Bank.png",height=600)
> > par(mfrow=c(2,1))
> > matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
> >  type="l",col=1:4,lty=1:4,lwd=3,
> >  main="Percentages by Income and MF type",
> >  xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
> >  lty=1:4,lwd=3,col=1:4)
> > matplot(at_df[,c("Bank_None","Bank_Current","Bank_Savings")],
> >  type="l",col=1:3,lty=1:4,lwd=3,
> >  main="Percentages by Income and Bank type",
> >  xlab="Income",ylab="Percentage of group",xaxt="n")
> > axis(1,at=1:5,labels=at_df$Income)
> > legend(3,54,c("Bank_None","Bank_

Re: [R] Plotting factors in graph panel

2023-06-28 Thread Jim Lemon
Hi Anupam,
Haven't heard from you in a long time. Perhaps you want something like this:

at_df<-read.table(text=
 "Income MF MF_None MF_Equity MF_Debt MF_Hybrid Bank_None Bank_Current
Bank_Savings Bank_NA
 $10 1 3.05 29.76 31.18 36.0 46.54 24.75 25.4 3.307
 $25 2 2.29 28.79 32.64 36.27 54.01 24.4 18.7 2.891
 $40 3 2.24 29.51 34.31 33.94 59.1 25.0 29 13.4
 $75 4 1.71 28.90 35.65 33.74 62.17 24.61 11.48 1.746
 >$75 5 1.30 31.67 37.59 29.44 67.67 24.02 7.103 1.208
 No_Answer 9 2.83 36.77 33.15 27.25 60.87 21.09 13.46 4.577",
 header=TRUE,stringsAsFactors=FALSE)
at_df<-at_df[at_df$Income!="No_Answer",which(names(at_df)!="Bank_NA")]
png("MF_Bank.png",height=600)
par(mfrow=c(2,1))
matplot(at_df[,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid")],
 type="l",col=1:4,lty=1:4,lwd=3,
 main="Percentages by Income and MF type",
 xlab="Income",ylab="Percentage of group",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
legend(3,24,c("MF_None","MF_Equity","MF_Debt","MF_Hybrid"),
 lty=1:4,lwd=3,col=1:4)
matplot(at_df[,c("Bank_None","Bank_Current","Bank_Savings")],
 type="l",col=1:3,lty=1:4,lwd=3,
 main="Percentages by Income and Bank type",
 xlab="Income",ylab="Percentage of group",xaxt="n")
axis(1,at=1:5,labels=at_df$Income)
legend(3,54,c("Bank_None","Bank_Current","Bank_Savings"),
 lty=1:4,lwd=3,col=1:3)
dev.off()

Jim

On Wed, Jun 28, 2023 at 6:33 PM Anupam Tyagi  wrote:
>
> Hello,
>
> I want to plot the following kind of data (percentage of respondents from a
> survey) that varies by Income into many small *line* graphs in a panel of
> graphs. I want to omit "No Answer" categories. I want to see how each one
> of the categories (percentages), "None", " Equity", etc. varies by Income.
> How can I do this? How to organize the data well and how to plot? I thought
> Lattice may be a good package to plot this, but I don't know for sure. I
> prefer to do this in Base-R if possible, but I am open to ggplot. Any ideas
> will be helpful.
>
> Income
> $10 $25 $40 $75 > $75 No Answer
> MF 1 2 3 4 5 9
> None 1 3.05 2.29 2.24 1.71 1.30 2.83
> Equity 2 29.76 28.79 29.51 28.90 31.67 36.77
> Debt 3 31.18 32.64 34.31 35.65 37.59 33.15
> Hybrid 4 36.00 36.27 33.94 33.74 29.44 27.25
> Bank AC
> None 1 46.54 54.01 59.1 62.17 67.67 60.87
> Current 2 24.75 24.4 25 24.61 24.02 21.09
> Savings 3 25.4 18.7 29 11.48 7.103 13.46
> No Answer 9 3.307 2.891 13.4 1.746 1.208 4.577
>
> Thanks.
> --
> Anupam.
>
> [[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] Plotrix pyramid plot: request for a little help

2023-06-06 Thread Jim Lemon
Hi Mohsin,
I must  have hit the wrong key and sent the last email. The last
paragraph should read:

To answer your question, I used the "laxlab" and "raxlab" arguments. I
also extended them to 0-200 to cover the range of the largest counts.
You can use 0-150 for both, but it is not a good idea to request
different labels, as the plot won't be correct. I added
the unit="Count", which you can delete if you don't want it. I think
it's a good idea to let the viewer know what the units are.

I have also attached an image which didn't get into the last email.

Jim
__
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] Plotrix pyramid plot: request for a little help

2023-06-06 Thread Jim Lemon
Hi Mohsin,
As I don't have your data, I had to fake it, so there are probably
some mistakes in the example below:

# my suggestion
x<-c(143,108,95,72,70,85,125,123,64,67,144,55,60,200,70,100,65,140,49,45,77,58,66,50,77)
y<-c(41,32,28,13,15,29,72,71,17,180,9,13,145,29,56,22,97,13,9,42,20,7,30,10,41)
labels<-c("sector","increase","period","foreign","compared","exchange","rate",
 "expected","impact","mpc","oil","sbp","growth","credit","economic","private",
 "year","government","improvement","months","average","cpi","real","net",
 "developments")
top25_df<-data.frame(x=x,y=y,labels=labels)
pyramid.plot(top25_df$x,top25_df$y,
 labels=top25_df$labels,
 main="Words Common in MPS statements",
 gap=40,
 unit="Count",
 top.labels=c("2016-20","Words","2021-23"),
 laxlab=seq(0,200,by=25),raxlab=seq(0,200,by=25))

To answer your question, I used the "laxlab" and "raxlab" arguments. I
also extended them to 0-200 to cover the range of the largest counts.
You can use 0-150 for both, but it is not a good idea to req I added
the unit="Count", which you can delete if you don't want it. I think
it's a good idea to let the viewer know what the units are. Apart from

On Tue, Jun 6, 2023 at 3:39 PM Mohsin Waheed  wrote:
>
> Hi,
>
>
>
> I am working on a research study wherein I have employed a variety of textual 
> analysis methods including plotrix pyramid plot. However, with the pyramid 
> plot, I am unable to set the x-axis limits; for example, how can I manually 
> define the frequency range as 0, 50, 100, 150…
>
>
>
> Would really appreciate your reply. Plot and codes files are attached for 
> your perusal.
>
>
>
> Regards,
>
>
>
> Mohsin
>
>
>
>
>
> Sent from Mail for Windows
>
>

__
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] Circular plot - polar plot code questions

2023-04-24 Thread Jim Lemon
Hi Bruce,
Reading your message, I get the idea that you want a radial.plot with
arcs to indicate "at least one bat is in this state'.This can be done
with an addition to the rp.type= argument. If you already have what
you want in this format, it may not be worth programming it. However,
if you want "how many bats are in this state":

m <- read.table(
 text="id T month P L
 10100
 20200
 30300
 41400
 51510
 61611
 70711
 80811
 90901
 1001000
 1101100
 1201200",
 header=TRUE)
 library(plotrix)
png("batstate.png",width=600)
kiteChart(t(m[,c("T","P","L")]),
 main="Bat state by month",
 xlab="Month",ylab="State",
 varlabels=c("Testiular enlargement","Pregnant","Lactatins"),
 timelabels=month.abb)
dev.off()

Jim

On Mon, Apr 24, 2023 at 7:22 PM Bruce Miller  wrote:
>
> Hi all...
> I assume there are a host of GGplot2 users out there.
> I have circular plot - polar plot code questions
> I needed to create circular – polar plots of reproductive status for
> bats.  I found a great sample of how to do this here:
> https://stackoverflow.com/questions/41081376/how-to-create-a-circular-plot-showing-monthly-presence-or-absence-using-radial-p
>
> I modified the sample code to meet the 3 data elements I am using the
> "raw data" table below with T=testes enlarge, P= Pregnant and L= Lactating.
>
> library(data.table)
>
>
> m <- fread("idTmonthPL
> 10100
> 20200
> 30300
> 41400
> 51510
> 61611
> 70711
> 80811
> 90901
> 1001000
> 1101100
> 1201200")
> # reshape from wide to long (as preferred by ggplot)
> ml <- melt(m, measure.vars = c("T", "P", "L"))
>
> # create factors to ensure desired order
> ml[, variable := factor(variable, levels = c("T", "P","L"))]
>
> ml[, fct_month := factor(month, levels = 1:12, labels = month.abb)]
> library(ggplot2)
> ggplot(ml[value != 0], aes(x = fct_month, y = variable,
> group = variable, colour = variable)) +
>geom_line(size = 3) +
>scale_y_discrete(expand = c(0, 1), breaks = NULL) +
>xlim(month.abb) +
>coord_polar() +
>theme_bw() + xlab(NULL) + ylab(NULL)
>
> This is creating a plot more or less as needed.  4 questions:
> 1 Do I even need the ID field? Seems not useful.
> 2 I assume the melt step can be avoided if my data is "Tidy" and long
> format at the start, correct?
> 3  How can I increase the weight of the month lines and labels
> 4  Where can I add color choices for the 3 variables in the plot? Simply
> adding an HTML color number to the “colour=variable” then plots the data
> and labeling one value as that color.
>
> Tnx all. The list is always educational on a daily basis.
> Cheers,
> Bat Dude
> [[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] Query about code

2023-04-22 Thread Jim Lemon
Hi Yeswanth,
As it says on the bottom ofthe first page, the corresponding author it:

yangj...@ms.xjb.ac.cn

Try that email address.

Jim

On Sat, Apr 22, 2023 at 2:59 PM ADIGARLA YESWANTH NAIDU
<102213...@smail.iitpkd.ac.in> wrote:
>
> Thanks for your reply sir ,
> Here is the reference,I want to follow the procedure which they have 
> mentioned in the method.
>
> Best Regards,
> Yeswanth,
>
> On Sat, Apr 22, 2023 at 4:08 AM Bert Gunter  wrote:
>>
>> "Perhaps you could supply a reference to
>> the work you are using?"
>>
>> ... in which case they should simply email the author directly, no?
>>
>> -- Bert
>>
>> On Fri, Apr 21, 2023 at 3:22 PM Jim Lemon  wrote:
>> >
>> > Hi Yeswanth,
>> > You seem to be referring to a specific publication by a specific
>> > author. Unless someone in R-help knows who and what you are referring
>> > to, it seems very difficult. Perhaps you could supply a reference to
>> > the work you are using?
>> >
>> > JIm
>> >
>> > On Sat, Apr 22, 2023 at 7:03 AM ADIGARLA YESWANTH NAIDU
>> > <102213...@smail.iitpkd.ac.in> wrote:
>> > >
>> > > I have been trying to write the code for the CCM analysis that you used 
>> > > in
>> > > your study, but unfortunately, I haven't been able to write it. I was
>> > > wondering if you would be willing to share the code with me. I understand
>> > > that the code may be your intellectual property, but I assure you that I
>> > > will use it solely for academic and non-commercial purposes.
>> > >
>> > > If you are able to share the code, I would greatly appreciate it. The 
>> > > code
>> > > will be a valuable resource for me to understand the implementation 
>> > > details
>> > > and reproduce the results of your study. Alternatively, if you are unable
>> > > to share the code, I would be grateful for any guidance or suggestions 
>> > > you
>> > > can provide in implementing the CCM analysis using the rEDM and
>> > > multispatialCCM packages.
>> > >
>> > > Thank you very much for your consideration. I look forward to your 
>> > > positive
>> > > response.
>> > >
>> > > Best regards,
>> > > Yeswanth.
>> > >
>> > > [[alternative HTML version deleted]]
>> > >
>> > > __
>> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > > https://stat.ethz.ch/mailman/listinfo/r-help
>> > > PLEASE do read the posting guide 
>> > > http://www.R-project.org/posting-guide.html
>> > > and provide commented, minimal, self-contained, reproducible code.
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Query about code

2023-04-21 Thread Jim Lemon
Hi Yeswanth,
You seem to be referring to a specific publication by a specific
author. Unless someone in R-help knows who and what you are referring
to, it seems very difficult. Perhaps you could supply a reference to
the work you are using?

JIm

On Sat, Apr 22, 2023 at 7:03 AM ADIGARLA YESWANTH NAIDU
<102213...@smail.iitpkd.ac.in> wrote:
>
> I have been trying to write the code for the CCM analysis that you used in
> your study, but unfortunately, I haven't been able to write it. I was
> wondering if you would be willing to share the code with me. I understand
> that the code may be your intellectual property, but I assure you that I
> will use it solely for academic and non-commercial purposes.
>
> If you are able to share the code, I would greatly appreciate it. The code
> will be a valuable resource for me to understand the implementation details
> and reproduce the results of your study. Alternatively, if you are unable
> to share the code, I would be grateful for any guidance or suggestions you
> can provide in implementing the CCM analysis using the rEDM and
> multispatialCCM packages.
>
> Thank you very much for your consideration. I look forward to your positive
> response.
>
> Best regards,
> Yeswanth.
>
> [[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] single character in R, and how to manipulate it

2023-03-30 Thread Jim Lemon
Also see the "arctext" function in the plotrix package.

Jim

On Fri, Mar 31, 2023 at 11:12 AM Jim Lemon  wrote:
>
> Hi Jinsong,
> Maybe "srt" will do what you want. As you noted non-orthogonal
> rotations may not work on some devices. You may be able to download
> mirror fonts from places like fontmirror.com, but it more complicated.
>
> Jim
>
> On Thu, Mar 30, 2023 at 7:25 PM Jinsong Zhao  wrote:
> >
> > Hi there,
> >
> >
> > I just noticed that "crt" is a graphical parameter, which is stated as 
> > follows in the help page of "par":
> > A numerical value specifying (in degrees) how single characters should be 
> > rotated. It is unwise to expect values other than multiples of 90 to work...
> >
> >
> > However, I did not find any code example to demo the usage of "crt", and 
> > even know how to present a *single character* in R. It seems that R treats 
> > "A" as a string. If I wanted to rotated it in a plot, I could use "text" 
> > function with "srt" argument. But how to use "crt"?
> >
> >
> > Another related question, how to mirror a character in R plot? For example, 
> > the mirror of "R" is something like "Я".
> >
> >
> > Any hint? Thanks in advance.
> >
> >
> > Best,
> > Jinsong
> > [[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] single character in R, and how to manipulate it

2023-03-30 Thread Jim Lemon
Hi Jinsong,
Maybe "srt" will do what you want. As you noted non-orthogonal
rotations may not work on some devices. You may be able to download
mirror fonts from places like fontmirror.com, but it more complicated.

Jim

On Thu, Mar 30, 2023 at 7:25 PM Jinsong Zhao  wrote:
>
> Hi there,
>
>
> I just noticed that "crt" is a graphical parameter, which is stated as 
> follows in the help page of "par":
> A numerical value specifying (in degrees) how single characters should be 
> rotated. It is unwise to expect values other than multiples of 90 to work...
>
>
> However, I did not find any code example to demo the usage of "crt", and even 
> know how to present a *single character* in R. It seems that R treats "A" as 
> a string. If I wanted to rotated it in a plot, I could use "text" function 
> with "srt" argument. But how to use "crt"?
>
>
> Another related question, how to mirror a character in R plot? For example, 
> the mirror of "R" is something like "Я".
>
>
> Any hint? Thanks in advance.
>
>
> Best,
> Jinsong
> [[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] Shaded area

2023-03-12 Thread Jim Lemon
Hi all,
I was quite intrigued by George's question, for I thought this might
be a problem faced by many. The solution attached is only useful for a
monotonically increasing x vector, a paired vector of y values, and a
criterial value above which a polygon will be displayed. More work
would needed for curves that are above the criterial value at the
beginning or end, and a corresponding argument to fill the area
_below_ the criterial value. If it is useful, I can probably do a bit
more work on it.

Jim

On Fri, Mar 3, 2023 at 11:58 PM John Kane  wrote:
>
> As Peter says, the list is very cautious about what types of files it
> allows. A handy way to supply some sample data is the dput() function.  In
> the case of a large dataset something like dput(head(mydata, 100)) should
> supply the data we need. Just do dput(mydata) where *mydata* is your data.
> Copy the output and paste it here.
>
> On Wed, 1 Mar 2023 at 09:58, PIKAL Petr  wrote:
>
> > Hallo
> >
> > Excel attachment is not allowed here, but shading area is answered many
> > times elsewhere. Use something like . "shading area r" in google.
> >
> > See eg.
> > https://www.geeksforgeeks.org/how-to-shade-a-graph-in-r/
> >
> > Cheers Petr
> >
> > -Original Message-
> > From: R-help  On Behalf Of George Brida
> > Sent: Wednesday, March 1, 2023 3:21 PM
> > To: r-help@r-project.org
> > Subject: [R] Shaded area
> >
> > Dear R users,
> >
> > I have an xlsx file (attached to this mail) that shows the values of a
> > "der" series observed on a daily basis from January 1, 2017 to January 25,
> > 2017. This series is strictly positive during two periods: from January 8,
> > 2017 to January 11, 2017 and from January 16, 2017 to January 20, 2017. I
> > would like to plot the series with two shaded areas corresponding to the
> > positivity of the series. Specifically, I would like to draw 4 vertical
> > lines intersecting the x-axis in the 4 dates mentioned above and shade the
> > two areas of positivity. Thanks for your help.
> > __
> > 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.
> > Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> > partnerů PRECHEZA a.s. jsou zveřejněny na:
> > https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
> > about processing and protection of business partner’s personal data are
> > available on website:
> > https://www.precheza.cz/en/personal-data-protection-principles/
> > Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> > důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
> > odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> > documents attached to it may be confidential and are subject to the legally
> > binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
> >
> > __
> > 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.
> >
>
>
> --
> John Kane
> Kingston ON Canada
>
> [[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] MFA variables graph, filtered by separate.analyses

2023-02-21 Thread Jim Lemon
Hi Gavin,
I can't work through this right now, but I would start by looking at
the 'hetcor' package to get the correlations, or if they are already
in the return object, build a plot from these.

Jim

On Wed, Feb 22, 2023 at 4:24 AM gavin duley  wrote:
>
> Hi!
>
> Apologies if this is not the correct place to ask. I am attempting a
> MFA analysis of a dataset based on wine chemical and sensory analysis,
> based on the STHDA tutorial [1]. (I am using this dataset here too, as
> an example dataset to work on without posting my actual data. I've
> tried this with both my data and the example data, with the exact same
> results.)
>
> The only issue I am having is that I would like to produce a graph
> showing the correlation between qualitative variables, quantitative
> variables, and dimensions for some but not all analyses types. For
> example, it would be good to see only origin, odor, and
> odor.after.shaking on the graph.
>
> By default, it doesn't seem possible to include both qualitative and
> qualitative data in the correlation graph, or to filter by
> res.mfa$separate.analyses.
>
> I am using the code:
> fviz_mfa_var(res.mfa, choice=c("quanti.var","group","quali.var"),
> palette = "jco",
>  col.var.sup = "violet", repel = TRUE)
>
> I have tried using select.ind with no change. This just produces the
> same graph as above:
> fviz_mfa_var(res.mfa, choice=c("quanti.var","group","quali.var"),
> palette = "jco",
>   col.var.sup = "violet", repel = TRUE,
>   
> select.ind=list(name=c(res.mfa$separate.analyses$origin,res.mfa$separate.analyses$odor,
>   res.mfa$separate.analyses$odor.after.shaking)))
>
> Attempting to simplify by just specifying one name (as a trial) does
> not work either.
>
> Is this actually possible? If so, how would it be best to attempt it?
>
> With thanks,
> gavin,
>
> [1] 
> http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/116-mfa-multiple-factor-analysis-in-r-essentials/
>
> --
> Gavin Duley 
>
> __
> 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] overlaying two graphs / plots /lines

2023-02-07 Thread Jim Lemon
Hi Bogdan,
Try this:

A<-data.frame(x=c(1,7,9,20),
 y=c(39,91,100,3))
B<-data.frame(x=c(10,21,67,99,200),
 y=c(9,89,1000,90,1001)) # one value omitted to equalize the rows
xrange<-range(c(unlist(A$x),unlist(B$x)))
yrange<-range(c(unlist(A$y),unlist(B$y)))
plot(A,type="l",xlim=xrange,ylim=yrange,col="red")
lines(B,lty=2,col="blue")
legend(150,400,c("A","B"),lty=1:2,col=c("red","blue"))

There are other tricks to deal with the differences in range between A and B.

Jim

On Wed, Feb 8, 2023 at 7:57 AM Bogdan Tanasa  wrote:
>
>  Dear all,
>
> Any suggestions on how I could overlay two or more graphs / plots / lines
> that have different sizes and the x axes have different breakpoints.
>
> One dataframe is : A :
>
> on x axis : 1 , 7, 9, 20, etc ... (100 elements)
> on y axis : 39, 91, 100, 3, etc ... (100 elements)
>
>
> The other dataframe is : B :
>
> on x axis : 10, 21, 67, 99, 200 etc .. (200 elements).
> on y axis :  9, 0, 89, 1000, 90, 1001. ... (200 elements).
>
> Thanks a lot,
>
> Bogdan
>
> [[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] Extracting data using subset function

2023-02-05 Thread Jim Lemon
Hi Upananda,
As a couple of respondents noted, you only need the logical statement,
not subset().

You did "frame the logical condition" in your example, for if you use
the extraction operator "[" this will work:
subset(p,(1:length(p)) <= 20)
as Jeff already pointed out. Obviously it is easier to write:
p[(1:length(p)) <= 20]

Let's say you want to select the odd numbers in p:
p<-1:10
as.logical(p%%2)
[1]  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
p[as.logical(p%%2)]
[1] 1 3 5 7 9
The as.logical() has to be included as the extractor function tries
use integers as indices

So the problem is really to reduce your selection criteria to a vector
of TRUER/FALSE values.

Jim

On Mon, Feb 6, 2023 at 1:07 AM Upananda Pani  wrote:
>
> Dear All,
>
> I want to create a vector p and extract first 20 observations using subset
> function based on logical condition.
>
> My code is below
>
> p <- 0:100
>
> I know i can extract the first 20 observations using the following command.
>
> q <- p[1:20]
>
> But I want to extract the first 20 observations using subset function which
> requires a logical condition. I am not able to frame the logical condition.
>
> The code should be
>
> q <- subset(p, logical condition)
>
> I am not able to do it. Please let me know what you think.
>
> Best regards,
> Upananda
>
> [[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] Reg: To change the x axis label in ts.plot function

2022-12-24 Thread Jim Lemon
Hi Upananda,
First, the date sequence you are using doesn't match the dates you
specify in your post. The code below may give you what you want:

# make up some prices
price<-c(seq(60,25,length.out=25),seq(25,70,length.out=54))+rnorm(79)
pricet <- ts(price, start = as.Date("2020-01-27"),end=as.Date("2021-07-26"),
frequency=1/7)
plot(pricet,xaxt="n")
axis_dates<-as.Date(c("2020-06-30","2021-01-01","2021-06-30"))
axis(1,at=axis_dates,labels=format(axis_dates,"%d/%m/%Y"))

Jim

On Sun, Dec 25, 2022 at 5:58 AM Upananda Pani  wrote:
>
>   Dear All,
>  I have the data set with daily dates (5-days trading in a week) and price
> data. I want to change the x axis labels to the plot. I am using ts.plot
> function to plot my data. My data spans from 2020-01-27 to 2021-07-30. I
> want to change it to D-M-Y first. Then I want to show all the dates with a
> one week gap in my x-axis label.
>
>  The following code I am using:
>  pricet <- ts(price, start = c(2020, 27), frequency = 260)
> plot.ts(pricet)
>
> Please advise me how to achieve the desired result. I have attached my data
> and the plot which I am currently getting with ts.plot.
>
> With sincere regards,
> Upananda Pani
> __
> 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] Format printing with R

2022-11-21 Thread Jim Lemon
Hi Steven,
I thought that the problem might be in the two large numbers, but
using a subset (I didn't want to edit out all the line numbers), I get
what I expected:

sydf<-read.table(text="Mean   Std.dev
 [1,]  0.3107966  0.462820
 [2,]  0.1880302  0.390736
 [3,] 45.3185794 16.313635
 [4,]  0.5066370  0.499956
 [5,]  0.4933630  0.499956
 [6,]  0.7029150  0.456974
 [7,]  0.2970850  0.456974
 [8,]  0.7967066  0.402449
 [9,]  0.2032934  0.402449",
stringsAsFactors=FALSE,header=TRUE)
> print(sydf,digits=2)
 Mean Std.dev
[1,]  0.310.46
[2,]  0.190.39
[3,] 45.32   16.31
[4,]  0.510.50
[5,]  0.490.50
[6,]  0.700.46
[7,]  0.300.46
[8,]  0.800.40
[9,]  0.200.40

I don't think it is your use of "cbind", but I didn't edit out Mean
and Std.dev and try it.

Jim

On Tue, Nov 22, 2022 at 7:41 AM Steven T. Yen via R-help
 wrote:
>
> Hi, I have two variables with 86 observations each. Below I print with
> the print command with digit=2. But, I am getting three decimal places
> for my first variable and two for the second. Please help. Thanks.
>
>  > cbind(Mean,Std.dev)
>  Mean   Std.dev
>   [1,]  0.3107966  0.462820
>   [2,]  0.1880302  0.390736
>   [3,] 45.3185794 16.313635
>   [4,]  0.5066370  0.499956
>   [5,]  0.4933630  0.499956
>   [6,]  0.7029150  0.456974
>   [7,]  0.2970850  0.456974
>   [8,]  0.7967066  0.402449
>   [9,]  0.2032934  0.402449
> [10,]  0.6582301  0.474303
> [11,]  0.3417699  0.474303
> [12,]  0.7262913  0.445861
> [13,]  0.2737087  0.445861
> [14,]  0.6415484  0.479546
> [15,]  0.3584516  0.479546
> [16,]  0.9110264  0.284706
> [17,]  0.0889736  0.284706
> [18,]  0.5211453  0.499553
> [19,]  0.4788547  0.499553
> [20,]  0.5481055  0.497680
> [21,]  0.4518945  0.497680
> [22,]  0.9135090  0.281088
> [23,]  0.0864910  0.281088
> [24,]  0.8727269  0.333279
> [25,]  0.1272731  0.333279
> [26,]  0.1015717  0.302084
> [27,]  0.6043692  0.488986
> [28,]  0.2940592  0.455619
> [29,]  0.2735274  0.445769
> [30,]  0.3777426  0.484823
> [31,]  0.3487300  0.476568
> [32,]  0.1603127  0.366896
> [33,]  0.1723783  0.377709
> [34,]  0.1230961  0.328547
> [35,]  0.1779381  0.382461
> [36,]  0.0964334  0.295185
> [37,]  0.1584698  0.365181
> [38,]  0.1113717  0.314592
> [39,]  0.3349813  0.471984
> [40,]  0.4081109  0.491484
> [41,]  0.2569078  0.436928
> [42,]  0.1034356  0.304527
> [43,]  0.6741233  0.468701
> [44,]  0.1254412  0.331218
> [45,]  0.096  0.295958
> [46,]  0.0587457  0.235148
> [47,]  0.4401115  0.496400
> [48,]  0.4689114  0.499033
> [49,]  0.0322313  0.176614
> [50,]  0.5907618  0.491693
> [51,]  0.1591195  0.365787
> [52,]  0.1132923  0.316950
> [53,]  0.1124207  0.315883
> [54,]  0.0244058  0.154305
> [55,]  0.7058787  0.455647
> [56,]  0.2941213  0.455647
> [57,]  0.0746892  0.262889
> [58,]  0.4749110  0.499370
> [59,]  0.3471837  0.476075
> [60,]  0.0435036  0.203988
> [61,]  0.0597126  0.236954
> [62,]  0.0478775  0.213507
> [63,]  0.1152615  0.319337
> [64,]  0.2074968  0.405514
> [65,]  0.2440626  0.429530
> [66,]  0.1605995  0.367161
> [67,]  0.0804598  0.272004
> [68,]  0.1442422  0.351335
> [69,]  0.3443231  0.475147
> [70,]  0.4280560  0.494797
> [71,]  0.0528221  0.223678
> [72,]  0.0805222  0.272100
> [73,]  0.0457169  0.208870
> [74,]  0.0485596  0.214945
> [75,]  0.1333443  0.339946
> [76,]  0.0932917  0.290841
> [77,]  0.0653987  0.247228
> [78,]  0.0573934  0.232593
> [79,]  0.1399086  0.346892
> [80,]  0.0887337  0.284359
> [81,]  0.0984479  0.297919
> [82,]  0.0914421  0.288237
> [83,]  0.1155505  0.319685
> [84,]  0.1363764  0.343188
> [85,]  0.1134570  0.317151
> [86,]  1.2985286  0.739096
>  > print(cbind(Mean,Std.dev),digits=2)
>  Mean Std.dev
>   [1,]  0.3110.46
>   [2,]  0.1880.39
>   [3,] 45.319   16.31
>   [4,]  0.5070.50
>   [5,]  0.4930.50
>   [6,]  0.7030.46
>   [7,]  0.2970.46
>   [8,]  0.7970.40
>   [9,]  0.2030.40
> [10,]  0.6580.47
> [11,]  0.3420.47
> [12,]  0.7260.45
> [13,]  0.2740.45
> [14,]  0.6420.48
> [15,]  0.3580.48
> [16,]  0.9110.28
> [17,]  0.0890.28
> [18,]  0.5210.50
> [19,]  0.4790.50
> [20,]  0.5480.50
> [21,]  0.4520.50
> [22,]  0.9140.28
> [23,]  0.0860.28
> [24,]  0.8730.33
> [25,]  0.1270.33
> [26,]  0.1020.30
> [27,]  0.6040.49
> [28,]  0.2940.46
> [29,]  0.2740.45
> [30,]  0.3780.48
> [31,]  0.3490.48
> [32,]  0.1600.37
> [33,]  0.1720.38
> [34,]  0.1230.33
> [35,]  0.1780.38
> [36,]  0.0960.30
> [37,]  0.1580.37
> [38,]  0.1110.31
> [39,]  0.3350.47
> [40,]  0.4080.49
> [41,]  0.2570.44
> [42,]  0.1030.30
> [43,]  0.6740.47
> [44,]  0.1250.33
> [45,]  0.0970.30
> [46,]  0.0590.24
> [47,]  0.4400.50
> [48,]  0.4690.50
> [49,]  0.0320.18
> [50,]  0.5910.49
> [51,]  0.1590.37
> [52,]  0.1130.32
> [53,]  0.1120.32
> [54,]  0.0240.15
> [55,]  0.7060.46
> [56,]  0.294

Re: [R] Plotting a triangular prism

2022-11-10 Thread Jim Lemon
Hi Erin,
If you want a realistic 3D prism, I would use something like POVRay or
other rendering software. You have to know your geometry, but you can
get a very realistic image. I suspect that you want more than just a
picture of a prism, so you can then generate a PNG image and use it as
a layer in a composite image in something like the GIMP.

Jim

> > On Nov 10, 2022, at 5:46 PM, Erin Hodgess  wrote:
> >
> > Hello!
> >
> > I’m trying to draw a triangular prism.  I have used rgl, plot3d, and it’s
> > still not working as I would like.
> >
> > Has anyone done this, please?
> >
> > Thanks for any help.
> >
> > Sincerely,
> > Erin

__
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] Unsubscribe from mailing list please

2022-11-01 Thread Jim Lemon
Hi Eva,
As it says in the footer, go here:

https://stat.ethz.ch/mailman/listinfo/r-help

Jim

On Wed, Nov 2, 2022 at 6:51 AM Eva Maria Leunissen
 wrote:
>
> Hi,
>
> Could I please unsubscribe from the R-help mailing list?
>
> Thanks
>
> Eva
>
> [[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] pairwise.var.test

2022-10-30 Thread Jim Lemon
Hi Thomas,
I have assumed the format of your p-value matrix. This may require
some adjustment.

  A  B  C D   E   F
A 1  0.7464 0.01870.0865  0.0122  0.4693
B 0.7464 1  0.03580.1502  0.0173  0.3240
C 0.0187 0.0358 1 0.5131  0.7185  0.0050
D 0.0865 0.1502 0.51311   0.3240  0.0173
E 0.0122 0.0173 0.71850.3240  1   0.0029
F 0.4693 0.3240 0.00500.0173  0.0029  1

pvar.mat<-as.matrix(read.table(text=
 "1  0.7464 0.01870.0865  0.0122  0.4693
 0.7464 1  0.03580.1502  0.0173  0.3240
 0.0187 0.0358 1 0.5131  0.7185  0.0050
 0.0865 0.1502 0.51311   0.3240  0.0173
 0.0122 0.0173 0.71850.3240  1   0.0029
 0.4693 0.3240 0.00500.0173  0.0029  1",
 stringsAsFactors=FALSE))
rownames(pvar.mat)<-colnames(pvar.mat)<-LETTERS[1:6]
pvar.col<-matrix(NA,nrow=6,ncol=6)
pvar.col[pvar.mat < 1]<-"red"
pvar.col[pvar.mat < 0.05]<-"orange"
pvar.col[pvar.mat < 0.01]<-"green"
library(plotrix)
par(mar=c(6,4,4,2))
color2D.matplot(pvar.mat,cellcolors=pvar.col,
 main="P-values for matrix",axes=FALSE)
axis(1,at=seq(0.5,5.5,by=1),labels=LETTERS[1:6])
axis(2,at=seq(0.5,5.5,by=1),labels=rev(LETTERS[1:6]))
color.legend(0,-1.3,2.5,-0.7,c("NA","NS","<0.05","<0.01"),
 rect.col=c(NA,"red","orange","green"))

Jim

On Mon, Oct 31, 2022 at 6:34 AM Thomas Subia via R-help
 wrote:
>
> Colleagues,
>
> The RVAideMemoire package has a pairwise variance test which one can use to 
> identify variance differences between group levels.
>
> Using the example from this package, 
> pairwise.var.test(InsectSprays$count,InsectSprays$spray), we get this output:
>
> Pairwise comparisons using F tests to compare two variances
>
> data:  InsectSprays$count and InsectSprays$spray
>
>A  B C DE
> B 0.7464 -   -  -  -
> C 0.0187 0.0358 -  -   -
> D 0.0865 0.1502 0.5131 - -
> E 0.0122 0.0173 0.7185 0.3240-
> F 0.4693 0.3240 0.0050 0.0173 0.0029
>
> P value adjustment method: fdr
>
> Is there a way to graph the pairwise variance differences so that users can 
> easily identify the statistically significant variance differences between 
> group levels?
>
> I can do this using Minitab but I'd prefer using R for this.
>
> Thomas Subia
>
> __
> 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] Forestplot, grid graphics Viewplot grid.arange

2022-10-13 Thread Jim Lemon
Hi Mary,
I didn't see any answers to your post, but doing something like this
is quite easy in base graphics. If you are still stuck, I may be able
to suggest something.

Jim

On Mon, Oct 10, 2022 at 6:05 PM Putt, Mary  wrote:
>
>
> I have created several plots using the forestplot package and the link shown 
> here. 
>  > Great package !
> Next step is to combine two plots into a single graphic. The code provided on 
> the link results in 'bleeding' of the graphics/text into each other. I don't 
> want to clip it as I need the text elements. I am guessing the problem 
> involves the combination of text and graphics in the 'plot'. I fooled around 
> with the original post and also did some hunting online but no luck Thanks in 
> advance.
> library(foresplot)
> data("dfHRQoL")
>
> #create individual forest plots for Sweden and Denmark
> fp_sweden <- dfHRQoL |>
>   filter(group == "Sweden") |>
>   mutate(est = sprintf("%.2f", mean), .after = labeltext) |>
>   forestplot(labeltext = c(labeltext, est),
>  title = "Sweden",
>  clip = c(-.1, Inf),
>  xlab = "EQ-5D index",
>  new_page = FALSE)
>
> fp_denmark <- dfHRQoL |>
>   filter(group == "Denmark") |>
>   mutate(est = sprintf("%.2f", mean), .after = labeltext) |>
>   forestplot(labeltext = c(labeltext, est),
>  title = "Denmark",
>  clip = c(-.1, Inf),
>  xlab = "EQ-5D index",
>  new_page = FALSE)
>
>
>
> #now combine into a single plot using the web code; but this one bleeds into 
> each other
> library(grid)
>
> #
> #Put plots together using grid graphics
> #Attempt 1 from website
>
> #
> grid.newpage()
> borderWidth <- unit(4, "pt")
> width <- unit(convertX(unit(1, "npc") - borderWidth, unitTo = "npc", 
> valueOnly = TRUE)/2, "npc")
> pushViewport(viewport(layout = grid.layout(nrow = 1,
>ncol = 3,
>widths = unit.c(width,
>borderWidth,
>width))
> )
> )
> pushViewport(viewport(layout.pos.row = 1,
>   layout.pos.col = 1))
> fp_sweden
> upViewport()
> pushViewport(viewport(layout.pos.row = 1,
>   layout.pos.col = 2))
> grid.rect(gp = gpar(fill = "grey", col = "red"))
> upViewport()
> pushViewport(viewport(layout.pos.row = 1,
>   layout.pos.col = 3))
> fp_denmark
> upViewport(2)
>
>
> 
> #Attempt 2 from website, still a problem.
> 
> grid.newpage()
> borderWidth <- unit(4, "pt")
> width <- unit(convertX(unit(1, "npc") - borderWidth, unitTo = "npc", 
> valueOnly = TRUE)/2, "npc")
> pushViewport(viewport(layout = grid.layout(nrow = 1,
>ncol = 3,
>widths = c(0.45, 0.1, 0.45))
> )
> )
> pushViewport(viewport(layout.pos.row = 1,
>   layout.pos.col = 1))
> fp_sweden
> upViewport()
>
> pushViewport(viewport(layout.pos.row = 1,
>   layout.pos.col = 3))
> fp_denmark
> upViewport(2)
>
> ###
> #Attempt 3 converting to grobs and use patchwork
> ###
> library(ggplotify)
> library(patchwork)
>
> fpd_grob <- grid2grob(print(fp_denmark))
>
> p1 <- grid2grob(print(fp_denmark))
> p2 <- grid2grob(print(fp_sweden))
> p_both <- wrap_elements(p1) + wrap_elements(p2)
> p_both
>
> #same problem with grid.arrange()**strong text**
>
>
>
> Mary Putt, PhD, ScD
> Professor of Biostatistics
> Department of Biostatistics, Epidemiology & Informatics
> Pereleman School of Medicine
> University of Pennsylvania
>
> 215-573-7020
>
> [[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] cat in a subroutine

2022-10-13 Thread Jim Lemon
Have you assigned the valuie of goprobit1.r.me.kr to "fortytwo", or
indeed anything?

Jim

On Thu, Oct 13, 2022 at 8:02 PM Steven T. Yen  wrote:
>
> Not really.
>
> fortytwo<-42
> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> Probabilities",
>  "logisitic =",fortytwo,"\n")
>
>  > goprobit1.r.me.kr<-me.gologit.r(goprobit1,embellished=TRUE,
> + resampling=TRUE,ndraws=5);
> goprobit1.r.me.kr
> Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
> Probit Probabilities",  :
>unused arguments (fortytwo, "\n")
>
> On 10/13/2022 4:46 PM, Jim Lemon wrote:
> > Hi Steven & Erin,
> > This works:
> >
> > fortytwo<-42
> > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities","logisitic =",fortytwo,"\n")
> > j<-grep(".one\\b",c(".one\\a",".one\\b"))
> >
> > Marginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities logisitic = 42
> >
> > If I don't define fortytwo before calling cat, it doesn't.
> > So we know what the answer is.
> >
> > Jim
> >
> > On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:
> >> t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> >> sig<-my.sig.levels(p)
> >> out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> >> rownames(out)<-names(me)
> >> colnames(out)<-c("est","se","t","p","sig")
> >> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> >> Probabilities",
> >>   "\n\nlogistic =",logistic)
> >> j<-grep(".one\\b",rownames(out))
> >> out<-out[-j,]
> >> return(out)
> >> }
> >>
> >> Steven from iPhone
> >>
> >>> On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:
> >>>
> >>> t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> >>> sig<-my.sig.levels(p)
> >>> out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> >>> rownames(out)<-names(me)
> >>> colnames(out)<-c("est","se","t","p","sig")
> >>> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> >>> Probabilities",
> >>>   "\n\nlogistic =",logistic)
> >>> j<-grep(".one\\b",rownames(out))
> >>> out<-out[-j,]
> >>> return(out)
> >>> }
> >>  [[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] cat in a subroutine

2022-10-13 Thread Jim Lemon
Hi Steven & Erin,
This works:

fortytwo<-42
cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities","logisitic =",fortytwo,"\n")
j<-grep(".one\\b",c(".one\\a",".one\\b"))

Marginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities logisitic = 42

If I don't define fortytwo before calling cat, it doesn't.
So we know what the answer is.

Jim

On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:
>
> t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> sig<-my.sig.levels(p)
> out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> rownames(out)<-names(me)
> colnames(out)<-c("est","se","t","p","sig")
> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> Probabilities",
>  "\n\nlogistic =",logistic)
> j<-grep(".one\\b",rownames(out))
> out<-out[-j,]
> return(out)
> }
>
> Steven from iPhone
>
> > On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:
> >
> > t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> > sig<-my.sig.levels(p)
> > out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> > rownames(out)<-names(me)
> > colnames(out)<-c("est","se","t","p","sig")
> > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities",
> >  "\n\nlogistic =",logistic)
> > j<-grep(".one\\b",rownames(out))
> > out<-out[-j,]
> > return(out)
> > }
>
> [[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] cat in a subroutine

2022-10-13 Thread Jim Lemon
Hi Steven,
I think Erin is right, unless there is a variable named "logistic"
visible within the function, "cat" will think it is either an argument
or an R object. If you have the "psych" package loaded, it may see it
as a closure. There is also a "Logistic" in the stats package, but
that shouldn't be visible due to the capital L

Jim

On Thu, Oct 13, 2022 at 6:55 PM Steven T. Yen  wrote:
>
> Thanks Erin.
>
> No. Removing the second line (so that cat simply prints something else),
>
> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> Probabilities")
> #"\n\nlogistic =",logistic)
>
> I get yet another nonsense:
>
> Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
> Probit Probabilities") :
>argument "j" is missing, with no default
>  >
>
> On 10/13/2022 3:37 PM, Erin Hodgess wrote:
> > Hi Steven:
> >
> > Do you have a variable called logistic, please?  I think that might be
> > the culprit.
> >
> > Thanks,
> > Erin
> >
> > On Thu, Oct 13, 2022 at 1:35 AM Steven T. Yen  wrote:
> >
> > I have had an issue with printing (with cat) in a subroutine for
> > which I
> > do not have a applicable example, but I am still hoping to get some
> > help. In the following, the first block of code works fine.
> >
> > ...
> >
> > t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> > sig<-my.sig.levels(p)
> > out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> > rownames(out)<-names(me)
> > colnames(out)<-c("est","se","t","p","sig")
> > j<-grep(".one\\b",rownames(out))
> > out<-out[-j,]
> > return(out)
> > }
> >
> > But as soon as I insert lines to print (cat) soething simple, it
> > spits
> > out message that appears to be nonsence (unrelated). Any idea. Please
> > help. Thanks.
> >
> > t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
> > sig<-my.sig.levels(p)
> > out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
> > rownames(out)<-names(me)
> > colnames(out)<-c("est","se","t","p","sig")
> > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities",
> >  "\n\nlogistic =",logistic)
> > j<-grep(".one\\b",rownames(out))
> > out<-out[-j,]
> > return(out)
> > }
> >
> > In this particular case, the error message was as follows:
> >
> > Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
> > Probit Probabilities",  :
> >unused argument (logistic)
> >
> > I have printed this way in numerous routines without problem and
> > do not
> > see why this is happending.
> >
> > __
> > 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.
> >
> > --
> > Erin Hodgess, PhD
> > mailto: erinm.hodg...@gmail.com
> [[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] Ids with matching number combinations?

2022-10-08 Thread Jim Lemon
Hi Marine,
I'm not sure that I have the right idea, but this worked for me and may help.

# I had to fix this line
df<-data.frame(id=rep(1:10,each=10),item1=sample(1:20, 100, replace=TRUE))
df2<-data.frame(a=c(8, 8,10,9, 5, 1,2,1),b=c(16,18,11, 19,18, 11,17,12))
result<-data.frame(id=df[,1],rown=1:dim(df)[1],matched=rep(FALSE,dim(dfw)[1]))
# function that checks that all entries in vector a exist in vector x
match_all_a<-function(a,x,index) {
 inx<-TRUE
 for(i in 1:length(a)) inx <- inx && a[i] %in% x[-1]
 return(list(id=x[1],rown=index,matched=inx))
}
# step through the data frame
for(i in df[,1]) result[i,]<-match_all_a(df2[i,],df[i,],i)
# display the result id, row in df, whether matched
result
# select the rows of result for which matched is TRUE

Jim

On Fri, Oct 7, 2022 at 11:57 PM Marine Andersson  wrote:
>
> Hi,
>
> If I have two datasets like this:
> df=data.frame("id"=rep(1:10,10, each=10), "item1"=sample(1:20, 100, replace=T)
> df2=data.frame("a"=c(8, 8,10,9, 5, 1,2,1), "b"=c(16,18,11, 19,18, 11,17,12))
>
> How do I find out which ids in the df dataset that has a match for both the 
> numbers occuring in the same row in the df2 dataframe? In the output I would 
> like to get the matching id and the rownumber from the df2.
>
> Output something like this
> IdRownr
> 2 1
> 5 1
> 7 4
>
> My actual problem is more complex with even more columns to be matched and 
> the datasets are large, hence the solution needs to be efficient.
>
> Kind regards,
>
>
>
>
>
> N?r du skickar e-post till Karolinska Institutet (KI) inneb?r detta att KI 
> kommer att behandla dina personuppgifter. H?r finns information om hur KI 
> behandlar personuppgifter.
>
>
> Sending email to Karolinska Institutet (KI) will result in KI processing your 
> personal data. You can read more about KI's processing of personal data 
> here.
>
> [[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] Creating a year-month indicator and groupby with category

2022-10-03 Thread Jim Lemon
Hi Tariq,
There were a couple of glitches in your data structure. Here's an
example of a simple plot:

dat<-structure(list(year = c(2018, 2019, 2019, 2019, 2019, 2019, 2019,
2019, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017,
2017, 2017, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018,
2018, 2018, 2018, 2019, 2019, 2019, 2019, 2019), month = c(12,
1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5), company = c("ABC",
"ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "FGH", "FGH",
"FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH",
"FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH",
"FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH"
), share = c(20, 16.5, 15, 15.5, 15.5, 16, 17, 16.5, 61, 55,
53, 53, 54, 53, 58, 54, 50, 47, 55, 50, 52, 51, 51.5, 52, 53,
54, 55, 53, 54, 50, 42, 48, 41, 40, 39, 36.5, 35), com_name = c(1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA,
-37L), spec = structure(list(cols = list(year = structure(list(), class =
c("collector_double",
"collector")), month = structure(list(), class = c("collector_double",
"collector")), company = structure(list(), class = c("collector_character",
"collector")), share = structure(list(), class = c("collector_double",
"collector")), com_name = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
# convert year and month fields to dates about the middle of each month
dat$date<-as.Date(paste(dat$year,dat$month,15,sep="-"),"%Y-%m-%d")
# plot the values for one company
plot(dat$date[dat$company=="ABC"],dat$share[dat$company=="ABC"],
 main="Plot of dat",xlab="Year",ylab="Share",
 xlim=range(dat$date),ylim=range(dat$share),
 type="l",col="red")
# add a line for the other one
lines(dat$date[dat$company=="FGH"],dat$share[dat$company=="FGH"],col="green")
# get the x plot limits as they are date values
xspan<-par("usr")[1:2]
# place a legend about in the middle of the plot
legend(xspan[1]+diff(xspan)*0.3,35,c("ABC","FGH"),lty=1,col=c("red","green"))

There are many more elegant ways to plot something like this.

Jim

On Mon, Oct 3, 2022 at 10:05 AM Tariq Khasiri  wrote:
>
> Hello,
>
> I have the following data. I want to show in a line plot how each different
> company is earning over the timeline of my data sample.
>
> I'm not sure how I can create the *year-month indicator* to plot it nicely
> in my horizontal axis out of my dataset.
>
> After creating the *year-month* indicator ( which will be in my x axis) I
> want to create a dataframe where I can groupby companies over the
> year-month indicator by putting *share *in the y axis as variables.
>
> ### data is like the following
>
> dput(dat)
> structure(list(year = c(2018, 2019, 2019, 2019, 2019, 2019, 2019,
> 2019, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017,
> 2017, 2017, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018,
> 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2019), month = c(12,
> 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1,
> 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5), company = c("ABC",
> "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "ABC", "FGH", "FGH",
> "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH",
> "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH",
> "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH", "FGH"
> ), share = c(20, 16.5, 15, 15.5, 15.5, 16, 17, 16.5, 61, 55,
> 53, 53, 54, 53, 58, 54, 50, 47, 55, 50, 52, 51, 51.5, 52, 53,
> 54, 55, 53, 54, 50, 42, 48, 41, 40, 39, 36.5, 35), com_name = c(1,
> 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA,
> -37L), spec = structure(list(cols = list(year = structure(list(), class =
> c("collector_double",
> "collector")), month = structure(list(), class = c("collector_double",
> "collector")), company = structure(list(), class = c("collector_character",
> "collector")), share = structure(list(), class = c("collector_double",
> "collector")), com_name = structure(list(), class = c("collector_double",
> "collector"))), default = structure(list(), class = c("collector_guess",
> "collector")), delim = ","), class = "col_spec"), problems =  0x7fd732028680>, class = c("spec_tbl_df",
> "tbl_df", "tbl", "data.frame"))
>
> [[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 

Re: [R] How long does it take to learn the R programming language?

2022-09-28 Thread Jim Lemon
Given some of the questions that are posted to this list, I am not
sure that there is an upper bound to the estimate.

Jim

__
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] Converting Character date to Dates in r

2022-09-28 Thread Jim Lemon
Hi Admire,
Your attachment didn't get through, although CSV format should. The
code you included seems a very roundabout way to extract a series of
dates as character strings and as there is no assignment of return
values in some lines, is unlikely to work. Perhaps if you send just a
few of the original strings, someone can answer your question.

Jim

On Thu, Sep 29, 2022 at 4:02 AM Admire Tarisirayi Chirume
 wrote:
>
> Hello, i hope this email finds you well. Kindly help me to format dates
> shown as character to dates using as.Dates.
>
> Attached herewith is my data in excel csv format.
>
> The following is the  r-code i have used in my analysis:
>
>
> setwd("Z:/2022/September/Inflation forecasts")
> inflation<-read.csv("Inflation_forecasts_1.csv")
> attach(inflation)
> inflation[,1:2 ] #subsetting the dataframe
> inflation.df<-inflation[,1:2]
> attach(inflation.df)
> #Renaming variables
> inflation<- rename(inflation.df,
>cpi = CPI,
>year=period)
>
> #subsetting data April 2020 to current
> inflation.2<-data.frame(inflation[-c(1:135),])
> Defining variables for use in the analysis
> attach(inflation.2)
>
> t <- year
> class(inflation.2$cpi)
> inflation.2$cpi <- as.numeric(as.character(inflation.2$cpi))
> Y <- cpi
> sapply(inflation.2, class)
>
> format(as.Date(inflation.2$period), "%Y-%m")
>
>
>
> Thank you in advance.
>
> Admire
>
>
>
>
> Alternative email: addtar...@icloud.com/tchir...@rbz.co.zw
> Skype: admirechirume
> Call: +263773369884
> whatsapp: +818099861504
> __
> 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] Need help plotting

2022-09-23 Thread Jim Lemon
Hi David,
No, read.table converts a text representation of data into a data frame object.

Jim

On Sat, Sep 24, 2022 at 2:29 AM DFP  wrote:
>
> Do I need that read.table if the tst dataframe already exists in my
> system?  If so, why?
>
> --
>
> Hello,
>
> You have to load the packages involved:
>
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
>
> then run the full sequence. Though this is not important, if you are
> pivotting columnns named y1 and y2, why not name the result just y?
>
>
> pivot_longer(-time, names_to = "y")
>
>
> And here is complete code, runs in a fresh R session.
>
>
> tst  <- read.table(text = "
> time y1 y2
> 1  18:55 30 19
> 2  18:56 30 19
> 3  18:57 29 19
> 4  18:58 31 19
> 5  18:59 28 19
> 6  19:00 28 19
> 7  19:01 28 19
> 8  19:02 28 19
> 9  19:03 28 19
> 10 19:04 28 19
> 11 19:05 29 19
> ", header = TRUE)
>
> library(dplyr)
> library(tidyr)
> library(ggplot2)
>
> tst %>%
> mutate(time = paste(Sys.Date(), time),
>time = as.POSIXct(time)) %>%
> select(time, y1, y2) %>%
> # reshape to long format
> pivot_longer(-time, names_to = "y") %>%
> # now plot
> ggplot(aes(time, value, color = y)) +
> geom_line() +
> geom_point() +
> scale_color_manual(values = c("orange", "skyblue")) +
> # make datetime labels
> scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
> theme_bw()
>
>
> Hope this helps,
>
> Rui Barradas
>
> [[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] Write text file in Fortran format

2022-09-21 Thread Jim Lemon
Sorry, line 9 should be:

if(substr(air[airline],1,1) == " ")

Jim

On Thu, Sep 22, 2022 at 8:51 AM Jim Lemon  wrote:
>
> Hi Javad,
> The example text file you sent doesn't appear to have the two
> "trailer" lines that you describe. I would try this brute force method
> as all you seem to want is to multiply the third column values by a
> constant:
>
> air<-readLines("Air.txt")
> # define the column 3 field
> begincol3<-29
> endcol3<-42
> widthcol3<-14
> lenline<-117
> for(airline in 1:length(air)) {
>  # is this a data line?
>  if(substr(air[airline]) == " ")
>  air[airline]<-paste0(substr(inputline,1,begincol3-1),
>   formatC(as.double(substr(inputline,begincol3,endcol3))*mult3,
>digits=5,width=widthcol3,format="f"),
>   substr(inputline,endcol3+1,lenline))
> }
> writeLines(air,"Air2.txt")
>
> Jim
>
> On Wed, Sep 21, 2022 at 9:25 PM javad bayat  wrote:
> >
> > Dear Jim;
> > I have no knowledge of the FORTRAN language. The text file is a model's 
> > output file and I know that the format is in FORTRAN. I want to write a 
> > text file exactly similar to the attached text file using R programming. 
> > The steps below show my goal:
> > 1- Read the text file without the first 8 and last 2 rows as a dataframe.
> > 2- Double the 3rd column values (or multiply by specific number).
> > 3- Insert the removed first 8 rows of the original text file as header in 
> > the dataframe.
> > 4- Insert the last 2 rows of the original text file at the end of dataframe.
> > 5- Write the dataframe as a new text file exactly similar to the original 
> > text file.
> > Is it possible?
> > Sincerely
> >
> >
> >
> >
> >
> >
> > On Wed, Sep 21, 2022 at 3:29 PM Jim Lemon  wrote:
> >>
> >> Hi,
> >> There was a .txt attachment that is some type of data file. Maybe what
> >> you mean is can the header be stripped and the rest written out in a
> >> format that can be input with a FORTRAN read routine. Yes, you just
> >> have to read it into a data frame and write it out so that it is in
> >> either free or fixed format. You will have to define the variable
> >> names in your FORTRAN code and work out the input format
> >> specifications for the fields.
> >>
> >> Jim
> >>
> >> On Wed, Sep 21, 2022 at 8:30 PM Ebert,Timothy Aaron  wrote:
> >> >
> >> > This post was empty.
> >> >
> >> > Tim
> >> >
> >> > From: R-help  On Behalf Of javad bayat
> >> > Sent: Wednesday, September 21, 2022 2:09 AM
> >> > To: R-help@r-project.org
> >> > Subject: [R] Write text file in Fortran format
> >> >
> >> >
> >> >
> >> > [[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.
> >
> >
> >
> > --
> > Best Regards
> > Javad Bayat
> > M.Sc. Environment Engineering
> > Alternative Mail: bayat...@yahoo.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] Write text file in Fortran format

2022-09-21 Thread Jim Lemon
Hi Javad,
The example text file you sent doesn't appear to have the two
"trailer" lines that you describe. I would try this brute force method
as all you seem to want is to multiply the third column values by a
constant:

air<-readLines("Air.txt")
# define the column 3 field
begincol3<-29
endcol3<-42
widthcol3<-14
lenline<-117
for(airline in 1:length(air)) {
 # is this a data line?
 if(substr(air[airline]) == " ")
 air[airline]<-paste0(substr(inputline,1,begincol3-1),
  formatC(as.double(substr(inputline,begincol3,endcol3))*mult3,
   digits=5,width=widthcol3,format="f"),
  substr(inputline,endcol3+1,lenline))
}
writeLines(air,"Air2.txt")

Jim

On Wed, Sep 21, 2022 at 9:25 PM javad bayat  wrote:
>
> Dear Jim;
> I have no knowledge of the FORTRAN language. The text file is a model's 
> output file and I know that the format is in FORTRAN. I want to write a text 
> file exactly similar to the attached text file using R programming. The steps 
> below show my goal:
> 1- Read the text file without the first 8 and last 2 rows as a dataframe.
> 2- Double the 3rd column values (or multiply by specific number).
> 3- Insert the removed first 8 rows of the original text file as header in the 
> dataframe.
> 4- Insert the last 2 rows of the original text file at the end of dataframe.
> 5- Write the dataframe as a new text file exactly similar to the original 
> text file.
> Is it possible?
> Sincerely
>
>
>
>
>
>
> On Wed, Sep 21, 2022 at 3:29 PM Jim Lemon  wrote:
>>
>> Hi,
>> There was a .txt attachment that is some type of data file. Maybe what
>> you mean is can the header be stripped and the rest written out in a
>> format that can be input with a FORTRAN read routine. Yes, you just
>> have to read it into a data frame and write it out so that it is in
>> either free or fixed format. You will have to define the variable
>> names in your FORTRAN code and work out the input format
>> specifications for the fields.
>>
>> Jim
>>
>> On Wed, Sep 21, 2022 at 8:30 PM Ebert,Timothy Aaron  wrote:
>> >
>> > This post was empty.
>> >
>> > Tim
>> >
>> > From: R-help  On Behalf Of javad bayat
>> > Sent: Wednesday, September 21, 2022 2:09 AM
>> > To: R-help@r-project.org
>> > Subject: [R] Write text file in Fortran format
>> >
>> >
>> >
>> > [[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.
>
>
>
> --
> Best Regards
> Javad Bayat
> M.Sc. Environment Engineering
> Alternative Mail: bayat...@yahoo.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] Write text file in Fortran format

2022-09-21 Thread Jim Lemon
Hi,
There was a .txt attachment that is some type of data file. Maybe what
you mean is can the header be stripped and the rest written out in a
format that can be input with a FORTRAN read routine. Yes, you just
have to read it into a data frame and write it out so that it is in
either free or fixed format. You will have to define the variable
names in your FORTRAN code and work out the input format
specifications for the fields.

Jim

On Wed, Sep 21, 2022 at 8:30 PM Ebert,Timothy Aaron  wrote:
>
> This post was empty.
>
> Tim
>
> From: R-help  On Behalf Of javad bayat
> Sent: Wednesday, September 21, 2022 2:09 AM
> To: R-help@r-project.org
> Subject: [R] Write text file in Fortran format
>
>
>
> [[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] Need help plotting

2022-09-20 Thread Jim Lemon
Hi David,
I'm back home again. Try this:

b<-read.table(text=
"Dtime DNO2 DVOC Dpm10Dpm2.5 Dpm1 Mtime MNO2 MVOCMpm10 Mpm2.5 Mpm1
 18:00   28  164  81.34773 24.695435   14 18:00   19  151 3.00  21
 18:01   27  163  74.44034 23.751198   14 18:01   20  148 3.00  21
 18:02   30  160  72.21975 22.463129   13 18:02   19  150 3.00  21",
 header=TRUE,stringsAsFactors=FALSE)
b$POSIXtime<-strptime(paste("2022-09-20",b$Dtime),"%Y-%m-%d %H:%M")
png("DFPNO2.png")
plot(b$POSIXtime,b$DNO2,type="b",main="NO2 readings (2022-09-20)",
 xlab="Date/time",ylab="NO2",ylim=range(c(b$DNO2,b$MNO2)),
 pch=19,col="red")
 points(b$POSIXtime,b$MNO2,type="b",pch=19,col="blue")
 legend("center",legend=c("DNO2","MNO2"),pch=19,col=c("red","blue"))
dev.off()

If you have more than one day, it will show up on the x axis. You can
also format the tick labels if you want the full dates for only one
day.

Jim

PS thanks Avi

On Tue, Sep 20, 2022 at 4:49 PM Parkhurst, David  wrote:
>
> Thank you.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 8:15 AM, Ebert,Timothy Aaron  wrote:
> >
> > My version of this email has a bunch of ? that I do not know how to 
> > interpret. Emails to this group need to be in plain text. HTML content is 
> > deleted or converted and impossible or at least difficult to interpret.
> >
> > Do not share confidential data. Please change some numbers or variable 
> > names and share that.
> > If this helps:
> > 1) Make sure your time variable is a datetime object.
> > 2) At least in ggplot it should now behave as expected.
> > ggplot(df, aes(y=NO2, x=datetime)) + geom_point()
> >
> > That will be a start as a scatterplot, but the graph can be customized or 
> > changed if scatterplot was not desired.
> >
> > Tim
> >
> > -Original Message-
> > From: R-help  On Behalf Of Parkhurst, David
> > Sent: Sunday, September 18, 2022 4:27 PM
> > To: r-help@r-project.org
> > Subject: [R] Need help plotting
> >
> > [External Email]
> >
> > I�ve been retired since �06 and have forgotten most of R.  Now I have a use 
> > for it, with some data from Bloomington�s Environmental Commission.
> >
> > I have a dataframe (obtained from read.csv) that contains numerous columns, 
> > including time (in Excel�s 18:00 format), and DNO2, and MNO2 from two air 
> > quality instruments.
> >
> > I�d like a plot of both the NO2 measurements against time.  I be happy to 
> > use either ordinary R plots or ggplot2 ones, if that would be a better way. 
> >  I�d much appreciate help.
> >
> >[[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] Need help plotting

2022-09-19 Thread Jim Lemon
Hi David,
All I got was the rather cryptic "DFP (iPad)" below your message.
Whatever format you used for the data was blocked by the R-help mail
server. Try this command in your R session:

dput(test)

and cut and paste the output into your email. That should do it.

Jim

On Tue, Sep 20, 2022 at 7:41 AM Parkhurst, David  wrote:
>
> I just sent a subset of the data, with a dataframe called test.  Can you see 
> that?  It may not have been approved by the moderator yet.
>
> DFP (iPad)
>
> > On Sep 19, 2022, at 5:29 PM, Jim Lemon  wrote:
> >
> > Hi David,
> > Since you used read.csv to get the data frame, the file must be i text
> > format. If you can include a few lines of the input (with made up NO2
> > values if necessary), it would be easy to respond with the required
> > commands and a plot.
> >
> > Jim
> >
> >> On Mon, Sep 19, 2022 at 9:12 PM Parkhurst, David  
> >> wrote:
> >>
> >> I’ve been retired since ‘06 and have forgotten most of R.  Now I have a 
> >> use for it, with some data from Bloomington’s Environmental Commission.
> >>
> >> I have a dataframe (obtained from read.csv) that contains numerous 
> >> columns, including time (in Excel’s 18:00 format), and DNO2, and MNO2 from 
> >> two air quality instruments.
> >>
> >> I’d like a plot of both the NO2 measurements against time.  I be happy to 
> >> use either ordinary R plots or ggplot2 ones, if that would be a better 
> >> way.  I’d much appreciate help.
> >>
> >>[[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] Need help plotting

2022-09-19 Thread Jim Lemon
Hi David,
Since you used read.csv to get the data frame, the file must be i text
format. If you can include a few lines of the input (with made up NO2
values if necessary), it would be easy to respond with the required
commands and a plot.

Jim

On Mon, Sep 19, 2022 at 9:12 PM Parkhurst, David  wrote:
>
> I’ve been retired since ‘06 and have forgotten most of R.  Now I have a use 
> for it, with some data from Bloomington’s Environmental Commission.
>
> I have a dataframe (obtained from read.csv) that contains numerous columns, 
> including time (in Excel’s 18:00 format), and DNO2, and MNO2 from two air 
> quality instruments.
>
> I’d like a plot of both the NO2 measurements against time.  I be happy to use 
> either ordinary R plots or ggplot2 ones, if that would be a better way.  I’d 
> much appreciate help.
>
> [[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] Overlapping barplots and lines

2022-09-15 Thread Jim Lemon
Hi Stefano,
The bar x centers are returned by the barplot function. You can also
use the barp function (plotrix package) that places the bars at unit
intervals by default.

Jim

On Thu, Sep 15, 2022 at 3:47 PM Stefano Sofia
 wrote:
>
> Dear R-list users,
>
> I have a silly problem with plot that I am not able to solve. I tried to find 
> a solution through the web, with no success.
>
>
> I need to overlap a barplot with points:
>
>
> barplot(c(55, 80, 120, 90, 105), lwd=1, lend=1, main="", ylab="cm", width=1, 
> ylim=c(0, 120), axes=F)
>
> lines(c(70, 50, 100, 60, 70), type="p", pch=21, bg="red")
>
> axis(1, at=c(1, 2, 3, 4, 5), labels=c("Dec", "Jan", "Feb", "Mar", "Apr"), 
> pos=-1, cex.axis=0.8)
> axis(2, at=seq(0, 120, 10), pos=0)
>
>
> Points and x-axis are not centered with barplots. How can I fix it?
>
>
> Thank you for your help
>
> Stefano
>
>
>  (oo)
> --oOO--( )--OOo--
> Stefano Sofia PhD
> Civil Protection - Marche Region - Italy
> Meteo Section
> Snow Section
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona (AN)
> Uff: +39 071 806 7743
> E-mail: stefano.so...@regione.marche.it
> ---Oo-oO
>
> 
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
> alla ricezione. I messaggi di posta elettronica per i client di Regione 
> Marche possono contenere informazioni confidenziali e con privilegi legali. 
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o 
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, 
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
> computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso 
> di necessità ed urgenza, la risposta al presente messaggio di posta 
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
> persons entitled to receive the confidential information it may contain. 
> E-mail messages to clients of Regione Marche may contain information that is 
> confidential and legally privileged. Please do not read, copy, forward, or 
> store this message unless you are an intended recipient of it. If you have 
> received this message in error, please forward it to the sender and delete it 
> completely from your computer system.
>
> --
> Questo messaggio  stato analizzato da Libraesva ESG ed  risultato non infetto.
> This message was scanned by Libraesva ESG and is believed to be clean.
>
>
> [[alternative HTML version deleted]]
>
> __
> 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] Clustering of datasets

2022-09-05 Thread Jim Lemon
Hi Subhamitra,
I think the fact that you are passing a vector of values rather than a
matrix is part of the problem. As you have only one value for each
country, The points plotted will be the index on the x-axis and the
value for each country on the y-axis. Passing a value for ylim= means
that you are cutting off the lowest points. Here is an example that
will give you two clusters and show the values for the centers in the
middle of the plot. Perhaps this is all you need, but I suspect there
is more work to be done.

k2<-kmeans(DMs[,2],centers=2)
plot(DMs[,2],col=k2$cluster,pch=19,xlim=c(1,46))
text(1:46,DMs[,2],DMs[,1],col=k2$cluster)
points(rep(23,2),k2$centers,pch=1:2,cex=2,col=k2$cluster)
legend(10,1,c("cluster 1: Highly Integrated","cluster 2: Less Integrated"),
col=1:2,pch=19)

Jim

On Mon, Sep 5, 2022 at 9:31 PM Subhamitra Patra
 wrote:
>
> Dear all,
>
> I am about to cluster my datasets by using K-mean clustering techniques in
> R, but getting some type of scattered results. Herewith I pasted my code
> below. Please suggest to me where I am lacking in my code. I was pasting my
> data before applying the K-mean method as follows.
>
> DMs<-read.table(text="Country DATA
>   IS -0.0092
>   BA -0.0235
>   HK -0.0239
>   JA -0.0333
>   KU -0.0022
>   OM -0.0963
>   QA -0.0706
>   SK -0.0322
>   SA -0.1233
>   SI -0.0141
>   TA -0.0142
>   UAE -0.0656
>   AUS -0.0230
>  BEL -0.0006
>  CYP -0.0085
>  CR  -0.0398
> DEN  -0.0423
>   EST -0.0604
>   FIN -0.0227
>   FRA -0.0085
>  GER -0.0272
>  GrE -0.3519
>  ICE -0.0210
>  IRE -0.0057
>  LAT -0.0595
> LITH -0.0451
> LUXE -0.0023
> MAL  -0.0351
> NETH -0.0048
>   NOR -0.0495
>   POL -0.0081
> PORT -0.0044
> SLOVA -0.1210
> SLOVE -0.0031
>   SPA -0.0213
>   SWE -0.0106
> SWIT -0.0152
>   UK -0.0030
> HUNG -0.0086
>   CAN -0.0144
> CHIL -0.0078
>   USA -0.0042
> BERM -0.0035
> AUST -0.0211
> NEWZ -0.0538" ,
>  header = TRUE,stringsAsFactors=FALSE)
> library(cluster)
> k1<-kmeans(DMs[,2],centers=2,nstart=25)
> plot(DMs[,2],col=k1$cluster,pch=19,xlim=c(1,46), ylim=c(-0.12,0))
> text(1:46,DMs[,2],DMs[,1],col=k1$cluster)
> legend(10,1,c("cluster 1: Highly Integrated","cluster 2: Less Integrated"),
> col=1:2,pch=19)
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
> [image: Mailtrack]
> 
> Sender
> notified by
> Mailtrack
> 
> 09/05/22,
> 04:55:22 PM
>
> [[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] Getting minimum value of a column according a factor column of a dataframe

2022-08-25 Thread Jim Lemon
Hi Javad,
In that case, just modify the function to extract the rows with both
the minimum and maximum Q from each station

df1<-read.table(text="Code Y  M  D  Q  N  O
 41003 81 1 19 0.16 7.17 2.5
 41003 77 9 22 0.197 6.8 2.2
 41003 79 7 28 0.21 4.7 6.2
 41005 79 8 17 0.21 5.5 7.2
 41005 80 10 30 0.21 6.84 2.6
 41005 80 12 20 0.21 6.84 2.4
 41005 79 6 14 0.217 5.61 3.55
 41009 79 2 21 0.218 5.56 4.04
 41009 79 5 27 0.218 6.4 3.12
 41009 80 11 29 0.22 6.84 2.8
 41009 78 5 28 0.232 6 3.2
 41009 81 8 20 0.233 6.39 1.6
 41009 79 9 30 0.24 5.6 7.5
 41017 79 10 20 0.24 5.3 7.1
 41017 80 7 30 0.24 6.73 2.6",
 stringsAsFactors=FALSE,header=TRUE)

# define a function that returns the desired rows
minmaxQrow<-function(x) return(x[c(which.min(x$Q),which.max(x$Q)),])
# apply the function to the data frame
df1a<-by(df1,df1$Code,minmaxQrow)
# set the result to the first element of the list
df1b<-df1a[[1]]
# rbind the remaining rows
for(i in 2:length(df1a)) df1b<-rbind(df1b,df1a[[i]])
# display the result
df1b

Jim

On Fri, Aug 26, 2022 at 5:25 AM javad bayat  wrote:
> ...
> I think I should explain more about my request. I had a large data frame
> (11059 rows and 16 columns). The Code column represented the stations code,
> totally the number of stations were 128. At each station I had many
> measured variables, like Q and N and O, and these variables were measured
> in different years and days. The days that data were measured were
> different for each station, and due to this reason I had different rows for
> stations. For example, station number one (41009) had 158 rows and station
> number 2 (41011) had 113 rows. Note that the station's codes are not in
> order format (e.g smallest to largest).
> Back to my request, I wanted to extract the minimum value of the Q for each
> station (based on the Code column). The problem was that I wanted to have
> other column values which were measured for this minimum of the Q.
> I hope my explanation was clear enough. As I said before, I used the Rui's
> codes and I got what I wanted. Although, other solutions provided by others
> were all correct.
>

__
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] Reading a CSV file

2022-08-06 Thread Jim Lemon
HI Erin,
Just index out the lines in the result vector.

Jim

On Sun, Aug 7, 2022 at 10:16 AM Erin Hodgess  wrote:
>
> Hello!
>
> Is there a way to read the first line of a CSV file, then skip 4 lines,
> then continue reading, please?
>
> I know you can skip from the top, but I don't know if you can read and then
> skip.
>
> Thanks,
> Erin
>
>
> Erin Hodgess, PhD
> mailto: erinm.hodg...@gmail.com
>
> [[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] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread Jim Lemon
Hi Roslina,
I think you have changed the code as "bc_start" in my code is
"BCStartTime" in yours. When I run the attached code, I get a data
frame "hourly_SoC" that looks right, and a matrix "result" (hour by
SoC) that checks against the data frame. I have tried to comment the
code so that you an see what I am doing.

Jim

On Wed, Jul 20, 2022 at 1:18 AM roslinazairimah zakaria
 wrote:
>
> Hi Jim,
>
> I tried to run your code and got this error.
>
> > # get the temporal order of observations
> > obs_order <- order(c(as.numeric(dt$BCStartTime),as.numeric(dt$BCStopTime)))
> Warning messages:
> 1: In order(c(as.numeric(dt$BCStartTime), as.numeric(dt$BCStopTime))) :
>   NAs introduced by coercion
> 2: In order(c(as.numeric(dt$BCStartTime), as.numeric(dt$BCStopTime))) :
>   NAs introduced by coercion
> > numeric_time<-c(as.numeric(dt$BCStartTime),as.numeric(dt$BCStopTime))[obs_order]
> Warning messages:
> 1: NAs introduced by coercion
> 2: NAs introduced by coercion
> > nobs<-diff(range(numeric_time))/3600
> > # find the linear approximation of charge state by hours
> > hourly_SoC <- approx(numeric_time,
> +
> c(dt$Starting_SoC_of_12,dt$Ending_SoC_of_12)[obs_order],n=nobs)
> Error in approx(numeric_time, c(dt$Starting_SoC_of_12, 
> dt$Ending_SoC_of_12)[obs_order],  :
>   need at least two non-NA values to interpolate
>
__
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] A Request

2022-06-21 Thread Jim Lemon
Hi Chishti,
Try this:

dim(x)[2]
length(dn)

>From your error message, the two will be different. They should be the
same. A wild guess is that the offending line of code should be:

dimnames[2]<-1:dn

Jim

On Tue, Jun 21, 2022 at 11:10 PM Muhammad Zubair Chishti
 wrote:
>
> Hi, Dear Professor,
> When I run a code in R, I face the following error:
> Error in dimnames(x) <- dn :
>   length of 'dimnames' [2] not equal to array extent
>
> Kindly help how to handle this.
>
> Regards
> Chishti
>
> [[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] Query regarding R 'irr' package 'N.cohen.kappa'

2022-06-16 Thread Jim Lemon
Hi Kalaivani,
The N.cohen.kappa function was written by Matthais Gamer, the
maintainer of the irr package. Both that function and N2.cohen.kappa
(written by Puspendra Singh) involve corrections that are described in
the references on the respective help pages. It is likely that there
will be small differences in the estimates for large N in the
different methods of calculation. I cannot advise which would best
suit your purpose as I only did testing and refining code in the
N2.cohen.kappa function. Perhaps corresponding directly with Matthais
Gamer would be your best option.

Jim

On Fri, Jun 17, 2022 at 2:20 AM Kalaivani Mani  wrote:
>
> Dear R-help Team,
>
> I am from India and have a query on 'N.cohen.kappa' Sample size
> calculations for Cohen's Kappa Statistic. I have calculated manually the
> sample size using the formula mentioned in "Cantor, A. B. (1996)
> Sample-size calculation for Cohen’s kappa. Psychological Methods, 1, 150-
> 153". Later came to know that it can be done using the R 'irr' package. I
> got a different number.
>
> Let us consider the following two situations:
>
> For situation 1, the sample size is 1370 using R
> Testing H0: kappa = 0.81 vs. HA: kappa> 0.95 given that kappa = 0.95 and
> both raters classify 1.5% of subjects as positive.
> R command used is: N.cohen.kappa(0.015, 0.015, 0.95, 0.81, alpha=0.05,
> power=0.8, twosided=FALSE ).
>
> But for the same situation, the sample size is much higher by manual
> calculation, which is 8580.
>
> For situation 2, the sample size is 74 by using R and is matching with the
> manual calculation too.
> Testing H0: kappa = 0.81 vs. HA: kappa> 0.95 given that kappa = 0.95 and
> rater1 classify 40% of subjects and rate2 classify 50% of subjects as
> positive.
> R command used is: N.cohen.kappa(0.40, 0.50, 0.95, 0.81, alpha=0.05,
> power=0.8, twosided=FALSE ).
>
> I am attaching both the 'Excel sheet formula-kappa sample size situation1 &
> 2').
>
> Why is this so? Please help me to sort this out.
>
> Looking forward to hearing from you.
>
> Best,
> Kalaivani
>
> --
> *Dr. Kalaivani Mani, *
>
> *M.Sc., Biostatistics (CMC, Vellore), Ph.D. (AIIMS, Delhi)*
>
> *Scientist-IV*
>
> *Dept. of Biostatistics*
>
> *All India Institute of Medical Sciences*
> *New Delhi-110029, India.*
> *Mobile:91-9717319082*
> __
> 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] Changing sign of columns and values

2022-06-12 Thread Jim Lemon
Hi Hana,
This is a bit more difficult, but the same basic steps apply. See the
comments for an explanation.
When you submit a problem like this, it is a lot easier if you send
the output from "dput" (e.g. dput(df1)) or set your data frames up
with "read.table" like I have done in the example below. It make it
lots easier for anyone who wants to reply to see what your dataset
looks like and input that dataset to devise a solution.
I have made some assumptions about marking the rows to be altered and
the arithmetic to do on those rows. What follows may not be as general
a solution as you want:

df1<-read.table(text=
 "SNPID OAEA
 snp001C A
 snp002G A
 snp003C A
 snp004G A
 snp005C T",
 header=TRUE,stringsAsFactors=FALSE)

df2<-read.table(text=
 "SNPID   OAEA   id1 id2 id3 id4 id5
 snp001AC1.012   0.971.971.99
 snp002AG1.022   1   2   2
 snp003CA1   1.032   0   1
 snp004AG1.021.992   1.021.98
 snp005CT1   0   1.011   1",
 header=TRUE,stringsAsFactors=FALSE)

# get a logical vector of the different XA values
reversals<-df1$EA != df2$EA | df1$OA != df2$OA
reversals

# set a variable to the maximum value of idx
# just to make the code easier to understand
maxid<-2

# create a copy of df2
dfnew<-df2

# now swap the XA columns and reflect the
# idxx values of the rows in which
# EA and OA are different between df1 and df2
# here I have looped through the rows
nrows<-dim(dfnew)[1]
idcols<-4:8
XAcols<-2:3
for(i in 1:nrows) {
 if(reversals[i]) {
  dfnew[i,XAcols]<-rev(dfnew[i,XAcols])
  dfnew[i,idcols]<-maxid-dfnew[i,idcols]
 }
}

dfnew

Jim

On Mon, Jun 13, 2022 at 12:09 AM anteneh asmare  wrote:
>
> Dear Jim, Morning I have the same issue regarding comparing and
> swapping the value of columns fro two different data frames.
> I have the following two data frames
> Data frame 1
> "SNPID" "OA""EA"
> "snp001""C" "A"
> "snp002""G" "A"
> "snp003""C" "A"
> "snp004""G" "A"
> "snp005""C" "T"
>
> Data frame 2
> SNPID   OA  EA  id1 id2 id3 id4 id5
> snp001 AC1.01  2  0.97
>   1.971.99
> snp002A G1.02 21
>  22
> snp003C A 1  1.03   2
>   01
> snp004   A  G  1.021.99  2
>  1.02   1.98
> snp005  C   T10  
> 1.01
> 1   1
>
> I want to  if  OA s and EAs in data frame 2 is the same as OAs and EAs
>  data frame 1 in such case I want to keep all information in data
> fram2 as it is . However if   OA s and EAs in data frame 2 is
> different from OAs and EAs  data frame 1, I want to change OA s and
> EAs in data frame 2 to  OAs and EAs  data frame 1 and   I want to
> redefine the values of the dosages (ids) of the variant (the dosage d
> for the i-th individual and the j-th variant would become d_ij
> new=2-dij.
> Dosage [j,]=2-dosage[j,]
> My desire data frame looks like
> Dataframe new
> SNPID"  "OA"   "EA"id1  id2 id3 id4 id5
> "snp001""C" "A" 2-1.012- 22-0.97  
>  2-1.97
> 2-1.99
> "snp002""G" "A" 2- 1.02  2- 2   
> 2-1
>   2-2 2- 2
> "snp003""C" "A"   11.03   
>   2
> 0  1
> "snp004""G" "A" 2-1.02   2-1.99
> 2-22-1.022-1.98
> "snp005""C" "T"  10
> 1.01   11
>  can you help me the r code for the above.
> Kind regards,
> Hana
>
>
> On 6/12/22, hanatezera  wrote:
> > Dear Jim, Thanks a lot this is exactly i am looking for.Stay safe and
> > blessed !Best,Ha

Re: [R] Changing sign of columns and values

2022-06-11 Thread Jim Lemon
Hi Hana,
I didn't look closely. The simplest rule that I can see is that the
letters (nucleotides?) should be swapped if there has been a sign
change in the beta value. Therefore:

mydf<-read.table(text=
"IDnumber  OA  EA  beta
1   C   A   -0.05
2   GA0.098
3   GT-0.789",
header=TRUE,stringsAsFactors=FALSE)
# logical vector marking the rows to be swapped
swap_letters<-mydf$beta < 0
# save the OA values to be swapped
newEA<-mydf$OA[swap_letters]
# change the OAs to EAs
mydf$OA[swap_letters]<-mydf$EA[swap_letters]
# set the relevant EA values to the old OA values
mydf$EA[swap_letters]<-newEA
# change the beta values
mydf$beta<-abs(mydf$beta)
mydf

Jim



On Sun, Jun 12, 2022 at 9:11 AM hanatezera  wrote:
>
> Dear jim thanks for your help! I want to change also the value of OA and EF 
> simultaneously.
> For instance i am looking the data
> mydf
> IDnumber OA EA  beta
> 11  A  C  0.050
> 22  G  A 0.098
> 33  T   G 0.789
>
> Best,
> Hana
>
>
>
>  Original message 
> From: Jim Lemon 
> Date: 6/12/22 1:59 AM (GMT+03:00)
> To: hanatezera , r-help mailing list 
> 
> Subject: Re: [R] Changing sign of columns and values
>
> Hi Hana,
> I think this is what you want:
>
> # first read in your example
> mydf<-read.table(text=
> "IDnumber  OA  EA  beta
> 1   C   A   -0.05
> 2   GA0.098
> 3   GT-0.789",
> header=TRUE,stringsAsFactors=FALSE)
> # check it
> mydf
> IDnumber OA EA   beta
> 11  C  A -0.050
> 22  G  A  0.098
> 33  G  T -0.789
> # change values of mydf$beta to absolute values
> mydf$beta<-abs(mydf$beta)
> mydf
> IDnumber OA EA  beta
> 11  C  A 0.050
> 22  G  A 0.098
> 33  G  T 0.789
>
> Jim
>
> On Sun, Jun 12, 2022 at 8:27 AM hanatezera  wrote:
> >
> > I have the following data set in data frameIDnumber  OA  EA  beta1  
> >C   A   -0.052 GA
> > 0.0983  GT-0.789I want to 
> > change the sign of negative beta. If the negative value change to postive i 
> > want to switch its EA and OA.My desire result will beIDnumber  OA  EA  
> > beta1 A  C 0.052 G  
> >   A0.0983  T G
> > 0.789Any one can help me with r codes? kind regards,Hana
> > [[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] Changing sign of columns and values

2022-06-11 Thread Jim Lemon
Hi Hana,
I think this is what you want:

# first read in your example
mydf<-read.table(text=
"IDnumber  OA  EA  beta
1   C   A   -0.05
2   GA0.098
3   GT-0.789",
header=TRUE,stringsAsFactors=FALSE)
# check it
mydf
 IDnumber OA EA   beta
11  C  A -0.050
22  G  A  0.098
33  G  T -0.789
# change values of mydf$beta to absolute values
mydf$beta<-abs(mydf$beta)
mydf
 IDnumber OA EA  beta
11  C  A 0.050
22  G  A 0.098
33  G  T 0.789

Jim

On Sun, Jun 12, 2022 at 8:27 AM hanatezera  wrote:
>
> I have the following data set in data frameIDnumber  OA  EA  beta1
>  C   A   -0.052 GA
> 0.0983  GT-0.789I want to change 
> the sign of negative beta. If the negative value change to postive i want to 
> switch its EA and OA.My desire result will beIDnumber  OA  EA  beta1  
>A  C 0.052 GA
> 0.0983  T G0.789Any one can help 
> me with r codes? kind regards,Hana
> [[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] Mixing plotting symbols with text

2022-06-07 Thread Jim Lemon
Hi Erin,
Here's a kinda clunky way to get your plot title. It can be modified
to do fancier things like intersperse symbols with letters but you may
need no more than this. Have fun.

par(mar=c(5,4,5,2))
plot(0,xlim=c(-1,1),ylim=c(-1,1),type="n",xlab="Nonsense",ylab="Intensity")
points(runif(4,-1,1),runif(4,-1,1),pch=3)
points(runif(4,-1,1),runif(4,-1,1),pch=4)
symbol_n_text<-function(x,y,pch,txt,adj=0,cex=1) {
 oldcex<-par(cex=cex)
 x<-x-(strwidth("M ")+strwidth(txt))/2
 points(x,y,pch=pch)
 x<-x+strwidth("M ")
 text(x,y,txt,adj=adj)
 par(oldcex)
}
par(xpd=TRUE)
symbol_n_text(0,1.35,3,"your stuff",cex=1.5)
symbol_n_text(0,1.2,4,"my stuff",cex=1.5)

Thanks for the nod, Bert.

Jim

On Wed, Jun 8, 2022 at 5:39 AM Erin Hodgess  wrote:
>
> Hello!
>
> Hope you’re having a great day!
>
> I would like to combine plotting symbols with text.
>
> I have tried
> xp2a <- expression(paste(pch =3, “my stuff”))
> But when I use that as a plot title, it just shows as “3 my stuff”.
>
> I have a feeling that it’s going to be something very straightforward that
> I am missing.
>
> Thanks for your help,
> Sincerely,
> Erin
> --
> Erin Hodgess, PhD
> mailto: erinm.hodg...@gmail.com
>
> [[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] How to represent tree-structured values

2022-05-30 Thread Jim Lemon
Hi Richard,
Thinking about this, you might also find intersectDiagram, also in
plotrix, to be useful.

Jim

On Mon, May 30, 2022 at 4:37 PM Jim Lemon  wrote:
>
> Hi Richard,
> Some years ago I had a try at illustrating Multiple Causes of Death
> (MCoD) data. I settled on what is sometimes called a "sizetree". You
> can see some examples in the sizetree function help page in "plotrix".
> Unfortunately I can't use the original data as it was confidential.
>
> Jim
>
> On Mon, May 30, 2022 at 2:55 PM Richard O'Keefe  wrote:
> >
> > There is a kind of data I run into fairly often
> > which I have never known how to represent in R,
> > and nothing I've tried really satisfies me.
> >
> > Consider for example
> >  ...
> >  - injuries
> >...
> >- injuries to limbs
> >  ...
> >  - injuries to extremities
> >...
> >- injuries to hands
> >  - injuries to dominant hand
> >  - injuries to non-dominant hand
> >...
> >  ...
> >...
> >
> > This isn't ordinal data, because there is no
> > "left to right" order on the values.  But there
> > IS a "part/whole" order, which an analysis should
> > respect, so it's not pure nominal data either.
> >
> > As one particular example, if I want to
> > tabulate data like this, an occurrence of one
> > value should be counted as an occurrence of
> > *every* superordinate value.
> >
> > Examples of such data include "why is this patient
> > being treated", "what drug is this patient being
> > treated with", "what geographic region is this
> > school from", "what biological group does this
> > insect belong to".
> >
> > So what is the recommended way to represent
> > and the recommended way to analyse such data in R?
> >
> > [[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] How to represent tree-structured values

2022-05-30 Thread Jim Lemon
Hi Richard,
Some years ago I had a try at illustrating Multiple Causes of Death
(MCoD) data. I settled on what is sometimes called a "sizetree". You
can see some examples in the sizetree function help page in "plotrix".
Unfortunately I can't use the original data as it was confidential.

Jim

On Mon, May 30, 2022 at 2:55 PM Richard O'Keefe  wrote:
>
> There is a kind of data I run into fairly often
> which I have never known how to represent in R,
> and nothing I've tried really satisfies me.
>
> Consider for example
>  ...
>  - injuries
>...
>- injuries to limbs
>  ...
>  - injuries to extremities
>...
>- injuries to hands
>  - injuries to dominant hand
>  - injuries to non-dominant hand
>...
>  ...
>...
>
> This isn't ordinal data, because there is no
> "left to right" order on the values.  But there
> IS a "part/whole" order, which an analysis should
> respect, so it's not pure nominal data either.
>
> As one particular example, if I want to
> tabulate data like this, an occurrence of one
> value should be counted as an occurrence of
> *every* superordinate value.
>
> Examples of such data include "why is this patient
> being treated", "what drug is this patient being
> treated with", "what geographic region is this
> school from", "what biological group does this
> insect belong to".
>
> So what is the recommended way to represent
> and the recommended way to analyse such data in R?
>
> [[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] How to color boxplots with respect to the variable names

2022-05-29 Thread Jim Lemon
Hi Neha,
As you have a distinguishing feature in the variable names, here is
one way to do it:

RF<- c(4.7, 1.52, 1.46, 4.5, 0.62, 1.12)
RF_LOO<- c(5.2, 1.52, 1.44, 4.3, 0.64, 1.11)
RF_boot<- c(5.8, 1.5, 1.23, 4.3, 0.64, 1.12)
Ranger<- c(4.5, 1.57, 1.25, 3.75, 0.56, 1.09)
Ranger_LOO<- c(5, 1.56, 1.35, 3.7, 0.6, 1.0)
Ranger_boot<- c(4.2, 1.53, 1.12, 3.7, 0.63, 1.1)
SVM<- c(3.51, 1.34, 0.62, 1.45, 0.5, 1.06)
SVM_LOO<- c(3.6, 1.33, 0.33, 1.4, 0.41, 1.1)
SVM_boot<- c(3.75, 1.35, 0.58, 1.4, 0.4, 1.0)
KNN<- c(2.85, 1.35, 0.25, 1.76, 0.43, 1.25)
KNN_LOO<- c(2.85, 1.34, 0.375, 1.75, 0.44, 1.27)
KNN_boot<- c(2.75, 1.35, 0.375, 1.75, 0.45, 1.27)
varnames<-c("RF","RF_LOO","RF_boot",
 "RANGER","RANGER_LOO","RANGER_boot",
 "SVM","SVM_LOO","SVM_boot",
 "KNN","KNN_LOO","KNN_boot")
colors<-rep("blue",length(varnames))
colors[grep("LOO",varnames)]<-"green"
colors[grep("boot",varnames)]<-"red"
at.x <- seq(1,by=.4, length.out = 10)
boxplot(RF, RF_LOO, RF_boot, Ranger, Ranger_LOO, Ranger_boot, SVM, SVM_LOO,
SVM_boot,
KNN, KNN_LOO, KNN_boot, range = 0, col=colors, names= c("RF",
"RF_LOO", "RF_boot",
"Ranger", "Ranger_LOO", "Ranger_boot", "SVM", "SVM_LOO", "SVM_boot",
"KNN", "KNN_LOO",
"KNN_boot"),las=2,boxwex=0.5,outline=FALSE,cex.axis=0.8, main="Consistency
of the 100% features ")
legend(8,5.5,c("Raw","LOO","boot"),fill=c("blue","green","red"))

Jim

On Mon, May 30, 2022 at 4:46 AM Neha gupta  wrote:
>
> I have the following data and I need to use a boxplot which displays the
> variables (RF, Ranger, SVM, KNN) with one color, variables (RF_boot,
> Ranger_boot, SVM_boot, KNN_boot) with another color and the variables
> (RF_LOO, SVM_LOO, Ranger_LOO, KNN_LOO) with another color.
>
> How can I do that? Currently, I am using the base boxplot which displays
> them in one color. I know it will be more easily achieved with ggplot but I
> have no experience/knowledge with it.
>
> RF= c(4.7, 1.52, 1.46, 4.5, 0.62, 1.12)
> RF_LOO= c(5.2, 1.52, 1.44, 4.3, 0.64, 1.11)
> RF_boot= c(5.8, 1.5, 1.23, 4.3, 0.64, 1.12)
> Ranger= c(4.5, 1.57, 1.25, 3.75, 0.56, 1.09)
> Ranger_LOO= c(5, 1.56, 1.35, 3.7, 0.6, 1.0)
> Ranger_boot= c(4.2, 1.53, 1.12, 3.7, 0.63, 1.1)
> SVM= c(3.51, 1.34, 0.62, 1.45, 0.5, 1.06)
> SVM_LOO= c(3.6, 1.33, 0.33, 1.4, 0.41, 1.1)
> SVM_boot= c(3.75, 1.35, 0.58, 1.4, 0.4, 1.0)
> KNN= c(2.85, 1.35, 0.25, 1.76, 0.43, 1.25)
> KNN_LOO= c(2.85, 1.34, 0.375, 1.75, 0.44, 1.27)
> KNN_boot= c(2.75, 1.35, 0.375, 1.75, 0.45, 1.27)
>
> My base boxplot is here
>
> colors = rep("blue",12)
> at.x <- seq(1,by=.4, length.out = 10)
> boxplot(RF, RF_LOO, RF_boot, Ranger, Ranger_LOO, Ranger_boot, SVM, SVM_LOO,
> SVM_boot,
> KNN, KNN_LOO, KNN_boot, range = 0, col=colors, names= c("RF",
> "RF_LOO", "RF_boot",
> "Ranger", "Ranger_LOO", "Ranger_boot", "SVM", "SVM_LOO", "SVM_boot",
> "KNN", "KNN_LOO",
> "KNN_boot"),las=2,boxwex=0.5,outline=FALSE,cex.axis=0.8, main="Consistency
> of the 100% features ")
>
> [[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] Help for funnel plot

2022-05-15 Thread Jim Lemon
Hi,
Looking at the help page for "funnel", I first thought that the
"shade" argument would be the one. However, that seems to take a
specific color. Perhaps the function computes the shading from that. I
have never used the "funnel" function myself, so I don't have a good
idea of how that left-to-right gradient is determined. Perhaps:

w...@metafor-project.org

could tell you.

Jim

On Sun, May 15, 2022 at 10:24 PM De Simone
 wrote:
>
> Thank you Jim
> I attached an example for color gradient
> What would be the argument for one color gradient. I haven't used the plotrix 
> before
>
> On Sun, May 15, 2022 at 10:56 AM Jim Lemon  wrote:
>>
>> Hi,
>> There are a number of functions that will transform numeric values
>> into colors. One is color.scale in the plotrix package. This accepts a
>> vector of numeric values and linearly transforms them into one or more
>> ranges of colors. The resulting colors can then be passed to the
>> appropriate arguments in your plotting function.
>>
>> Jim
>>
>> On Sun, May 15, 2022 at 3:48 PM De Simone  
>> wrote:
>> >
>> > Hi,
>> > Excuse me for this silly question
>> > how do I get a colour gradient like the one attached. Colours are a bit
>> > limited
>> > Any specific code for the reference line and pseudo confidence lines. I use
>> > "lty", but this do both
>> >
>> > Here is my argument
>> >
>> > dat <- escalc("MD", m1i=Mean_TAP, sd1i= SD_TAP, n1i= N_TAP,
>> > m2i=Mean_caudal, sd2i= SD_caudal, n2i= N_caudal, slab=Study, data=
>> > Duration_of_analgesia)
>> >
>> >
>> >
>> > res <- rma(yi, vi, data=dat, measure="MD", method="DL")
>> >
>> >
>> > funnel(res, main="Duration of analegsia", back = 12, xlab="Mean difference
>> > (hours)", cex = 1.2,  lwd = 2, lty = "solid", mgp = c(2, 1, 0), font.main =
>> > 1, font.lab = 2, font.axis = 2)
>> >
>> > Thank you
>> > __
>> > 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] Help for funnel plot

2022-05-15 Thread Jim Lemon
Hi,
There are a number of functions that will transform numeric values
into colors. One is color.scale in the plotrix package. This accepts a
vector of numeric values and linearly transforms them into one or more
ranges of colors. The resulting colors can then be passed to the
appropriate arguments in your plotting function.

Jim

On Sun, May 15, 2022 at 3:48 PM De Simone  wrote:
>
> Hi,
> Excuse me for this silly question
> how do I get a colour gradient like the one attached. Colours are a bit
> limited
> Any specific code for the reference line and pseudo confidence lines. I use
> "lty", but this do both
>
> Here is my argument
>
> dat <- escalc("MD", m1i=Mean_TAP, sd1i= SD_TAP, n1i= N_TAP,
> m2i=Mean_caudal, sd2i= SD_caudal, n2i= N_caudal, slab=Study, data=
> Duration_of_analgesia)
>
>
>
> res <- rma(yi, vi, data=dat, measure="MD", method="DL")
>
>
> funnel(res, main="Duration of analegsia", back = 12, xlab="Mean difference
> (hours)", cex = 1.2,  lwd = 2, lty = "solid", mgp = c(2, 1, 0), font.main =
> 1, font.lab = 2, font.axis = 2)
>
> Thank you
> __
> 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] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Jim Lemon
Hi Paul,
Based on my guess that all values have been normalized, I would say:

mat<-(matrix(runif(16,-5,5),4))
df<-as.data.frame(mat)
df[abs(df) < 3]<-NA
df
   V1   V2   V3V4
1   NA 4.675699 3.166625NA
2   NA   NA   NA  3.463660
3 4.288831   NA 4.032902 -4.343869
4   NA   NA   NANA

Beware that this behavior of data frames may not persist in the
future. You may have to convert to a matrix and then convert the
result back again.

Jim

On Mon, May 9, 2022 at 6:24 PM Paul Bernal  wrote:
>
> Dear friends,
>
> I have a dataframe which every single (i,j) entry (i standing for ith row,
> j for jth column) has been normalized (converted to z-scores).
>
> Now I want to filter or subset the dataframe so that I only end up with a a
> dataframe containing only entries greater than -3 or less than 3.
>
> How could I accomplish this?
>
> Best,
> Paul
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R Code Execution taking forever

2022-04-23 Thread Jim Lemon
HI Paul,
I had a problem a bit like this when trying to implement the Lim-Wolfe
imputation for ranks. The size of the output matrix increases
exponentially with the size of the initial matrix and it goes into
disk-swapping slow motion. It works for small matrices, but rapidly
runs out of memory. I have planned to insert code to only retain the
largest maximum to fix this. If I get to it, I'll post the result.

Jim

On Sun, Apr 24, 2022 at 11:01 AM Paul Bernal  wrote:
>
> Dear R friends,
>
> Hope you are doing great. The reason why I am contacting you all, is
> because the code I am sharing with you takes forever. It started running at
> 2:00 AM today, and it's 7:52 PM and is still running (see code at the end
> of this mail).
>
> I am using Rx64  4.1.2, and the code is being executed in RStudio. The
> RStudio version I am currently using is Version 2022.02.0 Build 443
> "Prairie Trillium" Release (9f796939, 2022-02-16) for Windows.
>
> My PC specs:
> Processor: Intel(R) Core(TM) i5-10310U CPU @ 1.70 GHz
> Installed RAM: 16.0 GB (15.6 GB usable)
> System type: 64-bit operating system, x64-based processor
> Local Disc(C:) Free Space: 274 GB
>
> I am wondering if there is/are a set of system variable(s) or something I
> could do to improve the performance of the program.
>
> It is really odd this code has taken this much (and it is still running).
>
> Any help and/or guidance would be greatly appreciated.
>
> Best regards,
> Paul
>
>
>
>
> #performing 1,000,000 simulations 10 times
> num_trials_6 = 100
> dice_rolls_6 = num_trials_6*12
> num_dice_6 = 1
> dice_sides_6 = 6
>
> prob_frame_6 <- data.frame(matrix(ncol = 10, nrow = 1))
>
> k <- 0
> while(k < 10){
>   dice_simul_6 = data.frame(dice(rolls = dice_rolls_6, ndice = num_dice_6,
> sides = dice_sides_6, plot.it = FALSE))
>
>   #constructing matrix containing results of all dice rolls by month
>   prob_matrix_6 <- data.frame(matrix(dice_simul_6[,1], ncol = 12, byrow =
> TRUE))
>
>   #naming each column by it's corresponding month name
>   colnames(prob_matrix_6) <-
> c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
>
>
>   #assigning each person´s name depending on the number showed in the dice
> once rolled
>   for (i in 1:nrow(prob_matrix_6)){
> for (j in 1:ncol(prob_matrix_6)){
>   if (prob_matrix_6[i,j] == 1){
> prob_matrix_6[i,j] = "Alice"
>   }
>   if (prob_matrix_6[i,j] == 2){
> prob_matrix_6[i,j] = "Bob"
>   }
>   if (prob_matrix_6[i,j] == 3){
> prob_matrix_6[i,j] = "Charlie"
>   }
>   if (prob_matrix_6[i,j] == 4){
> prob_matrix_6[i,j] = "Don"
>   }
>   if (prob_matrix_6[i,j] == 5){
> prob_matrix_6[i,j] = "Ellen"
>   }
>   if (prob_matrix_6[i,j] == 6){
> prob_matrix_6[i,j] = "Fred"
>   }
>
> }
>   }
>
>   #calculating column  which will have a 1 if trial was successful and a 0
> otherwise
>   prob_matrix_6['success'] <- for (i in 1:nrow(prob_matrix_6)){
> if (("Alice" %in% prob_matrix_6[i,]) & ("Bob" %in% prob_matrix_6[i,]) &
> ("Charlie" %in% prob_matrix_6[i,]) & ("Don" %in% prob_matrix_6[i,]) &
> ("Ellen" %in% prob_matrix_6[i,]) & ("Fred" %in% prob_matrix_6[i,])){
>   prob_matrix_6[i,13] = 1
> }else{
>   prob_matrix_6[i,13] = 0
> }
>   }
>
>   #relabeling column v13 so that its new name is success
>   colnames(prob_matrix_6)[13] <- "success"
>
>
>   #calculating probability of success
>
>   p6 = sum(prob_matrix_6$success)/nrow(prob_matrix_6)
>   prob_frame_6 <- cbind(prob_frame_6, p6)
>
>   k = k + 1
>
> }
>
> prob_frame_6 <- prob_frame_6[11:20]
> colnames(prob_frame_6) <-
> c("p1","p2","p3","p4","p5","p6","p7","p8","p9","p10")
> average_prob_frame_6 <- rowMeans(prob_frame_6)
> trial_100_10_frame <- cbind(prob_frame_6, average_prob_frame_6)
> final_frame_6 <- trial_100_10_frame
> colnames(final_frame_6) <-
> c("p1","p2","p3","p4","p5","p6","p7","p8","p9","p10", "avg_prob_frame_5")
>
> write.csv(final_frame_6, "OneMillion_Trials_Ten_Times_Results.csv")
> print(final_frame_6)
> print(paste("The average probability of success when doing 1,000,000 trials
> 10 times is:", average_prob_frame_6))
>
> [[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] Error with text analysis data

2022-04-12 Thread Jim Lemon
Hi Neha,
The error message is about not having _factors_ with two or more
levels. Apart from using stringsAsFactors=FALSE (meaning that you
probably won't get any factors in "d"), your sample data doesn't look
like CSV format. Perhaps the lines have been truncated. You may get
something with stringsAsFactors=TRUE, but I don't know whether it will
be sensibler.

Jim

On Wed, Apr 13, 2022 at 8:12 AM Neha gupta  wrote:
>
> Hello everyone, I have text data with output variable have three subgroups.
> I am using the following code but getting the error message (see error
> after the code).
>
> d=read.csv("SONAR_RULES.csv", stringsAsFactors = FALSE)
> d$REMEDIATION_FUNCTION=NULL
> d$DEF_REMEDIATION_GAP_MULT=NULL
> d$REMEDIATION_BASE_EFFORT=NULL
>
> index <- createDataPartition(d$TYPE, p = .70,list = FALSE)
> tr <- d[index, ]
> ts <- d[-index, ]
>
> ctrl <- trainControl(method = "cv",number=3, index = index, classProbs =
> TRUE, summaryFunction = multiClassSummary)
>
> ran <- train(TYPE ~ ., data = tr,
> method = "rpart",
> ## Will create 48 parameter combinations
> tuneLength = 3,
> na.action= na.pass,
> metric = "Accuracy",
> preProc = c("center", "scale", "nzv"),
> trControl = ctrl)
> getTrainPerf(ran)
>
> *It gives me error:*
>
>
> *Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
> contrasts can be applied only to factors with 2 or more levels*
>
>
> *My data is as follow*
>
> Rows: 1,819
> Columns: 14
> $ PLUGIN_RULE_KEY  "InsufficientBranchCoverage",
> "InsufficientLin~
> $ PLUGIN_CONFIG_KEY"", "", "", "", "", "", "", "", "", "",
> "S1120~
> $ PLUGIN_NAME  "common-java", "common-java",
> "common-java", "~
> $ DESCRIPTION  "An issue is created on a file as soon
> as the ~
> $ SEVERITY "MAJOR", "MAJOR", "MAJOR", "MAJOR",
> "MAJOR", "~
> $ NAME "Branches should have sufficient
> coverage by t~
> $ DEF_REMEDIATION_FUNCTION "LINEAR", "LINEAR", "LINEAR",
> "LINEAR_OFFSET",~
> $ REMEDIATION_GAP_MULT NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA~
> $ DEF_REMEDIATION_BASE_EFFORT  "", "", "", "10min", "", "", "5min",
> "5min", "~
> $ GAP_DESCRIPTION  "number of uncovered conditions",
> "number of l~
> $ SYSTEM_TAGS  "bad-practice", "bad-practice",
> "convention", ~
> $ IS_TEMPLATE  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0~
> $ DESCRIPTION_FORMAT   "HTML", "HTML", "HTML", "HTML", "HTML",
> "HTML"~
> $ TYPE "CODE_SMELL", "CODE_SMELL",
> "CODE_SMELL", "COD~
>
> [[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] replacing a value

2022-04-05 Thread Jim Lemon
Hi Ani,
It seems to work for me:

 a<-c(20, 20, 14.2375646029948, 19.9, 20, 20, 16.3092078677214,
20, 20, 20, 20, 20, 20, 20, 20, 14.8590932408795, 16.178935255298,
20, 20, 20, 20, 27.6404077886079, 20, 20, 20, 20, 20, 21.9857063037444,
20, 20, 20, 20)
> a==20
[1]  TRUE  TRUE FALSE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
[13]  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE
[25]  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE
> a[a==20]<-0
> a
[1]  0.0  0.0 14.23756 20.0  0.0  0.0 16.30921  0.0
[9]  0.0  0.0  0.0  0.0  0.0  0.0  0.0 14.85909
[17] 16.17894  0.0  0.0  0.0  0.0 27.64041  0.0  0.0
[25]  0.0  0.0  0.0 21.98571  0.0  0.0  0.0  0.0

Notice that it didn't make 19.99 equal to 20, but did
round it up when printing the result. How do you know that it failed?

Jim

On Wed, Apr 6, 2022 at 12:48 PM ani jaya  wrote:
>
> Dear R-Help,
>
> I try to change a specific value here by following these:
>
> https://www.journaldev.com/39695/replace-in-r
> https://stackoverflow.com/questions/5824173/replace-a-value-in-a-data-frame-based-on-a-conditional-if-statement
> https://stackoverflow.com/questions/54615462/how-to-replace-certain-values-in-a-specific-rows-and-columns-with-na-in-r
> ..and many more
>
> however, it is not change anything. I believe it "should" be easy but
> I think I am missing something. I am afraid it is my system that has a
> problem but restarting r is not solve the problem.
> I just want to change 20 to 0 in my data.
>
> > dput(a)
> c(20, 20, 14.2375646029948, 19.9, 20, 20, 16.3092078677214,
> 20, 20, 20, 20, 20, 20, 20, 20, 14.8590932408795, 16.178935255298,
> 20, 20, 20, 20, 27.6404077886079, 20, 20, 20, 20, 20, 21.9857063037444,
> 20, 20, 20, 20)
>
> what I did:
> a[a==20]<-0 #fail
> a<-replace(a,a==20,0) #fail
> a[which(a==20)]<-0 #fail
>
> > sessionInfo()
> R version 4.1.2 (2021-11-01)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 19043)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> system code page: 949
>
> Best,
> Ani
>
> __
> 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] Plotting proportions

2022-04-03 Thread Jim Lemon
Hi Nick,
If you can bear using R base graphics, the plotrix package has a
function named "getYmult" that allows you to adjust for the aspect
ratio of any plot area.

Jim

On Sun, Apr 3, 2022 at 11:14 PM Nick Wray  wrote:
>
> Hello  If you plot a square in the default R studio window you see a
> rectangle.  Does anyone know what the proportions of the sides of this
> rectangle are?  Thanks Nick Wray
>
> [[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] Cook's distance for least absolute deviation (lad) regressions

2022-03-20 Thread Jim Lemon
Hi Kelly,
Perhaps the best place to look is the "car" package. There is a
somewhat confusing reference in the "cookd" function help page to the
"cooks.distance" function in the "base" package that doesn't seem to
be there.  Whether this is the case or not, I think you can still use
the "cookd" alias.

Jim

On Mon, Mar 21, 2022 at 11:57 AM Kelly Thompson  wrote:
>
> I'm wanting to calculate Cook's distance for least absolute deviation
> (lad) regressions.
>
> Which R packages and functions offer this?
>
> 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] setting zeros for missing interval in data

2022-02-28 Thread Jim Lemon
Hi Eliza,
It sure was:

YY$datetime<-strptime(YY$TIMESTAMP,"%Y/%m/%d %I:%M:%S %p")
dt5min<-seq(ISOdate(2021,5,1,0,5),ISOdate(2021,5,31,12,55),by="5 min")
newdt<-data.frame(datetime=dt5min)
newyy<-merge(newdt,YY,by="datetime",all=TRUE)
newyy$RAINFALL[is.na(newyy$RAINFALL)]<-0
plot(newyy$datetime,newyy$RAINFALL)

Jim

On Tue, Mar 1, 2022 at 2:57 PM Eliza Botto  wrote:
>
> [The data setting in the last email might be faulty]
>
> Dear useRs,
>
> I have the following dataset which represents rainfall data at a 5-minute 
> interval from 1 May 2021 to 30 September 2021.
>
> > dput(YY)
>
> structure(list(CHANNEL = c(30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
> 30L, 30L), YEAR = c(2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L, 2021L,
> 2021L, 2021L, 2021L, 2021L), TIMESTAMP = c("2021/05/02 10:00:00 PM",
> "2021/05/02 10:55:00 PM", "2021/05/04 05:40:00 PM", "2021/05/04 06:50:00 PM",
> "2021/05/05 03:05:00 AM", "2021/05/08 05:15:00 AM", "2021/05/08 05:20:00 AM",
> "2021/05/08 05:30:00 AM", "2021/05/08 05:50:00 AM", "2021/05/08 06:05:00 AM",
> "2021/05/08 07:15:00 AM", "2021/05/08 08:00:00 AM", "2021/05/08 08:05:00 AM",
> "2021/05/08 08:15:00 AM", "2021/05/08 08:35:00 AM", "2021/05/08 08:50:00 AM",
> "2021/05/08 09:05:00 AM", "2021/05/08 09:30:00 AM", "2021/05/08 09:45:00 AM",
> "2021/05/08 09:55:00 AM", "2021/05/08 10:10:00 AM", "2021/05/08 10:20:00 AM",
> "2021/05/08 10:40:00 AM", "2021/05/08 10:55:00 AM", "2021/05/08 11:15:00 AM",
> "2021/05/08 11:25:00 AM", "2021/05/08 11:35:00 AM", "2021/05/08 11:45:00 AM",
> "2021/05/08 11:50:00 AM", "2021/05/08 12:00:00 PM", "2021/05/08 12:05:00 PM",
> "2021/05/08 12:15:00 PM", "2021/05/08 12:20:00 PM", "2021/05/08 12:30:00 PM",
> "2021/05/08 12:35:00 PM", "2021/05/08 12:50:00 PM", "2021/05/08 01:35:00 PM",
> "2021/05/08 01:50:00 PM", "2021/05/08 02:20:00 PM", "2021/05/08 02:30:00 PM",
> "2021/05/08 02:35:00 PM", "2021/05/08 03:00:00 PM", "2021/05/08 03:35:00 PM",
> "2021/05/08 03:45:00 PM", "2021/05/08 04:30:00 PM", "2021/05/08 04:40:00 PM",
> "2021/05/08 04:55:00 PM", "2021/05/08 05:05:00 PM", "2021/05/08 05:20:00 PM",
> "2021/05/08 07:25:00 PM", "2021/05/08 09:00:00 PM", "2021/05/08 09:25:00 PM",
> "2021/05/08 09:50:00 PM", "2021/05/08 10:15:00 PM", "2021/05/08 10:40:00 PM",
> "2021/05/08 11:35:00 PM", "2021/05/09 12:40:00 AM", "2021/05/09 01:10:00 AM",
> "2021/05/09 02:10:00 AM", "2021/05/09 06:00:00 AM", "2021/05/09 02:40:00 PM",
> "2021/05/09 02:45:00 PM", "2021/05/09 02:50:00 PM", "2021/05/09 02:55:00 PM",
> "2021/05/09 03:00:00 PM", "2021/05/09 03:05:00 PM", "2021/05/09 03:10:00 PM",
> "2021/05/09 03:15:00 PM", "2021/05/09 03:20:00 PM", "2021/05/09 03:25:00 PM",
> "2021/05/09 03:30:00 PM", "2021/05/09 03:35:00 PM", "2021/05/09 03:40:00 PM",
> "2021/05/09 03:45:00 PM", "2021/05/09 03:50:00 PM", "2021/05/09 03:55:00 PM",
> "2021/05/09 04:00:00 PM", "2021/05/09 04:05:00 PM", "2021/05/09 04:10:00 PM",
> "2021/05/09 04:15:00 PM", "2021/05/09 04:25:00 PM", "2021/05/09 04:30:00 PM",
> "2021/05/09 04:35:00 PM", "2021/05/09 04:40:00 PM", "2021/05/09 04:45:00 PM",
> "2021/05/09 04:50:00 PM", "2021/05/09 05:00:00 PM", "2021/05/09 05:05:00 PM",
> "2021/05/09 05:10:00 PM", "2021/05/09 05:20:00 PM", "2021/05/09 05:25:00 PM",
> "2021/05/09 05:35:00 PM", "2021/05/09 05:45:00 PM", "2021/05/09 05:50:00 PM",
> "2021/05/09 06:00:00 PM", "2021/05/09 06:10:00 PM", "2021/05/09 06:20:00 PM",
> "2021/05/09 06:30:00 PM", "2021/05/09 06:40:00 PM", "2021/05/09 06:50:00 PM"
> ), RAINFALL = c(0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
> 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.2, 

Re: [R] tidying up

2022-02-27 Thread Jim Lemon
Hi Avi,
I just sent in an answer to a very simple question. In many cases it
seems to me that the real problem isn't apparent from the request.
ektaraK appears to have almost no experience with R (sorry if I'm
wrong). A person in this position may sort of know what they want to
do but do not know how to ask the question. What's a reproducible
example? So I often submit really dumb looking answers that show the
person how to ask the question. If I'm successful, the OP learns how
to do some basic operation, but also learns how to ask the next
question. Until they get there, most responses just give them a typing
exercise.

Jim

On Mon, Feb 28, 2022 at 6:35 AM Avi Gross via R-help
 wrote:
>
> This mailing list seems to steadily get messages that some see as not 
> relevant to this forum. In particular, some see it as wrong to bring up some 
> things here and keep reminding people of some ground rules.
>
> So I want to know, briefly, if it is reasonable to ask a person with a 
> question or problem to reproduce their problem another way. If using RSTUDIO 
> or one of many IDE, can they run the code on a naked R interpreter by 
> sourcing the file or copying it in or typing it anew, or perhaps using IDLE 
> which comes by default with many installations of R? If using a library 
> (which I like so I am not really in agreement about the unsuitability) like 
> the tidyverse which is free and available to all even if loosely associated 
> with the RSTUDIO folks and that can be run on any version of R that I am 
> aware of, then some questions may still be fair if they are really about more 
> general R issues as much of the rest of the code may be base R and may be the 
> cause of whatever issue is being reported. And, some simple requests like 
> pointing out a missing comma, ...
>
> I have stated my thought before and it boils down to the reality that there 
> are some things about earlier versions of R that were far from perfect or 
> complete and a little healthy competition is not a bad thing and may help 
> base R evolve. Not everything in the tidyverse is better and it keeps 
> evolving and deprecating older features, but it cannot really be ignored any 
> longer. If you apply for a job at some company as something of an R expert, 
> you may well be asked by all kinds of people about their programs that use 
> the tidyverse for help or to help them solve a problem. You don't have to 
> like it, but if you cannot read it, you no longer are really qualified in 
> many places.
>
> Ask yourself if a language like R was created from scratch, what graphics 
> might be built into the base distribution? Would you rather have lattice or 
> ggplot or perhaps both as well as base R graphics? Would you make many of the 
> built-in functions more consistent, so for instance, the data being worked on 
> would be the first argument whenever possible?
>
> One reason there are so many packages is not so much due to the superiority 
> of R but because people find it lacks quite a bit. Much of that should not be 
> included, of course, if R is meant to be somewhat on the lean side, and yes, 
> packages are a deliberate way to extend it when needed. But when people use 
> it and think they are programming in R, ...
>
> __
> 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] Plot by month

2022-02-27 Thread Jim Lemon
Hi ektaraK,
Here is a step by step way to create an example and get your plot:

# make up a lot of dates
dates<-as.Date("2021-1-1")+sample(0:364,100)
# make up the temperatures
temps<-runif(100,0,40)
# create a data frame
mydf<-data.frame(date=dates,temp=temps)
# create a month variable
mydf$month<-factor(format(mydf$date,"%b"),levels=month.abb)
# calculate mean temperature for months
temp_x_month<-by(mydf$temp,mydf$month,mean)
# create a factor of the months of the year for plotting
months<-factor(month.abb,levels=month.abb)
# plot mean temperature by month
plot(months,temp_x_month,main="Mean temperature by month")

You may only need to apply the last three steps to your data.

Jim

On Sun, Feb 27, 2022 at 1:07 AM Ebert,Timothy Aaron  wrote:
>
> I did not get the data  but I was wondering what you have already tried.
> Try group_by() function
> Try fill= or color= in the aes() statement in ggplot.
>
> What is the goal?
> Do you want lines, bars, or dots?
>
> Is this a class?
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of ektaraful
> Sent: Saturday, February 26, 2022 2:00 AM
> To: r-help@r-project.org
> Subject: [R] Plot by month
>
> [External Email]
>
> Hi,
>
> I want to plot temp data from a csv file by month. Can you help me how I can 
> do it in R?
>
> A sample csv file is attached herewith. Please use left hand data.
>
> Thanks.
> ektaraK
> __
> 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=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=JeHylIm3ibHTYNZ-mLAAkF4JTrj_xyBnd0IQBZDJvV6HeovFeOLa5GwBe0LLBOwN=WJLtDEQ05d0kvlWFlrGCadjyBvwqCm_j37wsJ-CObyA=
> PLEASE do read the posting guide 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=JeHylIm3ibHTYNZ-mLAAkF4JTrj_xyBnd0IQBZDJvV6HeovFeOLa5GwBe0LLBOwN=QyEPln_51yStVY2Ec1hcAqygLeEh1CNf5JJT_vv1dto=
> 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] saving png images and X11

2022-02-26 Thread Jim Lemon
Hi Bogdan,
If we take the error message seriously, it may be that the initial X11
image was never displayed. When this very suspicious black box
function tried to transfer the image to a PNG file, it wasn't there or
the function couldn't find it.

Jim

On Sun, Feb 27, 2022 at 2:51 AM Bogdan Tanasa  wrote:
>
> Dear all,
>
> I am using a R package that renders the png images. As I am running the
> command below in a script, I would like to avoid the error below and still
> be able to save the images. How shall I do it ?
>
> > ChIPQCreport(SAMPLE, +  reportName = paste(ENTRY, "ChIPQC", 
> > sep="."), +  reportFolder = paste(ENTRY, "ChIPQCreport", 
> > sep="."))
> Saving 7 x 7 in image
> Error in png_dev(..., res = dpi, units = "in") : X11 is not available
>
> Shall I add the option :
>
> options(bitmapType='cairo')
>
> the png images are skipped and not saved on the disk. Thanks a lot,
>
> Bogdan
>
> [[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] Survey design for multilevel analysis

2022-02-01 Thread Jim Lemon
Hi Love,
I have finally had a chance to look at this more closely. I think that
the following link:

https://cran.r-project.org/web/packages/survival/vignettes/adjcurve.pdf

may be useful. See section 4.2.
This is not my area of expertise, but it seems to be a known problem.
Perhaps by posting to the:

R-SGI-Epi

mailing list you will get responses from specialists in the field.

Jim

On Tue, Feb 1, 2022 at 9:02 PM Love Umesi  wrote:
>
> I am new in using R, and I need to run a multilevel analysis (two-phase
> design on two levels) using Cox frailty survival model on a survey data
> (Nigeria Demographic and Health Survey Data).
>
> My problem is how to write the design weight using the two weights needed
> and apply them to the analysis.
>
> I have identified the needed variables for the survey design, which
> are : psu/cluster=
> v021 individual-level weight= wt1_1 cluster-level weigh= wt2_1 strata/stratum=
> v022
>
> Please can someone help me with the survey design (svydesign) code and how
> to include it and the weights in a model.
>
> I understand I have to use svycoxph in the model. Please how do I include
> survey design and account for the 2 weights (individual-level and
> cluster-level weights) in the gamma frailty model below?
>
> Frailty1 <- coxph (Surv(study_time, died) ~ factor(v024) + factor(mat_edu)
> + v025 + frailty(v021,distribution="gamma"), data=rcom2018)
>
> Really looking forward to your help as my project is hanging on this.
>
> Many thanks.
>
>
> library(survival)#> Warning: package 'survival' was built under R version 
> 4.0.5
> library(frailtypack)#> Warning: package 'frailtypack' was built under
> R version 4.0.5#> Loading required package: boot#> #> Attaching
> package: 'boot'#> The following object is masked from
> 'package:survival':#> #> aml#> Loading required package: MASS#>
> Loading required package: survC1#> Warning: package 'survC1' was built
> under R version 4.0.5#> Loading required package: doBy#> Warning:
> package 'doBy' was built under R version 4.0.5#> #> Attaching package:
> 'frailtypack'#> The following object is masked from
> 'package:survival':#> #> cluster
>
>
> rcom1 <- data.frame(
>   data.frame(
> pid = c(
>   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
>   14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
>   30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
>   46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
>   61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
>   77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
>   93, 94, 95, 96, 97, 98, 99, 100
> ),
> study_time = c(
>   13, 9, 17, 31, 39, 22, 24, 0, 23, 12, 9, 35,
>   18, 20, 60, 18, 5, 46, 26, 54, 37, 51, 31, 55, 27, 15, 39, 6,
>   29, 0, 9, 40, 23, 12, 35, 56, 14, 40, 57, 42, 5, 42, 39, 39,
>   54, 19, 52, 42, 7, 28, 53, 5, 28, 13, 37, 0, 23, 33, 27, 36, 20,
>   24, 58, 34, 12, 44, 3, 34, 14, 5, 10, 40, 12, 36, 19, 58, 17,
>   40, 39, 58, 53, 53, 1, 50, 2, 28, 24, 13, 13, 50, 46, 46, 19, 6,
>   32, 59, 9, 30, 30, 43
> ),
> died = c(
>   0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
>   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
>   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
>   0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
>   0
> ),
> v021 = c(
>   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
>   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
>   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
>   4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
>   5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
>   6
> ),
> v022 = c(
>   "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
>   "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2",
>   "2", "2", "2"
> ),
> v012 = c(
>   40, 37, 27, 27, 24, 32, 35, 35, 34, 20, 28,
>   28, 26, 24, 24, 25, 26, 26, 26, 26, 28, 27, 25, 25, 27, 26, 26,
>   21, 21, 31, 36, 36, 27, 23, 32, 32, 33, 33, 33, 28, 25, 37,
>   33, 34, 33, 28, 28, 29, 33, 33, 33, 39, 38, 38, 38, 38, 24, 27,
>   35, 40, 22, 38, 38, 21, 30, 30, 30, 39, 43, 18, 23, 23, 25, 25,
>   30, 45, 26, 26, 35, 35, 35, 35, 32, 32, 40, 25, 27, 30, 30, 30,
>   28, 28, 18, 27, 30, 30, 27, 21, 21, 30
> ),
> wt2_1 = c(
>   401.200012207031, 

Re: [R] How to avoid a divide by zero issue.

2022-01-25 Thread Jim Lemon
Hi Neha,
One sure cure for divide by zero is to omit zeros in the denominator variable.

num<-sample(0:10,20,TRUE)
denom<-sample(0:10,20,TRUE)
zeros<-denom == 0
num[!zeros]/denom[!zeros]

If you don't want to lose those data and there are no negative values,
you could add a small number to all denominator values if that would
still give useful output.

Jim

On Wed, Jan 26, 2022 at 7:51 AM Neha gupta  wrote:
>
> Hello everyone
>
> I have an output variable (0/1) and I want to evaluate how the model is
> biased when we have 1 and when 0 value.
>
> The problem is that the package of R I use here is designed originally to
> check bias for input metrics. When I evaluate it for this output variable,
> it gives me NA values, probably a divide by zero problem. Can I avoid this
> issue and how (I am not very expert of R language).
>
> Warm regards
>
> [[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] NAs are removed

2022-01-14 Thread Jim Lemon
Hi Neha,
You're using the argument "na.omit" in what function? My blind guess
is that there's a divide by zero shooting you from behind.

Jim

On Sat, Jan 15, 2022 at 6:32 AM Neha gupta  wrote:
>
> Hi everyone
>
> I use na.omit to remove NAs but still it gives me error
>
> Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed
>
> My data is:
>
> data.frame': 340 obs. of  15 variables:
>  $ DepthTree: num  1 1 1 1 1 1 1 1 1 1 ...
>  $ NumSubclass  : num  0 0 0 0 0 0 0 0 0 0 ...
>  $ McCabe   : num  1 1 1 1 1 1 3 3 3 3 ...
>  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
>  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
>  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
>  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
>  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
> 0.667 0.667 ...
>  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
>  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13 1 3
> 4 7 ...
>  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2 2
> 2 2 2 2 ...
>
> [[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] (Off-Topic) Time for a companion mailing list for R packages?

2022-01-13 Thread Jim Lemon
Hi,
I wasn't going to contribute to this, but I've got a couple of minutes
and the morning caffeine has hit me.
My 5 Point Plan for taking life as it comes:
1) I don't like to help people, I'd rather trick them into doing it themselves.
2) I'm lazy and intolerant. If somebody wants me to do their work for
them, that's what the delete key is for.
3) I'm not omniscient (and lazy, remember). If I can't provide an
answer, see 2) above.
4) I can read most HTML messages well enough. Be thankful they're not
sending TikTok videos.
5) I've got a good memory and I still blush at some of the stupid
questions I have asked.

Jim


On Fri, Jan 14, 2022 at 7:09 AM Marc Schwartz via R-help
 wrote:
>
> Eric,
>
> With respect to your second point, as one of the moderators for the
> R-Devel list, where the same considerations apply to all "official" R
> lists like R-Help here, the issue of plain text content restrictions is
> multi-factorial, partly with security considerations in mind, but has
> historically been imposed by the university (ETHZ) that hosts and
> archives all of these R related lists. It is also, historically, very
> common with open source communities generally.
>
> If one sends a message to the list that is only HTML, or perhaps a
> multi-part MIME message with both HTML and plain text sub-parts, the
> HTML markup will be stripped, leaving only the plain text part. You will
> usually see a line at the end of the post/reply as follows:
>
>"[[alternative HTML version deleted]]"
>
> when that occurs.
>
> When we see some messages here that appear to be a single, longish,
> unformatted and largely unreadable paragraph, with no obvious line/para
> breaks, where the sender may have actually formatted the message in HTML
> before sending, that is the result of the HTML filtering by the ETHZ
> server, perhaps also influenced by how the sender's e-mail client
> formatted the plain text sub-part of the message.
>
> That is why it is best, and recommended, to format the e-mail message
> natively in plain text only to begin with, and there are numerous e-mail
> clients that support that functional distinction.
>
> Also, there are still folks out there that use plain text only e-mail
> clients, yes in 2022, where we have to recognize and be sensitive to
> that reality as the official R support venues.
>
> With respect to attachments, a limited set of them are allowed here for
> the R lists. Primarily, these are PDF, [E]PS, PNG and JPG, which would
> generally accommodate the graphics related scenarios that you mention.
>
> As has been noted elsewhere in this thread, there are a number of other
> venues that provide R specific, community based, support using online
> forums with varying levels of, perhaps more "modern" functionality. The
> most prolific likely to be StackOverflow which, without any doubt, and
> to some extent via the gamification on that platform, has markedly
> reduced the traffic volume here over the years. That shift initially
> started in circa 2009 when that platform began, and then rapidly grew,
> with traffic volume on R-Help peaking in 2010. I occasionally run
> traffic volume reports comparing the two venues over time, and having
> been a part of the R community for ~20 years now, the drop-off here post
> 2010 is quite noticeable. I don't label that phenomenon as good or bad,
> it is simply the reality of the situation and this is not a competition
> for traffic.
>
> As noted in this thread, other locations find R related interactions as
> well, which would include LinkedIn, ResearchGate, RStudio's forums, and
> some package developers provide support via their GitHub repos, using
> the Issues functionality, even if not a bug. In the case of RStudio,
> having their own support forums, and as comes up here, there is
> frequently a lack of distinction between RStudio the third party GUI,
> and R itself, resulting in confusion by users, and subsequent
> "energetic" discussion here.
>
> I am not advocating the general use or non-use of any specific platform,
> but am primarily addressing the limitations here on the official lists
> as currently implemented. For the record, I am not an RStudio user and
> do not participate on StackOverflow, albeit, in the latter case, Google
> searches on technical subject matter do lead me there on occasion.
>
> We have had numerous online and offline discussions over the many years
> of sub-setting the official R lists by common subject matter. The
> challenge is always, how much granularity do you impose on the list
> structure, even if you just create an "R-Newbie" list, which
> specifically has been discussed many times over the years. The more
> granularity you impose, the more difficult it becomes to manage and
> interact with those "stove pipes", when there may not be a clear
> separation in subject matter, and there will be the inevitable overlap
> in content. You also need relevant, volunteer, community members to then
> be willing to moderate, 

Re: [R] Method Guidance

2022-01-11 Thread Jim Lemon
Hi Jeff,
A completely obscure question deserves a completely obscure answer:

jrdf<-read.table(text="Time   Event_AEvent_B   Lag_B
1  1 10
2  0 11
3  0 00
4  1 00
5  0 11
6  0 00
7  0 13
8  1 10
9  0 00
10 0 12",
header=TRUE,stringsAsFactors=FALSE)
plot(jrdf$Time-0.2,jrdf$Event_A,type="p",
 xlim=c(1,12),ylim=c(0.9,1.1),
 xlab="Day",ylab="",main="The As and the Bs",
 pch=c(" ","A")[jrdf$Event_A+1],yaxt="n")
points(jrdf$Time+jrdf$Lag_B+0.2,jrdf$Event_B,pch=c(" ","B")[jrdf$Event_B+1])

Jim

On Wed, Jan 12, 2022 at 1:33 PM Jeff Newmiller  wrote:
>
> 1) Figure out how to post plain text please. What you saw is not what we see.
>
> 2) I see a "table" of input information but no specific expectation of what 
> would come out of this hypothetical function.
>
> 3) Maybe you will find something relevant in this blog post: 
> https://jdnewmil.github.io/blog/post/cumsum-and-diff-tricks/
>
> ps not sure what "grate so sour" was supposed to be.
>
> pps While loops are not necessarily evil.
>
> On January 11, 2022 4:56:20 PM PST, Jeff Reichman  
> wrote:
> >R-Help Forum
> >
> >
> >
> >Looking for a little guidance. Have an issue were I'm trying to determine
> >the time between when Event A happened(In days) to when a subsequent Event B
> >happens. For Example at Time 1 Evat A happens and subsequently Event B
> >happens at the same day (0) and the next day (1) then Event A happens again
> >at time 4 and Event B happens the next day and 3 days later so on and so
> >forth. I gather there is no function that will do that so I suspect I will
> >need to grate so sour of do while loop?  Any suggestions?
> >
> >
> >
> >
> >
> >Time  Event_A   Event_B   Time_B
> >
> >1  1  1
> >0
> >
> >2  0  1
> >1
> >
> >3  0  0
> >0
> >
> >4  1  0
> >0
> >
> >5  0  1
> >1
> >
> >6  0  0
> >0
> >
> >7  0  1
> >3
> >
> >8  1  1
> >0
> >
> >9  0  0
> >0
> >
> >10   0  1  2
> >
> >
> >
> >
> >Jeff Reichman
> >
> >
> >   [[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.

__
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] unexpected (?) behavior of box()

2022-01-07 Thread Jim Lemon
Yes, the Mercator projection unwraps the globe (360 degrees around)
while the poles are 180 degrees apart. It then stretches the result
into a rectangle. If you enter:

par("usr")

after drawing the world map you will see the proportions.

Jim

On Fri, Jan 7, 2022 at 7:20 PM ani jaya  wrote:
>
> Hi Jim,
>
> Thank you for the alternative. Absolutely will try it.
> Can you explain a bit about "Maps draws an approximately 2x1 plot"?
> Is it the size proportion 2 in x-axis and 1 in y-axis?
>
> On Fri, Jan 7, 2022 at 4:41 PM Jim Lemon  wrote:
> >
> > Hi Ani,
> > Blame Mercator. Maps draws an approximately 2x1 plot. Maybe this:
> >
> > mappar<-par("usr")
> > rect(mappar[1],mappar[3],mappar[2],mappar[4])
> >
> > Jim
> >
> > On Fri, Jan 7, 2022 at 6:25 PM ani jaya  wrote:
> > >
> > > Dear R expert,
> > >
> > > I try to box a figure using box(). However it box the default margin,
> > > not the specified margin.
> > >
> > > #working as expected
> > > barplot(1:20)
> > > box()
> > >
> > > #working as expected, the box follow the margin
> > > par(mar=c(2, 6, 5, 4))
> > > barplot(1:20)
> > > box()
> > >
> > > #not working
> > > install.packages("maps")
> > > library(maps)
> > > par(mar=c(2, 6, 5, 4))
> > > m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
> > >lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
> > > box()
> > >
> > > #the turnaround
> > > par(mar=c(2, 6, 5, 4))
> > > m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
> > >lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
> > > par(mar=c(2, 6, 5, 4))
> > > box()
> > >
> > > I just curious with this behavior. Is it the problem with the package
> > > "map" or box() function?
> > > Thank you.
> > >
> > > > sessionInfo()
> > > R version 4.0.2 (2020-06-22)
> > > Platform: i386-w64-mingw32/i386 (32-bit)
> > > Running under: Windows 10 x64 (build 19043)
> > >
> > >
> > >
> > > Ani
> > >
> > > __
> > > 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] unexpected (?) behavior of box()

2022-01-06 Thread Jim Lemon
Hi Ani,
Blame Mercator. Maps draws an approximately 2x1 plot. Maybe this:

mappar<-par("usr")
rect(mappar[1],mappar[3],mappar[2],mappar[4])

Jim

On Fri, Jan 7, 2022 at 6:25 PM ani jaya  wrote:
>
> Dear R expert,
>
> I try to box a figure using box(). However it box the default margin,
> not the specified margin.
>
> #working as expected
> barplot(1:20)
> box()
>
> #working as expected, the box follow the margin
> par(mar=c(2, 6, 5, 4))
> barplot(1:20)
> box()
>
> #not working
> install.packages("maps")
> library(maps)
> par(mar=c(2, 6, 5, 4))
> m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
>lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
> box()
>
> #the turnaround
> par(mar=c(2, 6, 5, 4))
> m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
>lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
> par(mar=c(2, 6, 5, 4))
> box()
>
> I just curious with this behavior. Is it the problem with the package
> "map" or box() function?
> Thank you.
>
> > sessionInfo()
> R version 4.0.2 (2020-06-22)
> Platform: i386-w64-mingw32/i386 (32-bit)
> Running under: Windows 10 x64 (build 19043)
>
>
>
> Ani
>
> __
> 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] Dependencies for building R

2022-01-06 Thread Jim Lemon
Thanks, Bert. I will.

Jim

On Fri, Jan 7, 2022 at 3:44 PM Bert Gunter  wrote:
>
> Ask on r-sig-fedora rather than here, no?
>
> On Thu, Jan 6, 2022, 8:18 PM Jim Lemon  wrote:
>>
>> Hi,
>> I'm facing the usual challenge of  building the latest release of R on
>> a new install of Fedora 35 Linux. Is there a list of dependencies that
>> have to be installed (or even better, a package) to avoid the
>> necessity of running ./configure many times and installing them
>> piecemeal? I've just been reading Installation and Administration in
>> the manual and haven't found anything like this. Any pointers
>> appreciated.
>>
>> Jim
>>
>> __
>> 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] Dependencies for building R

2022-01-06 Thread Jim Lemon
Hi,
I'm facing the usual challenge of  building the latest release of R on
a new install of Fedora 35 Linux. Is there a list of dependencies that
have to be installed (or even better, a package) to avoid the
necessity of running ./configure many times and installing them
piecemeal? I've just been reading Installation and Administration in
the manual and haven't found anything like this. Any pointers
appreciated.

Jim

__
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] Mapping of groups of countries

2022-01-02 Thread Jim Lemon
Hi George,
Same to you. I fooled around with the plot a bit after I sent the email.

Jim

On Mon, Jan 3, 2022 at 8:36 AM george brida  wrote:
>
> Thanks a lot Jim. I really appreciate your help. Happy new year 2022.
> George
>
> On Wed, Dec 29, 2021 at 10:10 PM Jim Lemon  wrote:
>>
>> Hi George,
>> This example is obviously a mess, but it shows the basic elements. The
>> labels may be placed manually using something like boxed.labels
>> (plotrix) with lines connecting the labels to the smaller countries.
>> If you want the labels within the countries you will have to use a big
>> graphics device.
>>
>> library(maps)
>> map("world")
>> countries=c("China","Bangladesh","Egypt","Indonesia","South Korea","Nigeria",
>>  "Brazil","Pakistan","Philippines","Vietnam","South Africa",
>>  "India","Mexico","Turkey")
>> countrycol<-c(rep("red",6),rep("blue",4),"green",rep("orange",3))
>> for(i in 1:length(countries)) {
>>  mapinf<-map(region=countries[i],col=countrycol[i],add=TRUE)
>>  xpos<-sum(mapinf$range[1:2])/2
>>  ypos<-sum(mapinf$range[3:4])/2
>>  text(xpos,ypos,countries[i])
>> }
>>
>>
>> Jim
>>
>> On Thu, Dec 30, 2021 at 7:34 AM george brida  wrote:
>> >
>> > Dear R users,
>> >
>> > I would like to map with R the following countries (with their names on the
>> > map) as follows: the first group in red composed by China, Bangladesh,
>> > Eypt, Indonesia, South Korea, Nigeria. The second group in blue composed by
>> > Brazil, Pakistan, Philippines, Vietnam.
>> >
>> > The third group in green solely composed by South Africa.
>> >
>> > Finally, the fourth group in orange composed by India, Mexico and Turkey.
>> >
>> > I'd also like a legend that assigns the different colors to the various
>> > group.
>> > I tried several times with library maps but it seems that I failed to find
>> > the real setting of xlim and ylim. Can you please help me, I will be very
>> > grateful.
>> >
>> > Best regards
>> > George
>> >
>> > [[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] Mapping of groups of countries

2021-12-29 Thread Jim Lemon
Hi George,
This example is obviously a mess, but it shows the basic elements. The
labels may be placed manually using something like boxed.labels
(plotrix) with lines connecting the labels to the smaller countries.
If you want the labels within the countries you will have to use a big
graphics device.

library(maps)
map("world")
countries=c("China","Bangladesh","Egypt","Indonesia","South Korea","Nigeria",
 "Brazil","Pakistan","Philippines","Vietnam","South Africa",
 "India","Mexico","Turkey")
countrycol<-c(rep("red",6),rep("blue",4),"green",rep("orange",3))
for(i in 1:length(countries)) {
 mapinf<-map(region=countries[i],col=countrycol[i],add=TRUE)
 xpos<-sum(mapinf$range[1:2])/2
 ypos<-sum(mapinf$range[3:4])/2
 text(xpos,ypos,countries[i])
}


Jim

On Thu, Dec 30, 2021 at 7:34 AM george brida  wrote:
>
> Dear R users,
>
> I would like to map with R the following countries (with their names on the
> map) as follows: the first group in red composed by China, Bangladesh,
> Eypt, Indonesia, South Korea, Nigeria. The second group in blue composed by
> Brazil, Pakistan, Philippines, Vietnam.
>
> The third group in green solely composed by South Africa.
>
> Finally, the fourth group in orange composed by India, Mexico and Turkey.
>
> I'd also like a legend that assigns the different colors to the various
> group.
> I tried several times with library maps but it seems that I failed to find
> the real setting of xlim and ylim. Can you please help me, I will be very
> grateful.
>
> Best regards
> George
>
> [[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] Creating NA equivalent

2021-12-21 Thread Jim Lemon
Hi Bert,
What troubles me about this is that something like detectable level(s)
is determined at a particular time and may change. Censoring in
survival tells us that the case lasted "at least this long". While a
less than detectable value doesn't give any useful information apart
from perhaps "non-zero", an over limit value gives something like
censoring with "at least this much". However, it is more difficult to
conceptualize and I suspect, to quantify. To me, the important
information is that we think there _may be_ a value but we don't
(yet?) know it.

Jim

On Wed, Dec 22, 2021 at 9:56 AM Bert Gunter  wrote:
>
> But you appear to be missing something, Jim -- see inline below (and
> the original post):
>
> Bert
>
>
> On Tue, Dec 21, 2021 at 2:00 PM Jim Lemon  wrote:
> >
> > Please pardon a comment that may be off-target as well as off-topic.
> > This appears similar to a number of things like fuzzy logic, where an
> > instance can take incompatible truth values.
> >
> > It is known that an instance may have an attribute with a numeric
> > value, but that value cannot be determined.
> Yes, but **something** about the value is known: that it is > an upper
> value or < a lower value. Such information should be used
> (censoring!), not characterized as completely unknown. Think about it
> in terms of survival time: saying that a person lasted longer than k
> months is much more informative than saying that how long they lasted
> is completely unknown!
>
> >
> > It seems to me that an appropriate designation for the value is Unk,
> > perhaps with an associated probability of determination to distinguish
> > it from NA (it is definitely not known).
> >
> > Jim
> >
> > On Wed, Dec 22, 2021 at 6:55 AM Avi Gross via R-help
> >  wrote:
> > >
> > > I wonder if the package Adrian Dușa created might be helpful or point you 
> > > along the way.
> > >
> > > It was eventually named "declared"
> > >
> > > https://cran.r-project.org/web/packages/declared/index.html
> > >
> > > With a vignette here:
> > >
> > > https://cran.r-project.org/web/packages/declared/vignettes/declared.pdf
> > >
> > > I do not know if it would easily satisfy your needs but it may be a step 
> > > along the way. A package called Haven was part of the motivation and 
> > > Adrian wanted a way to import data from external sources that had more 
> > > than one category of NA that sounds a bit like what you want. His 
> > > functions should allow the creation of such data within R, as well. I am 
> > > including him in this email if you want to contact him or he has 
> > > something to say.
> > >
> > >
> > > -Original Message-
> > > From: R-help  On Behalf Of Duncan Murdoch
> > > Sent: Tuesday, December 21, 2021 5:26 AM
> > > To: Marc Girondot ; r-help@r-project.org
> > > Subject: Re: [R] Creating NA equivalent
> > >
> > > On 20/12/2021 11:41 p.m., Marc Girondot via R-help wrote:
> > > > Dear members,
> > > >
> > > > I work about dosage and some values are bellow the detection limit. I
> > > > would like create new "numbers" like LDL (to represent lower than
> > > > detection limit) and UDL (upper the detection limit) that behave like
> > > > NA, with the possibility to test them using for example is.LDL() or
> > > > is.UDL().
> > > >
> > > > Note that NA is not the same than LDL or UDL: NA represent missing data.
> > > > Here the data is available as LDL or UDL.
> > > >
> > > > NA is built in R language very deep... any option to create new
> > > > version of NA-equivalent ?
> > > >
> > >
> > > There was a discussion of this back in May.  Here's a link to one 
> > > approach that I suggested:
> > >
> > >https://stat.ethz.ch/pipermail/r-devel/2021-May/080776.html
> > >
> > > Read the followup messages, I made at least one suggested improvement.
> > > I don't know if anyone has packaged this, but there's a later version of 
> > > the code here:
> > >
> > >https://stackoverflow.com/a/69179441/2554330
> > >
> > > 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 
> > >

Re: [R] Creating NA equivalent

2021-12-21 Thread Jim Lemon
Please pardon a comment that may be off-target as well as off-topic.
This appears similar to a number of things like fuzzy logic, where an
instance can take incompatible truth values.

It is known that an instance may have an attribute with a numeric
value, but that value cannot be determined.

It seems to me that an appropriate designation for the value is Unk,
perhaps with an associated probability of determination to distinguish
it from NA (it is definitely not known).

Jim

On Wed, Dec 22, 2021 at 6:55 AM Avi Gross via R-help
 wrote:
>
> I wonder if the package Adrian Dușa created might be helpful or point you 
> along the way.
>
> It was eventually named "declared"
>
> https://cran.r-project.org/web/packages/declared/index.html
>
> With a vignette here:
>
> https://cran.r-project.org/web/packages/declared/vignettes/declared.pdf
>
> I do not know if it would easily satisfy your needs but it may be a step 
> along the way. A package called Haven was part of the motivation and Adrian 
> wanted a way to import data from external sources that had more than one 
> category of NA that sounds a bit like what you want. His functions should 
> allow the creation of such data within R, as well. I am including him in this 
> email if you want to contact him or he has something to say.
>
>
> -Original Message-
> From: R-help  On Behalf Of Duncan Murdoch
> Sent: Tuesday, December 21, 2021 5:26 AM
> To: Marc Girondot ; r-help@r-project.org
> Subject: Re: [R] Creating NA equivalent
>
> On 20/12/2021 11:41 p.m., Marc Girondot via R-help wrote:
> > Dear members,
> >
> > I work about dosage and some values are bellow the detection limit. I
> > would like create new "numbers" like LDL (to represent lower than
> > detection limit) and UDL (upper the detection limit) that behave like
> > NA, with the possibility to test them using for example is.LDL() or
> > is.UDL().
> >
> > Note that NA is not the same than LDL or UDL: NA represent missing data.
> > Here the data is available as LDL or UDL.
> >
> > NA is built in R language very deep... any option to create new
> > version of NA-equivalent ?
> >
>
> There was a discussion of this back in May.  Here's a link to one approach 
> that I suggested:
>
>https://stat.ethz.ch/pipermail/r-devel/2021-May/080776.html
>
> Read the followup messages, I made at least one suggested improvement.
> I don't know if anyone has packaged this, but there's a later version of the 
> code here:
>
>https://stackoverflow.com/a/69179441/2554330
>
> 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.
>
> __
> 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] help with LDA topic modelling..

2021-12-20 Thread Jim Lemon
Hi Akshay,
It depends upon how the circles are calculated. If each circle
encloses all of the members of each group, yes. I doubt you would get
perfect separation in any real example, though. At the moment:
Hanukkah is finished,
Margashirsha Punima has just happened and
Christmas is coming up.
No matter how devout the adherents, I don't think you would find news
articles that only mentioned one of these festivals. Less facetious
groupings would suffer the same eclectic problem.

Jim

On Mon, Dec 20, 2021 at 6:29 PM akshay kulkarni  wrote:
>
> dear members,
>  I am using LDA for topic modelling of news articles 
> (topicmodels package). I am visualizing the accuracy with the LDAvis package.
>
> The visualization shows clusters as circles, probably intersecting. My 
> question is, if a find the optimal number of topics, k, and if the circles 
> representing the topics doesn't intersect, then I have achieved perfect 
> segregation. AM I right?
>
> Thanking You,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> [[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] CandlestickCharts of any listed stock and fetching stock prices into R

2021-12-18 Thread Jim Lemon
Hi Winod,
Your first error message seems to be saying that you are passing a
function that returns an "ohic" object rather than the object. Maybe:

ohic<-get.ohlc.yahoo("GOOG",start="2020-12-18",end="2021-12-17")
candlestickChart(ohic,..)

would get you a bit further. Also it's obvious that the function wants
character dates with quotes around them. There seem to be quite a few
YouTube tutorials on candlestick charts.

Jim

On Sun, Dec 19, 2021 at 1:15 AM Winod Dhamnekar
 wrote:
>
> Hello,
> R users community,
>  I want to plot candlestickCharts of any stock prices of listed companies
> on any stock exchange (Indian or  worldwide) into r by using
> candlestickchart command in 'FinCal' r package. But I could not plot
> candlestic charts. R showed me errors.
>
>
>  candlestickChart(ohlc,2020-12-18,2021-12-17,"Google")
> Error in as.Date(ohlc$date) : object 'ohlc' not found
> > candlestickChart(get.ohlc.google,2020-12-18,2021-12-17,"Google")
> Error: object of type 'closure' is not subsettable
> > candlestickChart(get.ohlc.google,2020-12-18,2021-12-17,"Google")
> Error: object of type 'closure' is not subsettable
>
>
> What is the suitable syntax to use candlestickchart command from 'FinCal' r
> package?
>
> I also tried to fetch stock prices of listed companies on any stock
> exchange (wordwide or Indian) But I could not fetch stock prices.
>   # google <- get.ohlc.yahoo("GOOG",start="2014-07-01",end="2014-08-01");
> candlestickChart(google)
>  # google <- get.ohlc.yahoo("GOOG",start="2020-12-18",end="2021-12-17");
> candlestickChart(google)
> > candlestickChart(ohlc,2020-12-18,2021-12-17,"Google")
> Error in as.Date(ohlc$date) : object 'ohlc' not found
> > candlestickChart(get.ohlc.google,2020-12-18,2021-12-17,"Google")
> Error: object of type 'closure' is not subsettable
> > candlestickChart(get.ohlc.google,2020-12-18,2021-12-17,"Google")
> Error: object of type 'closure' is not subsettable
>
>  get.ohlc.yahoo("BOM:532504", 18-12-2021,17-12-2021,d)
> Error in strsplit(start, "-") : non-character argument
> > get.ohlc.yahoo('BOM:532504', 18-12-2021,17-12-2021,d)
> Error in strsplit(start, "-") : non-character argument
> > get.ohlc.yahoo(BOM:532504, 18-12-2021,17-12-2021,d)
> Error in strsplit(start, "-") : non-character argument
>  # google <- get.ohlc.yahoo("GOOG",start="2020-12-18",end="2021-12-17");
> candlestickChart(google)
> > candlestickChart(ohlc,2020-12-18,2021-12-17,"Google")
> Error in as.Date(ohlc$date) : object 'ohlc' not found
> > candlestickChart(get.ohlc.google,2020-12-18,2021-12-17,"Google")
> Error: object of type 'closure' is not subsettable
>  candlestickChart(ohlc,2020-12-18,2021-12-17,"Google")
> Error in as.Date(ohlc$date) : object 'ohlc' not found
>
>   How can I plot candlestickchart and fetch stock prices of any period with
> any frequency of time intervals?
>
> [[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] Changing time intervals in data set

2021-12-15 Thread Jim Lemon
Hi Rich,
>From what you sent, it seems like you want to find where the change in
_measurement interval_ occurred. That looks to me as though it is the
first datetime in each row. In the first row, there is a week gap
between the ten and fifteen minute intervals. This may indicate that
no measurements were taken or perhaps they were lost.

Jim

On Thu, Dec 16, 2021 at 8:13 AM Rich Shepard  wrote:
>
> On Wed, 15 Dec 2021, jim holtman wrote:
>
> > At least show a sample of the data and then what you would like as output.
>
> Jim,
>
> There are 813,694 rows of data. As I wrote,
> >> A 33-year set of river discharge data at one gauge location has recording
> >> intervals of 5, 10, and 30 minutes over the period of record.
>
> Also, 15 minute intervals
>
> >> The data.frame/tibble has columns for year, month, day, hour, minute, and
> >> datetime.
>
> As well as a site_nbr.
>
> What I asked is,
>
> >> Would difftime() allow me to find the dates when the changes occurred?
>
> I'm scrolling through the data file (not the R dataframe). The output I've
> so far generated manually:
>
> 1988-10-01 00:10 - 1991-03-12 23:50  10 min
> 1991-03-19 00:00 - 1994-07-05 23:45  15 min
> 2003-04-03 00:00 - 2004-01-31 10:30  30 min
> 2004-01-31 10:40 - 2004-01-31 15:30   5 min
> 2004-01-31 16:00 - 2008-06-27 11:00  30 min
> 2008-06-27 11:10 - 2008-07-07 15:30   5 min
> 2008-07-07 16:00 - 2009-05-26 13:00  30 min
> 2009-05-26 13:15 - 2009-05-27 06:30   5 min
> 2009-05-27 07:00 - 2009-06-11 08:00  30 min
> 2009-06-11 08:15 - 2009-06-12 08:50   5 min
> 2009-06-12 09:00 - 2010-09-07 08:00  30 min
> 2010-09-07 08:20 - 2010-09-07 18:00   5 min
> 2010-09-07 18:30 - 2010-09-09 07:30  30 min
> 2010-09-09 07:45 - 2010-09-13 11:15   5 min
> 2010-09-13 11:30 - 2010-12-01 07:30  30 min
> 2010-12-01 07:50 - 2010-12-02 15:50   5 min
> 2010-12-02 16:00 - 2010-12-17 10:00  30 min
> 2010-12-17 10:05 - 2010-12-20 08:35   5 min
> 2010-12-20 09:00 - 2011-05-20 09:00  30 min
> 2011-05-20 09:05 - 2011-05-23 06:40   5 min
> 2011-05-23 07:00 - 2011-08-18 17:30  30 min
> 2011-08-18 17:45 - 2011-12-14 06:15  15 min
> 2011-12-14 06:20 - 2011-12-14 17:35   5 min
> 2011-12-14 17:45 - 2012-06-28 06:15  15 min
> 2012-06-28 06:25 - 2012-06-28 14:30   5 min
> 2012-06-28 14:45 - 2012-10-12 06:15  15 min
> 2012-10-12 06:25 - 2012-10-12 15:45   5 min
> 2012-10-12 16:00 - 2014-01-17 07:00  15 min
> 2014-01-17 07:05 - 2014-01-21 07:05   5 min
> 2014-01-21 07:15 - 2015-04-03 07:30  15 min
>
> Rich
>
> __
> 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] help

2021-12-01 Thread Jim Lemon
Hi mehdi,
Try this (first example in the help page):

ref<-rnorm(30,sd=2)
 # add a little noise
 model1<-ref+rnorm(30)/2
 # add more noise
 model2<-ref+rnorm(30)
 # display the diagram with the better model
 oldpar<-taylor.diagram(ref,model1)
 # now add the worse model
 taylor.diagram(ref,model2,add=TRUE,col="blue")
 # get approximate legend position
 lpos<-1.5*sd(ref)
 # add a legend
 legend(lpos,lpos,legend=c("Better","Worse"),pch=19,col=c("red","blue"))
 # now restore par values
 par(oldpar)

What you have done is to leave out the "reference" model (ref), so
that the second argument is missing.

Jim

On Wed, Dec 1, 2021 at 7:29 PM mehdi ghasemi  wrote:
>
> Hi Dr
>
> If we want to draw two plots only in a Taylor diagram ,What  the  attached  
> code should be modified ?
> 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] converting to POSIXct

2021-11-30 Thread Jim Lemon
Hi,
Petr is right. Apparently as.POSIXct drops the smallest increments if
all are zero:

ssdf<-read.csv(text="data_POSIX,Sensor_code,value
2002-11-01 00:00:01,1694,7.2
2002-11-01 00:00:00,1723,10.8",
stringsAsFactors=FALSE)
ssdf$data_POSIX<-as.POSIXct(ssdf$data_POSIX,"%Y-%m-%d HH:MM:SS")
ssdf

   data_POSIX Sensor_code value
1 2002-11-01 00:00:011694   7.2
2 2002-11-01 00:00:001723  10.8

but if there is a single small increment, they all show up.

Jim

On Tue, Nov 30, 2021 at 7:33 PM PIKAL Petr  wrote:
>
> Hi
>
> You probably has zero hours in all your data
>
> see
> > temp
>data_POSIX Sensor_code value
> 1 2002-11-01 00:00:001694   7.2
> 2 2002-11-01 00:00:001723  10.8
>
> without hours
> > as.POSIXct(temp$data_POSIX, format = "%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1")
> [1] "2002-11-01 +01" "2002-11-01 +01"
>
> add value to hours
> > fix(temp)
> > temp
>data_POSIX Sensor_code value
> 1 2002-11-01 00:01:001694   7.2
> 2 2002-11-01 00:00:001723  10.8
>
> Voila, hours are back.
> > as.POSIXct(temp$data_POSIX, format = "%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1")
> [1] "2002-11-01 00:01:00 +01" "2002-11-01 00:00:00 +01"
>
> So nothing wrong in uyour code, hours are there but they are probably not 
> printed to console and hours are there but hidden.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help  On Behalf Of Stefano Sofia
> > Sent: Tuesday, November 30, 2021 9:20 AM
> > To: r-help mailing list 
> > Subject: [R] converting to POSIXct
> >
> > Dear R-list users,
> > I thought I was able to manage easily POSIXct, but this is not true.
> > I am not going to load the input txt file because I know that attachments 
> > are
> > not allowed. The structure of my input txt file is
> >
> > data_POSIX,Sensor_code,value
> > 2002-11-01 00:00:00,1694,7.2
> > 2002-11-01 00:00:00,1723,10.8
> > ...
> >
> > I load it with
> > myfile <- read.table(file="mypath/myfile.txt", header = TRUE, sep=",", dec =
> > ".", stringsAsFactors = FALSE)
> >
> > When I try to convert the data_POSIX column (which is a character) to
> > POSIXct with
> >
> > myfile$data_POSIX <- as.POSIXct(myfile$data_POSIX, format = "%Y-%m-%d
> > %H:%M:%S", tz="Etc/GMT-1")
> >
> > the outupt is
> >
> > 2002-11-01 1694 7.2
> > 2002-11-01 1723 10.8
> > ...
> >
> > Why I keep loosing hours, minutes and seconds? Wher eis my mistake or my
> > misunderstanding?
> >
> > Sorry again if I have not been able to reproduce the R code, and thank you
> > for your support.
> > Stefano
> >
> >  (oo)
> > --oOO--( )--OOo--
> > Stefano Sofia PhD
> > Civil Protection - Marche Region - Italy Meteo Section Snow Section Via del
> > Colle Ameno 5
> > 60126 Torrette di Ancona, Ancona (AN)
> > Uff: +39 071 806 7743
> > E-mail: stefano.so...@regione.marche.it
> > ---Oo-oO
> >
> > 
> >
> > AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
> > informazioni confidenziali, pertanto è destinato solo a persone autorizzate
> > alla ricezione. I messaggi di posta elettronica per i client di Regione 
> > Marche
> > possono contenere informazioni confidenziali e con privilegi legali. Se non 
> > si è
> > il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
> > questo
> > messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al
> > mittente ed eliminarlo completamente dal sistema del proprio computer. Ai
> > sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di 
> > necessità ed
> > urgenza, la risposta al presente messaggio di posta elettronica può essere
> > visionata da persone estranee al destinatario.
> > IMPORTANT NOTICE: This e-mail message is intended to be received only by
> > persons entitled to receive the confidential information it may contain. 
> > E-mail
> > messages to clients of Regione Marche may contain information that is
> > confidential and legally privileged. Please do not read, copy, forward, or 
> > store
> > this message unless you are an intended recipient of it. If you have 
> > received
> > this message in error, please forward it to the sender and delete it
> > completely from your computer system.
> >
> > --
> > Questo messaggio  stato analizzato da Libraesva ESG ed  risultato non 
> > infetto.
> > This message was scanned by Libraesva ESG and is believed to be clean.
> >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > 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
> 

Re: [R] Package is not available for this version of R.

2021-11-26 Thread Jim Lemon
Hi Amanze,
The package is apparently "apsurvival", hosted on GitHub:

https://rdrr.io/github/carolinewei/apsurvival/

There seem to be instructions on how to install this, but the
maintainer (Caroline Wei?) doesn't seem to have an email address
listed. Perhaps the easiest thing for you to do is ask your teacher
how to install this package and remember to load it:

library(apsurvival)

after installing when you need the function.

Jim

On Sat, Nov 27, 2021 at 4:02 AM Amanze Ozioma  wrote:
>
> Hi, Good afternoon.
>  Please I am trying to do my project from school. I keep getting the error
> message that the package is not available. Please advise. below is the
> error message. May I know what package the 'prob.def1' is under?
> __
> 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] Merge column with characters

2021-11-18 Thread Jim Lemon
Hi RosalinaZakaria,
Talk about using a sledgehammer to crack a nut. In your example the
two objects are character vectors. How about:

dt_comb1gd <-paste0(dtpaigd,dtpmgd)

Jim

On Fri, Nov 19, 2021 at 2:15 AM ROSLINAZAIRIMAH BINTI ZAKARIA .
 wrote:
>
> Dear all,
>
> I try to merge two columns consisting of characters using the 'coalesce'
> function from dplyr package. However, two data still have not merged, data
> no. 124 1nd 143. Any help is very much appreciated. I provide the data as
> follows.
>
> > dput(dtpaigd)
> c("C+", "B+", "C+", "B+", "C+", "A-", "A ", "B+", "A-", "C ",
> "B+", "A-", "B+", "B ", "B ", "B ", "D ", "B+", "B ", "B ", "C+",
> "B ", "A ", "A-", "B+", "A-", "A ", "B ", "A ", "C ", "B ", "A+",
> "C ", "B ", "B+", "C+", "B ", "B ", "C+", "B ", "B+", "B ", "A-",
> "B+", "B ", "A-", "C+", "A ", "A-", "C+", "C+", "B ", "B+", "A-",
> "A-", "B ", "E ", "A-", "B+", "B ", "A ", "B+", "A-", "A-", "A ",
> "B+", "A-", "A-", "A-", "B+", "C ", "A-", "A ", "A-", "A ", "A-",
> "A-", "A ", "A ", "B+", "B ", "A+", "B ", "B ", "B+", "A-", "B+",
> "B+", "A-", "A-", "B+", "A-", "A-", "A-", "A-", "A-", "A ", "B+",
> "B ", "A-", "A-", "A-", "A ", "A-", "A-", "B+", "A-", "A ", "B+",
> "B+", "A-", "B+", "A-", "A ", "B+", "A ", "D ", "A+", "B ", "B+",
> "A+", "B+", "B ", "", "A ", "A-", "B ", "A ", "B+", "E ", "B ",
> "B ", "A ", "A-", "B ", "A ", "C+", "B ", "A ", "B+", "B+", "A ",
> "", "B ")
> > dput(dtpmgd)
> c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "A-", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "A ", "")
>
> dt_comb1gd <- coalesce(dtpaigd, dtpmgd)
> > dput(dt_comb1gd)
> c("C+", "B+", "C+", "B+", "C+", "A-", "A ", "B+", "A-", "C ",
> "B+", "A-", "B+", "B ", "B ", "B ", "D ", "B+", "B ", "B ", "C+",
> "B ", "A ", "A-", "B+", "A-", "A ", "B ", "A ", "C ", "B ", "A+",
> "C ", "B ", "B+", "C+", "B ", "B ", "C+", "B ", "B+", "B ", "A-",
> "B+", "B ", "A-", "C+", "A ", "A-", "C+", "C+", "B ", "B+", "A-",
> "A-", "B ", "E ", "A-", "B+", "B ", "A ", "B+", "A-", "A-", "A ",
> "B+", "A-", "A-", "A-", "B+", "C ", "A-", "A ", "A-", "A ", "A-",
> "A-", "A ", "A ", "B+", "B ", "A+", "B ", "B ", "B+", "A-", "B+",
> "B+", "A-", "A-", "B+", "A-", "A-", "A-", "A-", "A-", "A ", "B+",
> "B ", "A-", "A-", "A-", "A ", "A-", "A-", "B+", "A-", "A ", "B+",
> "B+", "A-", "B+", "A-", "A ", "B+", "A ", "D ", "A+", "B ", "B+",
> "A+", "B+", "B ", "", "A ", "A-", "B ", "A ", "B+", "E ", "B ",
> "B ", "A ", "A-", "B ", "A ", "C+", "B ", "A ", "B+", "B+", "A ",
> "", "B ")
>
> *Thank you and best regards.*
>
> *RoslinaZakaria*
>
> --
> _*
> *_
> _**_*
> *__
> _*"Think Green. Keep it on the screen.
> If printing is
> necessary, please print it on both sides."
> *_
>
> *The information contained
> in this e-mail message and any accompanying files is or may be
> confidential. If you are not the intended recipient, any use,
> dissemination, reliance, forwarding, printing or copying of this e-mail or
> any attached files is unauthorized. This e-mail is subject to copyright. No
> part of it should be reproduced, adapted or communicated without the
> written consent of the copyright owner. If you have received this e-mail in
> error please advise the sender immediately by return e-mail or telephone
> and delete all copies. UMP does not guarantee the accuracy or completeness
> of any information contained in this e-mail or attached files. Internet
> communications are not secure, therefore UMP does not accept legal
> responsibility for the contents of this message or attached files.*
> *Universiti Malaysia Pahang *
>
> [[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] How to run prop.test on 3-level factors?

2021-11-16 Thread Jim Lemon
Hi Luigi,
Maybe multinomial regression?

https://www.r-bloggers.com/2020/05/multinomial-logistic-regression-with-r/

Jim

On Tue, Nov 16, 2021 at 7:33 PM Luigi Marongiu  wrote:
>
> Hello,
> I have a large database with a column containing a factor:
> ```
> > str(df)
> 'data.frame': 500 obs. of  4 variables:
> $ MR   : num  0.000809 0.001236 0.001663 0.002089 0.002516 ...
> $ FCN  : num  2 2 2 2 2 2 2 2 2 2 ...
> $ Class: Factor w/ 3 levels "negative","positive",..: 1 1 1 1 1 1 1 1 1 1 ...
> $ Set  : int  1 1 1 1 1 1 1 1 1 1 ...
> - attr(*, "out.attrs")=List of 2
> ..$ dim : Named int [1:2] 1000 1000
> .. ..- attr(*, "names")= chr [1:2] "X1" "X2"
> ..$ dimnames:List of 2
> .. ..$ X1: chr [1:1000] "X1=0.0008094667" "X1=0.0012360955"
> "X1=0.0016627243" "X1=0.0020893531" ...
> .. ..$ X2: chr [1:1000] "X2= 2.00" "X2= 2.048048" "X2= 2.096096"
> "X2= 2.144144" ...
> ```
> I would like to run prop.test on df$Class, but:
> ```
> > prop.test(x=point$Class, n=length(point$Class),
> + conf.level=.95, correct=FALSE)
> Error in prop.test(x = point$Class, n = length(point$Class),
> conf.level = 0.95,  :
> 'x' and 'n' must have the same length
> ```
> Since `x` is "a vector of counts of successes, a one-dimensional table
> with two entries, or a two-dimensional table (or matrix) with 2
> columns, giving the counts of successes and failures, respectively." I
> provided point$Class. The total number of tests is
> length(point$Class).
> There are three levels:
> ```
> > unique(df$Class)
> [1] negative  positive  uncertain
> Levels: negative positive uncertain
> ```
> I tried to remove the levels to check if the levels were interfering
> with the test:
> ```
> > df$Class = levels(droplevels(df$Class))
> Error in `$<-.data.frame`(`*tmp*`, Class, value = c("negative", "positive",  :
> replacement has 3 rows, data has 500
> ```
> What would be the syntax for this test? The idea is to get the most
> common value for each unique(df$Set) and prop.test will provide also
> the 95% CI for the estimate.
> 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] Confidence Interval for p1-p2 and plot the CI with bar chart

2021-11-13 Thread Jim Lemon
Hi Abou,
Perhaps this will be helpful. Be aware that you will cop some flak for
putting error bars on a bar plot.

aadat<-data.frame(group=c(rep("Exp",50),rep("Con",50)),
 v1=sample(0:1,100,TRUE),
 v2=sample(0:1,100,TRUE),
 v3=sample(0:1,100,TRUE),
 v4=sample(0:1,100,TRUE),
 v5=sample(0:1,100,TRUE))
ggps<-function(x,group) {
 gns<-as.vector(table(group))
 return(by(x,group,sum)/gns)
}
testggps<-data.frame(
 group=c("A","A","A","B","B","B","B","C","C","C","C","C"),
 x=c(1,0,1,1,0,1,0,1,1,0,0,0))
aaprop<-sapply(aadat[,2:6],ggps,aadat[,1])
library(plotrix)
barpos<-barp(aaprop,ylim=c(0,0.65),col=c(2,3),names.arg=colnames(aaprop))
legend(2.5,0.65,c("Con","Exp"),fill=c(2,3))
dispersion(barpos$x,barpos$y,ulim=aaprop/10)

Jim

On Sun, Nov 14, 2021 at 11:01 AM AbouEl-Makarim Aboueissa
 wrote:
>
> Dear All:
>
>
>
> I do have a binary data set with multiple variables, event = 1 in all
> variables. As an example, I attached a data set with 6 variables. The first
> column is the grouping variable. Then the next 5 columns are the binary
> data for 5 variables.
>
>
>
> - Can we compute the confidence interval for the difference between the two
> proportions of the event = 1 in both groups (say: G1 – G2) for the 5
> variables in one shut.
>
>
>
> - I also need to create the Bar plot of individual proportions (both groups
> side-by-side) and add the confidence intervals bar for the 5 variables in
> one graph.
>
>
>
>
>
> Example.Data <- read.table(file="F/Example_Data_for_R.csv", header=T,
> sep=",")
>
> Example.Data
>
> attach(Example.Data)
>
>
>
>
>
>
>
>  For example, this is how I use the prop.test() function to get the CI
> for p1-p2
>
>
>
> x12 <- c(x1, x2)
>
> n12 <- c(n1, n2)
>
> prop.test(x12, n12, conf.level = 0.95)$conf.int
>
>
>
> But, I am not sure how to use it for raw data, and for multiple pairs of
> data in one shut if possible.
>
>
>
> With many thanks in advance
>
> Abou
> __
>
>
> *AbouEl-Makarim Aboueissa, PhD*
>
> *Professor, Statistics and Data Science*
> *Graduate Coordinator*
>
> *Department of Mathematics and Statistics*
> *University of Southern Maine*
> __
> 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] heatmap ploting

2021-11-05 Thread Jim Lemon
Hi Steve,
That plot looks to me as though a value-to-color transformation is
performed on the logarithm of gene expression. The scale bar can be
roughly reproduced like this:

library(plotrix)
plot(0,xlim=c(0,3))
gradient.rect(0,-0.1,3,0.1,
 col=color.scale(seq(0,3,0.1),
 c(0.7,1,1,1,0.7,0.2),
 c(0.7,1,0,0,0,0),
 c(1,0,0,0.1,0.7,0.2)))
text(0:3,rep(0.2,3),c(0,10,100,1000))

The horizontal lengths of the stacked bars of the plot can then be
adjusted to the number of subjects in a given bin of log gene
expressions. A tricky plot, but it can be done in R.

Jim

On Fri, Nov 5, 2021 at 6:08 PM Stephen HonKit Wong  wrote:
>
> Dear Community,
>
> I have an example heatmap plot in this link
> 
> which was generated by java I believe, I want to make a similar plot in R.
> Any clues on how to do it? Thanks.
>
> The column is a gene, and the rows are different cancer types with
> different numbers of patients. The heatmap value represents the expression
> value, such as FPKM, which can range from 0 to over several hundreds.
>
>
> Much thanks!
>
> Steve
>
> [[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] Date

2021-11-04 Thread Jim Lemon
Hi Val,
Try this:

dat=read.csv("myfile.csv",stringsAsFactors=FALSE)

However, the apparently silent conversion of format is a mystery to
me. The only time I have struck something like this was when exporting
dates from Excel some years ago, and there was a silent conversion to
mm/dd/ format if the dates were in dd/mm/ format. Could you
post some sample data?

Jim


On Fri, Nov 5, 2021 at 8:44 AM Val  wrote:
>
> IHi All, l,
>
> I am  reading a csv file  and one of the columns is named as  "mydate"
>  with this form, 2019-09-16.
>
> I am reading this file as
>
> dat=read.csv("myfile.csv")
>  the structure of the data looks like as follow
>
> str(dat)
> mydate : chr  "09/16/2019" "02/21/2021" "02/22/2021" "10/11/2017" ...
>
> Please note the format  has  changed from -mm-dd  to mm/dd/
> When I tried to change this   as a Date using
>
> as.Date(as.Date(mydate, format="%m/%d/%Y" )
> I am getting this error message
> Error in charToDate(x) :
>   characte string is not in a standard unambiguous format
>
> My question is,
> 1. how can I read the file as it is (i.e., without changing the date format) ?
> 2. why does R change the date format?
>
> Thank you,
>
> __
> 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] Fwd: Merging multiple csv files to new file

2021-11-03 Thread Jim Lemon
Hi Gabrielle,
I get the feeling that you are trying to merge data in which each file
contains different variables, but the same subjects have contributed
the data. This a very wild guess, but it may provide some insight.

# assume that subjects are identified by a variable named "subjectID"
# create a vector of all your filenames
my_filenames<-c("dailyActivity_merged.csv",
"dailyCalories_merged.csv", "dailyIntensities_merged.csv",
...)
# step through the filenames, reading each one and merging it into the
final data frame
for(filename in my_filenames) {
 if(!exists(my_df)) my_df<-read.csv(filename)
 else {
  next_df<-read.csv(filename)
  my_df<-merge(my_df,next_df,by="subjectID",fill=TRUE)
 }
}

I doubt that this will work first time, but it will be a lot easier to
debug than throwing it all into a black box and seeing what comes out.

Jim

On Thu, Nov 4, 2021 at 2:36 AM gabrielle aban steinberg
 wrote:
>
> Hello, I would like to merge 18 csv files into a master data csv file, but
> each file has a different number of columns (mostly found in one or more of
> the other cvs files) and different number of rows.
>
> I have tried something like the following in R Studio (cloud):
>
> all_data_fit_files <- rbind("dailyActivity_merged.csv",
> "dailyCalories_merged.csv", "dailyIntensities_merged.csv",
> "dailySteps_merged.csv", "heartrate_seconds_merged.csv",
> "hourlyCalories_merged.csv", "hourlyIntensities_merged.csv",
> "hourlySteps_merged.csv", "minuteCaloriesNarrow_merged.csv",
> "minuteCaloriesWide_merged.csv", "minuteIntensitiesNarrow_merged.csv",
> "minuteIntensitiesWide_merged.csv", "minuteMETsNarrow_merged.csv",
> "minuteSleep_merged.csv", "minuteStepsNarrow_merged.csv",
> “minuteStepsWide_merged.csv", "sleepDay_merged.csv",
> "minuteStepsWide_merged.csv", "sleepDay_merged.csv",
> "weightLogInfo_merged.csv")
>
>
>
> But I am getting the following error:
>
> Error: unexpected input in "rlySteps_merged.csv",
> "minuteCaloriesNarrow_merged.csv", "minuteCaloriesWide_merged.csv",
> "minuteIntensitiesNarrow_merged.csv",
> "minuteIntensitiesWide_merged.csv", "minuteMETsNarrow_merged.csv"
>
>
> (Maybe the R Studio free trial/usage is underpowered for my project?)
>
> [[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] by group

2021-11-01 Thread Jim Lemon
Hi Val,
I think you answered your own question:

by(dat$wt,dat[,c("Sex","Year")],mean)

Jim

On Tue, Nov 2, 2021 at 8:09 AM Val  wrote:
>
> Hi All,
>
> How can I generate mean by group. The sample data looks like as follow,
> dat<-read.table(text="Year Sex wt
> 2001 M 15
> 2001 M 14
> 2001 M 16
> 2001 F 12
> 2001 F 11
> 2001 F 13
> 2002 M 14
> 2002 M 18
> 2002 M 17
> 2002 F 11
> 2002 F 15
> 2002 F 14
> 2003 M 18
> 2003 M 13
> 2003 M 14
> 2003 F 15
> 2003 F 10
> 2003 F 11  ",header=TRUE)
>
> The desired  output  is,
>  MF
> 20011512
> 200216.33   13.33
> 200315  12
>
> Thank you,
>
> __
> 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] Help needed with data visualization in R

2021-11-01 Thread Jim Lemon
Hi bharat,
There are a number of ways to do this in R. One is:

library(plotrix)
example(size_n_color)

Jim

On Tue, Nov 2, 2021 at 6:43 AM bharat rawlley via R-help
 wrote:
>
>  Thank you very much, for your time and response!
> This did resolve my issue and I apologize if the question was a little too 
> straightforward - I did try to create bubble plots in excel but that did not 
> work, hence, I asked here since it is more of a diagram and less of a plot. 
> Thank you very much for your time and help!
> On Monday, 1 November, 2021, 09:47:29 pm IST, Bert Gunter 
>  wrote:
>
>  ... a simple web search on "bubble plots R" (what else?) would have brought 
> up many relevant hits. One should always try such obvious "homework" before 
> posting here. Better and quicker info often results.
>
> 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, Nov 1, 2021 at 8:15 AM Eric Berger  wrote:
>
> I have no experience with this but I did a search and found the following
> which looks close to what you are looking for
>
> https://stackoverflow.com/questions/69755844/is-it-possible-to-draw-the-following-diagram-in-r
>
>
>
> On Mon, Nov 1, 2021 at 5:06 PM bharat rawlley via R-help <
> r-help@r-project.org> wrote:
>
> > Hello,
> >
> > I wanted to ask if it is possible to have a data visualization of the
> > following kind in R?
> > It is not exactly a graph; a series of bubbles that have an area
> > corresponding to the percentage inside it arranged in a row.
> > Thank you!
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
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] How to slice the array?

2021-11-01 Thread Jim Lemon
Hi Alice,
I can see from your two questions that your English is a bit shaky.
This is not a criticism, I couldn't speak Chinese to save my life. I
looked around for a Chinese R help mailing list and couldn't find one.
Perhaps someone else knows of one. Not only would it make your life
easier at the moment, but it may help you learning R jargon in
English.

Jim

On Tue, Nov 2, 2021 at 6:49 AM Alice  wrote:
>
> How to slice the array with the condition?
> For example, in perl I can get the elements greater than 2.
>
> $ perl -le '@x=(1,2,3,4,5);@y=grep {$_>2} @x;print "@y"'
>
> 3 4 5
>
>
> in R I know which(x>2), but it will return the indexes instead of an array.
>
>
> Thanks again.
>
>
> Alice
>
> [[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] all letters like the R Logo

2021-10-30 Thread Jim Lemon
Hi Cleber,
Looks like Deja Vu Sans Bold to me. If you have the GIMP, check it out.

Jim

On Sun, Oct 31, 2021 at 1:35 PM Cleber Borges via R-help
 wrote:
>
> I once saw an internet article someone who made all the letters of the
> alphabet with the R logo style (font type, blue color and bow).
> I tried several Google searches with different combinations of strings
> but I couldn't find it.
>
> Would anyone know to give news of this article?
> Thanks in advance for tips.
> Cleber Borges
>
>
> --
> Este email foi escaneado pelo Avast antivírus.
> https://www.avast.com/antivirus
>
> __
> 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] Need help to print matrix with element and position

2021-10-28 Thread Jim Lemon
mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
3,byrow = TRUE)
mat_1
# Loop over my_matrix
for(row in 1:nrow(mat_1)) {
for(col in 1:ncol(mat_1)) {
cat(row,col,mat_1[row,col],"\n")
}
}

On Thu, Oct 28, 2021 at 8:01 PM Anas Jamshed  wrote:
>
> where should I place  cat(row,col,mat_1[row,col],"\n")?
>
> On Thu, Oct 28, 2021 at 1:58 PM Jim Lemon  wrote:
>>
>> Hi Anas,
>> How about:
>>
>> cat(row,col,mat_1[row,col],"\n")
>>
>> Jim
>>
>> On Thu, Oct 28, 2021 at 7:19 PM Anas Jamshed  
>> wrote:
>> >
>> > I create a matrix of size 3x3 called mat_1 and then I want to iterate over
>> > all the values one by one and print the element as well as the position in
>> > the matrix:
>> >
>> > My code is :
>> >
>> > mat_1= matrix( c('1','2','3','4','5','6','7','8','9'), nrow = 3, ncol =
>> > 3,byrow = TRUE)
>> > mat_1
>> > # Loop over my_matrix
>> > for(row in 1:nrow(mat_1)) {
>> > for(col in 1:ncol(mat_1)) {
>> > print(mat_1[row, col])
>> > }
>> > }
>> >
>> > But I don't know how to print elements and positions as well of this 
>> > matrix?
>> >
>> > [[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.


  1   2   3   4   5   6   7   8   9   10   >