Re: [R] Translation of the charter

2021-11-01 Thread Heinz Tuechler
Alice wrote/hat geschrieben on/am 31.10.2021 07:33: Dear members, How to translate the charter to the underline inter? I tried this: x <- c("a","b","c") as.numeric(x) [1] NA NA NA Warning message: NAs introduced by coercion It didn't work. Sorry for my newbie questions. B.R. Alice

Re: [R] Error with RMySQL

2021-11-01 Thread Ashim Kapoor
Dear Jim and others, (One of my colleagues pointed me in this direction) I think the following is the problem that I am experiencing:- https://dev.mysql.com/doc/mysql-security-excerpt/5.7/en/problems-connecting.html The above says : Some permanent solutions are: Determine what is wrong with y

Re: [R] by group

2021-11-01 Thread Val
Thank you all for your help! On Mon, Nov 1, 2021 at 8:47 PM Bert Gunter wrote: > > ... maybe not. According to Rdocumentation.org: > > reshape2's status is: > > reshape2 is retired: only changes necessary to keep it on CRAN will be > made. We recommend using tidyr in

Re: [R] by group

2021-11-01 Thread Bert Gunter
... maybe not. According to Rdocumentation.org: reshape2's status is: reshape2 is retired: only changes necessary to keep it on CRAN will be made. We recommend using tidyr instead. Bert Gunter "The trouble with having an open mind is that people keep coming along

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread jim holtman
drop the select, or put tz in the select Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Mon, Nov 1, 2021 at 3:39 PM Rich Shepard wrote: > On Mon, 1 Nov 2021, CALUM POLWART wrote: > > > Mutat

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
That works, Bert. I do note the result, d, is a matrix and works because everything within it is numeric. I have no problem with that for this problem. For a more general problem with a data.frame type of object with columns of any type, the proper output might better be a data.frame. Of cour

Re: [R] by group

2021-11-01 Thread Rasmus Liland
Dear Val, also consider using reshape2::dcast dat <- structure(list(Year = c(2001L, 2001L, 2001L, 2001L, 2001L, 2001L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L), Sex = c("M", "M", "M", "F", "F", "F", "M", "M

Re: [R] by group

2021-11-01 Thread Bert Gunter
"A decent example was given and I see Andrew provided a base R reply that should be sufficient. But I do not think he realized you wanted something different so his answer is not in the format you wanted:" Yes, but it is trivial to modify Andrew's suggestion to get almost exactly what Val has requ

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
I sent Val a longer reply but for anyone else here, please note Val was copying my OUTPUT with continuation lines starting with plus so of course that has issues! The naked code to use was this: dat %>% group_by(Year, Sex) %>% summarize( M = mean(wt, na.rm=TRUE)) %>% pivot_wider(names_fr

Re: [R] by group

2021-11-01 Thread Val
Thank you Avi, One question, I am getting this error from this script > dat %>% + + group_by(Year, Sex) %>% + + summarize( M = mean(wt, na.rm=TRUE)) %>% + + pivot_wider(names_from = Sex, values_from = M) %>% + + as.data.frame %>% + + round(1) Error in group_by(Year, Sex) : ob

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
Understood Val. So you need to save the output in something like a data.frame which can then be saved as a CSV file or whatever else makes sense to be read in by a later program. As note by() does not produce the output in a usable way. But you mentioned efficient, and that is another whole ball

Re: [R] by group

2021-11-01 Thread Val
Thank you all! I can assure you that this is not HW. This is a sample of my large data set and I want a simple and efficient approach to get the desired output in that particular format. That file will be saved and used as an input file for another external process. val On Mon, Nov 1

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
Jim, Your code gives the output in quite a different format and as an object of class "by" that is not easily convertible to a data.frame. So, yes, it is an answer that produces the right numbers but not in the places or data structures I think they (or if it is HW ...) wanted. Trivial standard c

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
This is a fairly simple request and well covered by introductory reading material. A decent example was given and I see Andrew provided a base R reply that should be sufficient. But I do not think he realized you wanted something different so his answer is not in the format you wanted: > tapply(d

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, CALUM POLWART wrote: Mutate. Probably.  Calum, I thought that I had it working, but I'm still missing a piece. For example, cor_disc %>% + select(year, mon, day, hr, min) %>% + mutate( + sampdt = make_datetime(year, mon, day, hr, min) + ) # A tibble: 415,263 × 6 yea

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 > 2

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 littl

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

Re: [R] by group

2021-11-01 Thread Andrew Simmons
I would usually use 'tapply'. It splits an object into groups, performs some function on each group, and then (optionally) converts the input to something simpler. For example: tapply(dat$wt, dat$Year, mean) # mean by Year tapply(dat$wt, dat$Sex , mean) # mean by Sex tapply(dat$wt, list(dat$Yea

[R] by group

2021-11-01 Thread Val
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 ",h

Re: [R] Code problem with R/Microeconomics

2021-11-01 Thread Eric Berger
Hi Olga, There are many people reading this list who are happy to try to help. Please provide some additional information about what you are trying to do and where you are stuck. Good luck, Eric On Mon, Nov 1, 2021 at 9:49 PM Olga Pervushina wrote: > > > Dear Sir/Madam, > > I am working on a sta

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, CALUM POLWART wrote: Also - what is the RAW CSV like? "12345678",2019,"10" Calum, No parentheses. Example: 14171600,2009,10,23,05,15,PDT,8710 14171600,2009,10,23,05,30,PDT,8710 Which causes another question. If I work within the tidyverse should I mutate the year, month,

Re: [R] How to slice the array?

2021-11-01 Thread Eric Berger
x[ x > 2] On Mon, Nov 1, 2021 at 9:49 PM 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 in

Re: [R] Translation of the charter

2021-11-01 Thread Eric Berger
> R.oo::charToInt(x) # [1] 97 98 99 On Mon, Nov 1, 2021 at 9:48 PM Alice wrote: > > Dear members, > > How to translate the charter to the underline inter? > I tried this: > > > x <- c("a","b","c") > > > as.numeric(x) > > [1] NA NA NA > > Warning message: > > NAs introduced by coercion > > > It

Re: [R] Error in dis[sppInSample,sppInSample]:subscript out of bounds

2021-11-01 Thread Bert Gunter
This question is about an (unspecified! -- tell us which one so we don't have to guess) contributed package. The Posting Guide linked below says: "For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R

Re: [R] How to slice the array?

2021-11-01 Thread Bert Gunter
Have you spent time with any R tutorials? Your queries are really elementary, and this list really cannot serve as a tutorial service. See the Posting Guide linked below for what help you can expect here ... and how to post queries that will get that help. Cheers, Bert Gunter "The trouble with ha

[R] Code problem with R/Microeconomics

2021-11-01 Thread Olga Pervushina
Dear Sir/Madam, I am working on a statistical evaluation with R at the Erasmus University and have a problem with one coding sentense. Who can help me with that? Thank you. Kind regards, Olga Pervushina [[alternative HTML version deleted]] _

Re: [R] Error in dis[sppInSample,sppInSample]:subscript out of bounds

2021-11-01 Thread Zhao Shanshan
Hi, I have the same problem, can you tell me how to solve it? Hello, I am new to R and am encountering an error message that I cannot find a solution for. I am attempting to calculate MPD (mean pairwise distance), without weighting for abundance, with a community species list and a phyloge

[R] How to slice the array?

2021-11-01 Thread Alice
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 v

[R] Translation of the charter

2021-11-01 Thread Alice
Dear members, How to translate the charter to the underline inter? I tried this: > x <- c("a","b","c") > as.numeric(x) [1] NA NA NA Warning message: NAs introduced by coercion It didn't work. Sorry for my newbie questions. B.R. Alice [[alternative HTML version deleted]] __

Re: [R] Help needed with data visualization in R

2021-11-01 Thread bharat rawlley via R-help
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 mu

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, CALUM POLWART wrote: You specified 7 column types for 8 columns... Thanks, Calum. I didn't see that I mis-counted when adding types. But, that doesn't change the tibble types for year and disc from doubles to character and int, respectively. Regards, Rich __

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Kevin Thorpe wrote: Is there a leading space on those variables for that row? Kevin, No: site_nbr,year,mon,day,hr,min,tz,disc 14171600,2009,10,23,00,00,PDT,8750 ... Thanks, Rich __ R-help@r-project.org mailing list -- To UNSUB

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Kevin Thorpe
Is there a leading space on those variables for that row? Kevin > On Nov 1, 2021, at 2:01 PM, Rich Shepard wrote: > > On Mon, 1 Nov 2021, Jeff Newmiller wrote: > >> Sorry... untested code... use which... not where. > > Jeff, > > That problem's resolved; problems() found the lines. > > Ques

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Jeff Newmiller wrote: Sorry... untested code... use which... not where. Jeff, That problem's resolved; problems() found the lines. Question: cor_disc # A tibble: 415,263 × 8 site_nbr year mon day hrmin tz disc 1 14171600 2009 1023

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Jeff Newmiller
Sorry... untested code... use which... not where. On November 1, 2021 10:29:13 AM PDT, Rich Shepard wrote: >On Mon, 1 Nov 2021, Jeff Newmiller wrote: > >> More explicitly... look at rows past the first row. If your csv has 300 >> rows and column 1 has something non-numeric in row 299 then the wh

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Bill Dunlap wrote: Use the col_type argument to specify your column types. [Why would you expect '2009' to be read as a string instead of a number?]. It looks like an initial zero causes an otherwise numeric looking entry to be considered a string (handy for zip codes in the

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Bill Dunlap
Use the col_type argument to specify your column types. [Why would you expect '2009' to be read as a string instead of a number?]. It looks like an initial zero causes an otherwise numeric looking entry to be considered a string (handy for zip codes in the northeastern US). help(read_csv) says t

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Jeff Newmiller wrote: More explicitly... look at rows past the first row. If your csv has 300 rows and column 1 has something non-numeric in row 299 then the whole column gets imported as character data. Try cor_disc[[ 1 ]] |> as.numeric() |> is.na() |> where() to find suspec

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Jeff Newmiller
More explicitly... look at rows past the first row. If your csv has 300 rows and column 1 has something non-numeric in row 299 then the whole column gets imported as character data. Try cor_disc[[ 1 ]] |> as.numeric() |> is.na() |> where() to find suspect rows. You may want to read about the na

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Kevin Thorpe wrote: I do not have a specific answer to your particular problem. All I can say is when a CSV import doesn’t work, it can mean there is something in the CSV file that is unexpected. When read_csv() fails, I will try read.csv() to compare the results. Kevin, I

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
On Mon, 1 Nov 2021, Kevin Thorpe wrote: I do not have a specific answer to your particular problem. All I can say is when a CSV import doesn’t work, it can mean there is something in the CSV file that is unexpected. When read_csv() fails, I will try read.csv() to compare the results. Kevin, T

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Kevin Thorpe
I do not have a specific answer to your particular problem. All I can say is when a CSV import doesn’t work, it can mean there is something in the CSV file that is unexpected. When read_csv() fails, I will try read.csv() to compare the results. Kevin > On Nov 1, 2021, at 12:40 PM, Rich Shepar

[R] tidyverse: read_csv() misses column

2021-11-01 Thread Rich Shepard
The data file, cor-disc.csv begins with: site_nbr,year,mon,day,hr,min,tz,disc 14171600,2009,10,23,00,00,PDT,8750 The first 7 columns are character strings; the 8th column is an integer. After loading library(tidyverse) I ran read_csv() with this result: cor_disc <- read_csv("../data/cor-disc.cs

Re: [R] Help needed with data visualization in R

2021-11-01 Thread Bert Gunter
... 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 stick

Re: [R] Help needed with data visualization in R

2021-11-01 Thread Eric Berger
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>

[R] Help needed with data visualization in R

2021-11-01 Thread bharat rawlley via R-help
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-p

Re: [R] typo in documentation for array // how to report such

2021-11-01 Thread Martin Maechler
> Mathew Englander > on Fri, 29 Oct 2021 20:30:16 -0700 writes: > I noticed a typo in the ?array help-file ("Multi-way > Arrays"), which is also at this web page: > https://stat.ethz.ch/R-manual/R-patched/library/base/html/array.html > In the "Arguments" section of th

[R] [Rd] R 4.1.2 is released

2021-11-01 Thread Peter Dalgaard
The build system rolled up R-4.1.2.tar.gz (codename "Bird Hippie") this morning. The list below details the changes in this release. You can get the source code from https://cran.r-project.org/src/base/R-4/R-4.1.2.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for