Hi, I am working to understand the Rfast functions of colMins and colMaxs. I worked through the example listed on page 54 of the PDF. https://cran.r-project.org/web/packages/Rfast/index.html https://cran.r-project.org/web/packages/Rfast/Rfast.pdf My data is in a CSV file. So, I bring it into R Studio using: Data <- read.csv("./input/DataSet05.csv", header=T) However, I read the instructions listed on page 54 of the PDF saying I need to bring data into R using a matrix. I think read.csv brings the data in as a dataframe. I think colMins is failing because it is looking for a matrix but finds a dataframe. > colMaxs(Data) Error in colMaxs(Data) : ? Not compatible with requested type: [type=list; target=double]. > colMins(Data, na.rm = TRUE) Error in colMins(Data, na.rm = TRUE) : ? unused argument (na.rm = TRUE) > colMins(Data, value = FALSE, parallel = FALSE) Error in colMins(Data, value = FALSE, parallel = FALSE) : ? Not compatible with requested type: [type=list; target=double]. QUESTION What is the best practice to bring a csv file into R Studio so it can be accessed by colMaxs and colMins, please? Thanks, -- *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com <http://www.shdawson.com>
RStudio is **not** R. In particular, the so-called TidyVerse consists of all *non*-standard contributed packages, about which the PG says: "For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R), ask questions on R-help. [The link is: https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R This gives the list of current _standard_ packages] If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. You can also use find("functionname") and packageDescription("packagename") to find this information. Only send such questions to R-help or R-devel if you get no reply or need further assistance. This applies to both requests for help and to bug reports." Note that RStudio maintains its own help resources at: https://community.rstudio.com/ This is where questions about the TidyVerse, ggplot, etc. should be posted. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help <r-help at r-project.org> wrote:> > Hi, > > > I am working to understand the Rfast functions of colMins and colMaxs. I > worked through the example listed on page 54 of the PDF. > > https://cran.r-project.org/web/packages/Rfast/index.html > > https://cran.r-project.org/web/packages/Rfast/Rfast.pdf > > My data is in a CSV file. So, I bring it into R Studio using: > Data <- read.csv("./input/DataSet05.csv", header=T) > > However, I read the instructions listed on page 54 of the PDF saying I > need to bring data into R using a matrix. I think read.csv brings the > data in as a dataframe. I think colMins is failing because it is looking > for a matrix but finds a dataframe. > > > colMaxs(Data) > Error in colMaxs(Data) : > Not compatible with requested type: [type=list; target=double]. > > colMins(Data, na.rm = TRUE) > Error in colMins(Data, na.rm = TRUE) : > unused argument (na.rm = TRUE) > > colMins(Data, value = FALSE, parallel = FALSE) > Error in colMins(Data, value = FALSE, parallel = FALSE) : > Not compatible with requested type: [type=list; target=double]. > > QUESTION > What is the best practice to bring a csv file into R Studio so it can be > accessed by colMaxs and colMins, please? > > > Thanks, > -- > *Stephen Dawson, DSL* > /Executive Strategy Consultant/ > Business & Technology > +1 (865) 804-3454 > http://www.shdawson.com <http://www.shdawson.com> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
You can use as.matrix() to convert your data.frame to a matrix, but that loses the speed/space advantages of colMins (as well as causing issues if some columns are not numeric). You could write to the maintainer of the package to ask that data.frames be directly supported. In the meantime you could use vapply(yourDataFrame, which.min, FUN.VALUE=NA_real_) or vapply(yourDataFrame, min, FUN.VALUE=NA_real_) instead of colMins. -Bill On Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help < r-help at r-project.org> wrote:> Hi, > > > I am working to understand the Rfast functions of colMins and colMaxs. I > worked through the example listed on page 54 of the PDF. > > https://cran.r-project.org/web/packages/Rfast/index.html > > https://cran.r-project.org/web/packages/Rfast/Rfast.pdf > > My data is in a CSV file. So, I bring it into R Studio using: > Data <- read.csv("./input/DataSet05.csv", header=T) > > However, I read the instructions listed on page 54 of the PDF saying I > need to bring data into R using a matrix. I think read.csv brings the > data in as a dataframe. I think colMins is failing because it is looking > for a matrix but finds a dataframe. > > > colMaxs(Data) > Error in colMaxs(Data) : > Not compatible with requested type: [type=list; target=double]. > > colMins(Data, na.rm = TRUE) > Error in colMins(Data, na.rm = TRUE) : > unused argument (na.rm = TRUE) > > colMins(Data, value = FALSE, parallel = FALSE) > Error in colMins(Data, value = FALSE, parallel = FALSE) : > Not compatible with requested type: [type=list; target=double]. > > QUESTION > What is the best practice to bring a csv file into R Studio so it can be > accessed by colMaxs and colMins, please? > > > Thanks, > -- > *Stephen Dawson, DSL* > /Executive Strategy Consultant/ > Business & Technology > +1 (865) 804-3454 > http://www.shdawson.com <http://www.shdawson.com> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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]]
I don't know anything about this package, but read.csv returns a data frame. How you go about forming a matrix using that data frame depends what is in it. If it is all numeric then as.matrix may be all you need. Half of any R data analysis is data... and the details are almost always crucial. Since you have told us nothing useful about the data, it is up to you to inspect your data and figure out what to do with it. On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via R-help" <r-help at r-project.org> wrote:>Hi, > > >I am working to understand the Rfast functions of colMins and colMaxs. I >worked through the example listed on page 54 of the PDF. > >https://cran.r-project.org/web/packages/Rfast/index.html > >https://cran.r-project.org/web/packages/Rfast/Rfast.pdf > >My data is in a CSV file. So, I bring it into R Studio using: >Data <- read.csv("./input/DataSet05.csv", header=T) > >However, I read the instructions listed on page 54 of the PDF saying I >need to bring data into R using a matrix. I think read.csv brings the >data in as a dataframe. I think colMins is failing because it is looking >for a matrix but finds a dataframe. > > > colMaxs(Data) >Error in colMaxs(Data) : > ? Not compatible with requested type: [type=list; target=double]. > > colMins(Data, na.rm = TRUE) >Error in colMins(Data, na.rm = TRUE) : > ? unused argument (na.rm = TRUE) > > colMins(Data, value = FALSE, parallel = FALSE) >Error in colMins(Data, value = FALSE, parallel = FALSE) : > ? Not compatible with requested type: [type=list; target=double]. > >QUESTION >What is the best practice to bring a csv file into R Studio so it can be >accessed by colMaxs and colMins, please? > > >Thanks,-- Sent from my phone. Please excuse my brevity.
What puzzles me is why you are not just using lapply(some.data.frame, min) lapply(some.data.frame, max) or as.vector(lapply(...)) Why go to another package for this? Is it the indices you want? col.min.indices <- function (some.data.frame) { v <- sapply(some.data.frame, function (column) which(column == min(column))[1]) names(v) <- colnames(some.data.frame) v } On Wed, 1 Dec 2021 at 07:55, Stephen H. Dawson, DSL via R-help < r-help at r-project.org> wrote:> Hi, > > > I am working to understand the Rfast functions of colMins and colMaxs. I > worked through the example listed on page 54 of the PDF. > > https://cran.r-project.org/web/packages/Rfast/index.html > > https://cran.r-project.org/web/packages/Rfast/Rfast.pdf > > My data is in a CSV file. So, I bring it into R Studio using: > Data <- read.csv("./input/DataSet05.csv", header=T) > > However, I read the instructions listed on page 54 of the PDF saying I > need to bring data into R using a matrix. I think read.csv brings the > data in as a dataframe. I think colMins is failing because it is looking > for a matrix but finds a dataframe. > > > colMaxs(Data) > Error in colMaxs(Data) : > Not compatible with requested type: [type=list; target=double]. > > colMins(Data, na.rm = TRUE) > Error in colMins(Data, na.rm = TRUE) : > unused argument (na.rm = TRUE) > > colMins(Data, value = FALSE, parallel = FALSE) > Error in colMins(Data, value = FALSE, parallel = FALSE) : > Not compatible with requested type: [type=list; target=double]. > > QUESTION > What is the best practice to bring a csv file into R Studio so it can be > accessed by colMaxs and colMins, please? > > > Thanks, > -- > *Stephen Dawson, DSL* > /Executive Strategy Consultant/ > Business & Technology > +1 (865) 804-3454 > http://www.shdawson.com <http://www.shdawson.com> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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]]