Re: [R] Readxl Question

2019-12-20 Thread Jim Lemon
Hi Thomas, Perhaps this is what you are seeking: my_read_excel<-function(filename) { serials<-read_excel(filename,sheet="Flow Data",range=("c6")) flow.data<-read_excel(filename,sheet="Flow Data",range=("c22:c70")) dates<-read_excel(filename,sheet="Flow Data",range=("h14")) return(data.frame(Se

Re: [R] script execution stops and give the error

2019-12-20 Thread Jeff Newmiller
We don't have your data file. Therefore your example is not yet reproducible. If you read the references I provided you in my other email then you will find hints and discussion about how to make your example reproducible without giving out your actual data. The reprex package mentioned in refer

Re: [R] script execution stops and give the error

2019-12-20 Thread Neha gupta
This is the whole code I provided except the libraries such as library(caret) library(randomForest) data=read.csv("fault.csv") inTraining <- createDataPartition(data$bug , p = .75,list = FALSE) training <- data [inTraining, ] testings <- data [-inTraining, ] ctrol = trainControl(method = "repeat

Re: [R] script execution stops and give the error

2019-12-20 Thread Jeff Newmiller
A) Plain text is a setting that you must choose in many modern email clients. Failing to do so tends to cause us to see something more or less different than what you intended us to see. B) Repeating your incomplete example is a more significant issue in this case. If you supply a reproducible

Re: [R] script execution stops and give the error

2019-12-20 Thread Neha gupta
The code is described below: I need to find the RMSE and MAE ///read data which have data types of integer and number. data=read.csv("fault.csv") inTraining <- createDataPartition(data$bug , p = .75,list = FALSE) training <- data [inTraining, ] testings <- data [-inTraining, ] ctrol = trainContro

Re: [R] script execution stops and give the error

2019-12-20 Thread Patrick (Malone Quantitative)
Per the posting guide, post your script and use plain text. There's no way anyone can possibly help with only this information. On Fri, Dec 20, 2019 at 5:33 PM Neha gupta wrote: > > When I run my code, I get the following error and suddenly the execution > of the script stops. Where in my data

[R] script execution stops and give the error

2019-12-20 Thread Neha gupta
When I run my code, I get the following error and suddenly the execution of the script stops. Where in my data is the problem? Something is wrong; all the MAE metric values are missing: RMSERsquaredMAE Min. : NA Min. : NA Min. : NA 1st Qu.: NA 1st Qu.: NA 1s

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
I'm probably misunderstanding what you want. I get this from the code I sent: VC [[1]] Prob.of.exceedance_1 Prob.of.exceedance_2 Prob.of.exceedance_3 100 0.005343027 Prob.of.exceedance_4 1 0.01947477 [[2]] Prob.of.exceedance_1 Prob.of

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
Hi Ioanna, We're getting somewhere, but there are four unique combinations of Taxonomy and IM.type: ER+ETR_H1,PGA ER+ETR_H2,PGA ER+ETR_H1,Sa ER+ETR_H2,Sa Perhaps you mean that ER+ETR_H1 only occurs with PGA and ER+ETR_H2 only occurs with Sa. I handled that by checking that there were any rows th

Re: [R] data reshape

2019-12-20 Thread Yuan Chun Ding
Hi Bert, Thank you for the elegant code example. I achieved my goal using lapply function and do.call function together. Reduce function is nicer one and I am looking into it. Ding From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Friday, December 20, 2019 11:47 AM To: Yuan Chun Ding C

Re: [R] data reshape

2019-12-20 Thread Bert Gunter
It is perhaps worth noting that (assuming I understand correctly) this can easily be done in one go without any overt looping as a nice application of Reduce() after all your files are read into your global environment as a nice application of Reduce(). Example: > a.out <- data.frame(x = 1:3, y1

Re: [R] data reshape

2019-12-20 Thread Bert Gunter
?merge ## note the all.x option Example: > a <- data.frame(x = 1:3, y1 = 11:13) > b <- data.frame(x = c(1,3), y2 = 21:22) > merge(a,b, all.x = TRUE) x y1 y2 1 1 11 21 2 2 12 NA 3 3 13 22 Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things int

Re: [R] Using older version of R

2019-12-20 Thread Duncan Murdoch
On 20/12/2019 11:24 a.m., Steven Yen wrote: I had to use an older version of R (as old as R3.0.3) for a reason. I myself have no problem installing a package built under a newer version, but my student (who also installed R3.0.3) could not install the package (newer version). Had an error message

[R] Readxl Question

2019-12-20 Thread Thomas Subia
Colleagues, I am using readxl to extract a serial number and its associated data using the following code. library(readxl) files <- list.files(pattern="*.xls", full.names = FALSE) serials <- lapply(files, read_excel, sheet="Flow Data", range=("c6")) flow.datum <- lapply(files, read_excel, sheet=

Re: [R] data reshape

2019-12-20 Thread Yuan Chun Ding
Hi Bert, Sorry that I was in a hurry going home yesterday afternoon and just posted my question and hoped to get some advice. Here is what I got yesterday before going home. --- setwd("C:/Awork/VNTR/GETXdata/GTEx_genotypes") file_list

Re: [R] Using older version of R

2019-12-20 Thread Bert Gunter
No. You can install both versions side by side, use the newer version and xx package as needed, use the older version and your essential package as needed, and shift results in .Rdata files -- or even as text files of data -- between them as necessary. This is obviously a nightmare and may be

[R] Using older version of R

2019-12-20 Thread Steven Yen
I had to use an older version of R (as old as R3.0.3) for a reason. I myself have no problem installing a package built under a newer version, but my student (who also installed R3.0.3) could not install the package (newer version). Had an error message saying package x is not available und

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Ioannou, Ioanna
Hello Jim, I made some changes to the code essentially I substitute each 4 lines DS1-4 with one. I estimate VC which in an ideal world should be a matrix with 4 columns one for every exceedance_probability_1-4 and 2 rowsfor each unique combination of taxonomy and IM.Type. Coukd you please check

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Ioannou, Ioanna
Hello Jim, Thank you every so much it ws very helful. In fact what I want to calculate is the following. My very last question is if I want to save the outcome VC, IM.type and Taxonomy in a new data.frame how can I do it? # names of the variables used in the calculations calc_vars<-paste("Pro

Re: [R] How to create a new data.frame based on calculation of subsets of an existing data.frame

2019-12-20 Thread Jim Lemon
Hi Ioanna, For simplicity assume that the new data frame will be named E: E<-D[,c("Taxonomy","IM.type",paste("VC,1:4,sep="_"))] While I haven't tested this, I'm pretty sure I have it correct. Just extract the columns you want from D and assign that to E. Jim On Fri, Dec 20, 2019 at 9:02 PM Ioan

[R] How to save output of multiple unique loops in R.

2019-12-20 Thread Ioanna Ioannou
Hello everyone, Could you please let me know how to create a new data.frame with the output of the 2 unique loops. Essentially i want a data.frame with the IM, Taxonomy and VC . MInd you VC is a vector with 33 elements. Any ideas? best, ioanna D<- data.frame(Ref.No = c(1622, 1623, 1624, 1625,