When I use any function of RWeka Package in Rstudio I get an error, "Error in .jnew (name): java.lang.ClassFormatError." can anyone guide me in this? [[alternative HTML version deleted]]
Read the Posting Guide mentioned at the bottom of this email. Highlights you should be sure to address: * HTML formatted email gets messed up on the R mailing lists, so post in plain text. Yes, you can and need to do this. * Make sure the problem occurs in R by trying it without RStudio. Sometimes RStudio interferes with R, and you have to ask elsewhere about such problems. * Give us details about your setup and the exact commands you used. The sessionInfo function is helpful here, as is a sample of what you entered into a clean R session to get that error (for completeness). Make sure you are clear in your post about what operating system you are using, and what Java runtime (version and 32/64 bitness) is installed. -- Sent from my phone. Please excuse my brevity. On April 5, 2016 5:14:55 AM PDT, "?Rini John? ? via R-help" <r-help at r-project.org> wrote:> >When I use any function of RWeka Package in Rstudio I get an error, >"Error in .jnew (name): java.lang.ClassFormatError." can anyone guide >me in this? > > [[alternative HTML version deleted]] > >______________________________________________ >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 would like to apply a function, fract, to the columns of a dataframe. I tried the following apply(data5NonEventEpochs,2,fract) but, no surprise it did not work as apply works on matrices not data frames. How can I apply a fuction to the columns of a data frame? (I can't covert data5NonEventsEpochs to a matrix as it contains character data). Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
Dear John, Try using sapply(data5NonEventEpochs, fract) HTH Best, Luisfo Chiroque PhD Student IMDEA Networks Institute http://fourier.networks.imdea.org/people/~luis_nunez/ <http://fourier.networks.imdea.org/people/~luis_nunez/>> El 7 abr 2016, a las 23:25, John Sorkin <JSorkin at grecc.umaryland.edu> escribi?: > > > ??I would like to apply a function, fract, to the columns of a > dataframe. I tried the following > apply(data5NonEventEpochs,2,fract) > but, no surprise it did not work as apply works on matrices not data > frames. How can I apply a fuction to the columns of a data frame? (I > can't covert data5NonEventsEpochs to a matrix as it contains character > data). > Thank you, > John > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:16}}
Inline. -- Bert Bert Gunter On Thu, Apr 7, 2016 at 1:25 PM, John Sorkin <JSorkin at grecc.umaryland.edu> wrote:> > ??I would like to apply a function, fract, to the columns of a > dataframe. I tried the following > apply(data5NonEventEpochs,2,fract) > but, no surprise it did not work as apply works on matrices not data > frames.That is false! From ?apply: "If X is not an array but an object of a class with a non-null dim value (such as a data frame), apply attempts to coerce it to an array via as.matrix if it is two-dimensional (e.g., a data frame) or via as.array." Your apply() call would not have worked with a matrix either, as your syntax was wrong. Here is a corrected example:> X <- data.frame(a=1:5,b=6:10)> apply(X,2,function(x)mean(sqrt(x)))a b 1.676466 2.817189 How can I apply a fuction to the columns of a data frame? (I> can't covert data5NonEventsEpochs to a matrix as it contains character > data). > Thank you, > John > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:12}}
Use lapply or sapply. A data frame is also a list with each component representing one column; lapply/sapply will apply the function to each column. Peter On Thu, Apr 7, 2016 at 1:25 PM, John Sorkin <JSorkin at grecc.umaryland.edu> wrote:> > ??I would like to apply a function, fract, to the columns of a > dataframe. I tried the following > apply(data5NonEventEpochs,2,fract) > but, no surprise it did not work as apply works on matrices not data > frames. How can I apply a fuction to the columns of a data frame? (I > can't covert data5NonEventsEpochs to a matrix as it contains character > data). > Thank you, > John > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:12}}
> On Apr 7, 2016, at 1:25 PM, John Sorkin <JSorkin at grecc.umaryland.edu> wrote: > > > ??I would like to apply a function, fract, to the columns of a > dataframe. I tried the following > apply(data5NonEventEpochs,2,fract) > but, no surprise it did not work as apply works on matrices not data > frames.As Bert pointed out your analsysis is incorrect. If `fract` is function that takes a single vector then you should have gotten back a list or a matrix with as many entries or columns as the data5NonEventEpochs had columns. So to do anything further, please post the output of dput(fract) -- David.> How can I apply a fuction to the columns of a data frame? (I > can't covert data5NonEventsEpochs to a matrix as it contains character > data). > Thank you, > John > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:16}}
Hi,When I use any function of RWeka Package in Rstudio I get an error, "Error in .jnew (name): java.lang.ClassFormatError." can anyone guide me in this?Operation system used:?Linux 64 bit (CentOS) Command used:?>data("crude")>tdm <- TermDocumentMatrix(crude, control=list(tokenize = NGramTokenizer)) Packages loaded:?tm and RWeka Regards,Rini John? From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us> To: ?Rini John? ? <rini.john3 at yahoo.com>; ?Rini John? ? via R-help <r-help at r-project.org>; "r-help at r-project.org" <r-help at r-project.org> Sent: Tuesday, 5 April 2016, 18:30:26 Subject: Re: [R] RWeka Error Read the Posting Guide mentioned at the bottom of this email. Highlights you should be sure to address: * HTML formatted email gets messed up on the R mailing lists, so post in plain text. Yes, you can and need to do this. * Make sure the problem occurs in R by trying it without RStudio. Sometimes RStudio interferes with R, and you have to ask elsewhere about such problems. * Give us details about your setup and the exact commands you used. The sessionInfo function is helpful here, as is a sample of what you entered into a clean R session to get that error (for completeness). Make sure you are clear in your post about what operating system you are using, and what Java runtime (version and 32/64 bitness) is installed. -- Sent from my phone. Please excuse my brevity. On April 5, 2016 5:14:55 AM PDT, "?Rini John? ? via R-help" <r-help at r-project.org> wrote: When I use any function of RWeka Package in Rstudio I get an error, "Error in .jnew (name): java.lang.ClassFormatError." can anyone guide me in this? [[alternative HTML version deleted]] 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]]
Hi,When I use any function of RWeka Package in Rstudio I get an error, "Error in .jnew (name): java.lang.ClassFormatError." can anyone guide me in this?Operation system used:?Linux 64 bit (CentOS) Command used:?>data("crude")>tdm <- TermDocumentMatrix(crude, control=list(tokenize = NGramTokenizer)) Packages loaded:?tm and RWeka Regards,Rini John? [[alternative HTML version deleted]]