Re: [R] Suggestion for installation of R
The following installs a version of R on an android phone or tablet. I have tried it on a google 5x, Lenovo TAB , Bush Spira B2 10.and several other phones/tablets which I do not have acess to exact model descriptions Install Gnuroot Debian from the Google app store. This app installs an expandable Debian system that will run on a non-rooted Android phone/tablet. It includes a basic x-window system. You can start with apt-get update and apt -gat upgrade to bring the system up to date. I have used apt-get to install R, emacs, ess and gretl.. You can do this in a basic terminal or in the x-window terminal. The versions available are a little dated but do work if one can manage the small screen. The x-window screen has additional cursor and cntrl/excape/alt etc keys available. ions You may find that there is a delay between the appearance of a window and the ability to use it. Due to screen, memory and cpu limitations it would be difficult to do any complex work on such a system. There is a native maxima on android app that you might find useful. John C Frain 3 Aranleigh Park Rathfarnham Dublin 14 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:fra...@tcd.ie mailto:fra...@gmail.com On 17 August 2017 at 14:06, S Ellison wrote: > > >Is it possible to download and run R on Asus ZenFone, if yes, which > > >version > > Try Googling 'R on Android' > > The top link is > https://www.r-bloggers.com/install-r-in-android-via- > gnuroot-no-root-required/ > > > > > *** > This email and any attachments are confidential. Any u...{{dropped:13}} __ 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] Update data in text file with data in dataframe
I think we need a bit more info on the data layout and what decision rule you are using to update the Date of Service. Are you just updating a record to provide the most recent DoS or are you correcting errors? Have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example or Reproducibility · Advanced R.for some susggestions on how to form a good question for R-help. Some of the details mentioned in those links can be of great help to R-help readers in trying to suggest approaches. | | | | Reproducibility · Advanced R. | | | We probably should see some sample data both of the existing data set and the update data set. Please supply it using dput() ---discussed in the links above. This is the best way to provide sample data as it ensures that we see exactly the same data as you see. As Jeff says, it is best to keep all communications on the R-help list. It allows many people to see and hopefully contribute to a solution. Welcome to R. Most beginners spend much of their time pounding head on desk or wall but once you get a feel for the way it works it is an incredibly powerful tool. On Saturday, August 19, 2017, 5:02:23 PM EDT, Jeff Newmiller wrote: You might get someone on this last willing to invent something from scratch, but really this mailing list works best if you give very specific information, such as a verbatim copy of several records worth of your data file including all the stuff you want to skip over. Usually if someone is planning on inventing an example from scratch they make a blog post which you could find via search engine. Helping you offline is also not preferred since multiple people can offer advice (or correct each other) if you keep the discussion on the list. And no, giving some of the code you have tried is indeed helpful, since it can highlight things you don't know that might seem obvious to us. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [2] http://adv-r.had.co.nz/Reproducibility.html [3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) -- Sent from my phone. Please excuse my brevity. On August 19, 2017 10:39:26 AM PDT, Nic wrote: >Hello all, > >I'm a novice R programmer and I don't have a clue as to how to approach > >this. I have tried many different approaches only to fail and I can't >seem to wrap my head around it. So I turn to the experts. > >I have a text file with patient data that has incorrect dates of >service. I need to update the dates of service in the text file with >data that's in a dataframe. > >Data in the text file looks like this (call it PatRecs): > >PatientID #: 12345 >Date of Service: 8/1/2017 >. > >. > >. > >PatientID #: 12346 >Date of Service: 8/2/2017 > >. > >. > >. > >The dots are other data. I'm just focused on the PatientID and DOS. > >The data in the data frame (call it DF) looks like > >Id2 DOS > >12345, 8/3/2017 >12346, 8/4/2017 > >etc. > >The lists for both are longer than this. > >I know that in programming for this that there should be readLines and >writeLines and greps - but I'm far too new to using R to figure out the > >usage of these commands. > >How can I update the text file (PatRecs) with the incorrect Date of >Service, with the correct DOS in the dataframe (DF)??? > >This is not a homework assignment, I promise. This is just my attempt >to automate data quality using R, and so that I can learn something >new. In any event, providing you with anything I've done so far would >be meaningless. In an effort to minimize email space, please email me >directly. If there is any interest I'll compile the responses and >forward them. I humbly thank you all for any assistance with this. > >Best, > >Nic > >__ >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] Update data in text file with data in dataframe
You might get someone on this last willing to invent something from scratch, but really this mailing list works best if you give very specific information, such as a verbatim copy of several records worth of your data file including all the stuff you want to skip over. Usually if someone is planning on inventing an example from scratch they make a blog post which you could find via search engine. Helping you offline is also not preferred since multiple people can offer advice (or correct each other) if you keep the discussion on the list. And no, giving some of the code you have tried is indeed helpful, since it can highlight things you don't know that might seem obvious to us. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [2] http://adv-r.had.co.nz/Reproducibility.html [3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) -- Sent from my phone. Please excuse my brevity. On August 19, 2017 10:39:26 AM PDT, Nic wrote: >Hello all, > >I'm a novice R programmer and I don't have a clue as to how to approach > >this. I have tried many different approaches only to fail and I can't >seem to wrap my head around it. So I turn to the experts. > >I have a text file with patient data that has incorrect dates of >service. I need to update the dates of service in the text file with >data that's in a dataframe. > >Data in the text file looks like this (call it PatRecs): > >PatientID #: 12345 >Date of Service: 8/1/2017 >. > >. > >. > >PatientID #: 12346 >Date of Service: 8/2/2017 > >. > >. > >. > >The dots are other data. I'm just focused on the PatientID and DOS. > >The data in the data frame (call it DF) looks like > >Id2DOS > >12345, 8/3/2017 >12346, 8/4/2017 > >etc. > >The lists for both are longer than this. > >I know that in programming for this that there should be readLines and >writeLines and greps - but I'm far too new to using R to figure out the > >usage of these commands. > >How can I update the text file (PatRecs) with the incorrect Date of >Service, with the correct DOS in the dataframe (DF)??? > >This is not a homework assignment, I promise. This is just my attempt >to automate data quality using R, and so that I can learn something >new. In any event, providing you with anything I've done so far would >be meaningless. In an effort to minimize email space, please email me >directly. If there is any interest I'll compile the responses and >forward them. I humbly thank you all for any assistance with this. > >Best, > >Nic > >__ >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] Update data in text file with data in dataframe
Hello all, I'm a novice R programmer and I don't have a clue as to how to approach this. I have tried many different approaches only to fail and I can't seem to wrap my head around it. So I turn to the experts. I have a text file with patient data that has incorrect dates of service. I need to update the dates of service in the text file with data that's in a dataframe. Data in the text file looks like this (call it PatRecs): PatientID #: 12345 Date of Service: 8/1/2017 . . . PatientID #: 12346 Date of Service: 8/2/2017 . . . The dots are other data. I'm just focused on the PatientID and DOS. The data in the data frame (call it DF) looks like Id2DOS 12345, 8/3/2017 12346, 8/4/2017 etc. The lists for both are longer than this. I know that in programming for this that there should be readLines and writeLines and greps - but I'm far too new to using R to figure out the usage of these commands. How can I update the text file (PatRecs) with the incorrect Date of Service, with the correct DOS in the dataframe (DF)??? This is not a homework assignment, I promise. This is just my attempt to automate data quality using R, and so that I can learn something new. In any event, providing you with anything I've done so far would be meaningless. In an effort to minimize email space, please email me directly. If there is any interest I'll compile the responses and forward them. I humbly thank you all for any assistance with this. Best, Nic __ 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] bootstrap subject resampling: resampled subject codes surface as list/vector indices
Thank you and apologies for not having posted the data along with the code. After poking some more, I found the bug. I first initialize sample.subjects as an an empty list: sample.subjects = list() And then I try to the first element of that empty list. sample.subjects[1] = sample(unique(data$subj), 1, replace=TRUE,prob=NULL) Needless to say, an empty list has no elements. After changing this last line to: sample.subjects = sample(unique(data$subj), 1, replace=TRUE,prob=NULL) the code runs without issues. I actually don't need the initialization line. It only caused unnecessary confusion. Thank you! On 8/19/2017 7:15 PM, Bert Gunter wrote: I din't have the patience to go through your missive in detail, but do note that it is not reproducible, as you have not provided a "data" object. You **are** asked to provide a small reproducible example by the posting guide. Of course, others with more patience and/or more smarts may not need the reprex to figure out what's going on. But if not ... Cheers, Bert 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 Sat, Aug 19, 2017 at 7:39 AM, Aleksander Główka wrote: I'm implementing a custom bootstrap resampling procedure in R. This procedure resamples clusters of data points obtained by different subjects in an experiment. Since the bootstrap samples need to have the same size as the original dataset, `target.set.size`, I select speakers compute their data point contributions to make sure I have a set of the right size. set.seed(1) target.sample.size = 1742 count.lookup = rbind(levels(data$subj), as.numeric(table(data$subj))) To this end, I create a dynamic list of resampled subjects, `sample.subjects`, that keep on being selected and appended to the list as long as their summed data point contributions do not exceed `target.set.size`. To conveniently retrieve the number of data points that a given subject contributes I constructed a reference matrix, `count.lookup`, where the first row contains subject codes and the second row contains their respective data point counts. > count.lookup [,1] [,2] [,3] [,4] [,5] [1,] "5" "6" "13" "18" "20" [2,] "337" "202" "311" "740" "152" This is how the resampling works: for (iter in 1:1000){ #select first subject #empty list overwrites sample subjects from previous iteration sample.subjects = list() sample.subjects[1] = sample(unique(data$subj), 1, replace=TRUE, prob=NULL) #determine subject position in data point count lookup first.subj.pos = which(count.lookup[1,]==sample.subjects, arr.ind=TRUE) #add contribution of first subject to data point count sample.size = as.numeric(count.lookup[2,first.subj.pos]) #select subject clusters until you exceed target sample size while(sample.size < target.sample.size){ #add another subject current.subject = sample(unique(data$subj), 1, replace=TRUE, prob=NULL) sample.subjects[length(sample.subjects)+1] = current.subject #determine subject's position in data point lookup curr.subj.pos = which(count.lookup[1,]==current.subject, arr.ind=TRUE) #add subject contribution to the data point count sample.size = sample.size + as.numeric(count.lookup[2,curr.subj.pos]) } #initialize intermediate data frame; intermediate because it will be shortened to fit target size inter.set = data.frame(matrix(, nrow = 0, ncol = ncol(data))) #build the bootstrap sample from the selected subjects for(j in 1:length(sample.subjects)){ inter.set = rbind(inter.set, data[data$subj == sample.subjects[j],]) } #procustean bed of target sample size final.set = inter.set[1:target.sample.size,] write.csv(final.set, paste("bootstrap_sample_", iter,".csv", sep=""), row.names=FALSE) cat("Bootstrap Iteration", iter, "completed\n") #clean up sample.size for next bootstrap iteration sample.size = 0 } My problem is that when I sample the second subject onward and add it to `sample.subjects` (regardless of whether it is a list of a vector), what actually gets added to `sample.subjects` seems to be the index of that subject in `count.lookup`! When I select the first subject code and create a list consisting of just that subject code as the only element, everything is fine. > sample.subjects[1] = sample(unique(tt1$subj), 1, replace=TRUE, prob=NULL) > sample.subjects [[1]] [1] 5 I know this is the actual subject number because when I check the number of data points that this subject contributes in `count.lookup`, it is the number that corresponds to subject 5. > sample.size = as.numeric(tt1.lookup[2,first.subj.pos]) > sample.size However, when I append further
Re: [R] bootstrap subject resampling: resampled subject codes surface as list/vector indices
I din't have the patience to go through your missive in detail, but do note that it is not reproducible, as you have not provided a "data" object. You **are** asked to provide a small reproducible example by the posting guide. Of course, others with more patience and/or more smarts may not need the reprex to figure out what's going on. But if not ... Cheers, Bert 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 Sat, Aug 19, 2017 at 7:39 AM, Aleksander Główka wrote: > I'm implementing a custom bootstrap resampling procedure in R. This > procedure resamples clusters of data points obtained by different subjects > in an experiment. Since the bootstrap samples need to have the same size as > the original dataset, `target.set.size`, I select speakers compute their > data point contributions to make sure I have a set of the right size. > > set.seed(1) > target.sample.size = 1742 > count.lookup = rbind(levels(data$subj), as.numeric(table(data$subj))) > > To this end, I create a dynamic list of resampled subjects, > `sample.subjects`, that keep on being selected and appended to the list as > long as their summed data point contributions do not exceed > `target.set.size`. To conveniently retrieve the number of data points that a > given subject contributes I constructed a reference matrix, `count.lookup`, > where the first row contains subject codes and the second row contains their > respective data point counts. > > > count.lookup > > [,1] [,2] [,3] [,4] [,5] > [1,] "5" "6" "13" "18" "20" > [2,] "337" "202" "311" "740" "152" > > This is how the resampling works: > > for (iter in 1:1000){ > > #select first subject > #empty list overwrites sample subjects from previous iteration > sample.subjects = list() > sample.subjects[1] = sample(unique(data$subj), 1, replace=TRUE, > prob=NULL) > > #determine subject position in data point count lookup > first.subj.pos = which(count.lookup[1,]==sample.subjects, > arr.ind=TRUE) > > #add contribution of first subject to data point count > sample.size = as.numeric(count.lookup[2,first.subj.pos]) > > #select subject clusters until you exceed target sample size > while(sample.size < target.sample.size){ > > #add another subject > current.subject = sample(unique(data$subj), 1, replace=TRUE, > prob=NULL) > sample.subjects[length(sample.subjects)+1] = current.subject > > #determine subject's position in data point lookup > curr.subj.pos = which(count.lookup[1,]==current.subject, > arr.ind=TRUE) > > #add subject contribution to the data point count > sample.size = sample.size + > as.numeric(count.lookup[2,curr.subj.pos]) > } > > #initialize intermediate data frame; intermediate because it will be > shortened to fit target size > inter.set = data.frame(matrix(, nrow = 0, ncol = ncol(data))) > > #build the bootstrap sample from the selected subjects > for(j in 1:length(sample.subjects)){ > > inter.set = rbind(inter.set, data[data$subj == sample.subjects[j],]) > > } > > #procustean bed of target sample size > final.set = inter.set[1:target.sample.size,] > > write.csv(final.set, paste("bootstrap_sample_", iter,".csv", sep=""), > row.names=FALSE) > cat("Bootstrap Iteration", iter, "completed\n") > > #clean up sample.size for next bootstrap iteration > sample.size = 0 > > } > > My problem is that when I sample the second subject onward and add it to > `sample.subjects` (regardless of whether it is a list of a vector), what > actually gets added to `sample.subjects` seems to be the index of that > subject in `count.lookup`! When I select the first subject code and create a > list consisting of just that subject code as the only element, everything is > fine. > > > sample.subjects[1] = sample(unique(tt1$subj), 1, replace=TRUE, > prob=NULL) > > sample.subjects > [[1]] > [1] 5 > > I know this is the actual subject number because when I check the number of > data points that this subject contributes in `count.lookup`, it is the > number that corresponds to subject 5. > > > sample.size = as.numeric(tt1.lookup[2,first.subj.pos]) > > sample.size > > However, when I append further sampled subject codes to the list, for some > reason they surface as their index number in count.lookup. > > > sample.subjects > [[1]] > [1] 5 > > [[2]] > [1] 5 > > [[3]] > [1] 1 > > [[4]] > [1] 2 > > [[5]] > [1] 5 > > [[6]] > [1] 2 > > [[7]] > [1] 2 > > [[8]] > [1] 3 > > [[9]] > [1] 3 > > The third element, for example, is 1. This coincides with none of the > subject codes in count.lookup. > > It seems the problem lies in how I append to `sample.su
[R] bootstrap subject resampling: resampled subject codes surface as list/vector indices
I'm implementing a custom bootstrap resampling procedure in R. This procedure resamples clusters of data points obtained by different subjects in an experiment. Since the bootstrap samples need to have the same size as the original dataset, `target.set.size`, I select speakers compute their data point contributions to make sure I have a set of the right size. set.seed(1) target.sample.size = 1742 count.lookup = rbind(levels(data$subj), as.numeric(table(data$subj))) To this end, I create a dynamic list of resampled subjects, `sample.subjects`, that keep on being selected and appended to the list as long as their summed data point contributions do not exceed `target.set.size`. To conveniently retrieve the number of data points that a given subject contributes I constructed a reference matrix, `count.lookup`, where the first row contains subject codes and the second row contains their respective data point counts. > count.lookup [,1] [,2] [,3] [,4] [,5] [1,] "5" "6" "13" "18" "20" [2,] "337" "202" "311" "740" "152" This is how the resampling works: for (iter in 1:1000){ #select first subject #empty list overwrites sample subjects from previous iteration sample.subjects = list() sample.subjects[1] = sample(unique(data$subj), 1, replace=TRUE, prob=NULL) #determine subject position in data point count lookup first.subj.pos = which(count.lookup[1,]==sample.subjects, arr.ind=TRUE) #add contribution of first subject to data point count sample.size = as.numeric(count.lookup[2,first.subj.pos]) #select subject clusters until you exceed target sample size while(sample.size < target.sample.size){ #add another subject current.subject = sample(unique(data$subj), 1, replace=TRUE, prob=NULL) sample.subjects[length(sample.subjects)+1] = current.subject #determine subject's position in data point lookup curr.subj.pos = which(count.lookup[1,]==current.subject, arr.ind=TRUE) #add subject contribution to the data point count sample.size = sample.size + as.numeric(count.lookup[2,curr.subj.pos]) } #initialize intermediate data frame; intermediate because it will be shortened to fit target size inter.set = data.frame(matrix(, nrow = 0, ncol = ncol(data))) #build the bootstrap sample from the selected subjects for(j in 1:length(sample.subjects)){ inter.set = rbind(inter.set, data[data$subj == sample.subjects[j],]) } #procustean bed of target sample size final.set = inter.set[1:target.sample.size,] write.csv(final.set, paste("bootstrap_sample_", iter,".csv", sep=""), row.names=FALSE) cat("Bootstrap Iteration", iter, "completed\n") #clean up sample.size for next bootstrap iteration sample.size = 0 } My problem is that when I sample the second subject onward and add it to `sample.subjects` (regardless of whether it is a list of a vector), what actually gets added to `sample.subjects` seems to be the index of that subject in `count.lookup`! When I select the first subject code and create a list consisting of just that subject code as the only element, everything is fine. > sample.subjects[1] = sample(unique(tt1$subj), 1, replace=TRUE, prob=NULL) > sample.subjects [[1]] [1] 5 I know this is the actual subject number because when I check the number of data points that this subject contributes in `count.lookup`, it is the number that corresponds to subject 5. > sample.size = as.numeric(tt1.lookup[2,first.subj.pos]) > sample.size However, when I append further sampled subject codes to the list, for some reason they surface as their index number in count.lookup. > sample.subjects [[1]] [1] 5 [[2]] [1] 5 [[3]] [1] 1 [[4]] [1] 2 [[5]] [1] 5 [[6]] [1] 2 [[7]] [1] 2 [[8]] [1] 3 [[9]] [1] 3 The third element, for example, is 1. This coincides with none of the subject codes in count.lookup. It seems the problem lies in how I append to `sample.subjects`. I tried both vectors and list as data structures in which to store sampled subject codes. For each data type, I tried two ways of appending: the one I present above, and one that is more idiomatic in R: sampled.subjects = [current.subject, sampled.subjects] (for lists) and sampled.subjects = c(current.subject, sampled.subjects) (for vectors) Are these appending strategies flawed here or is there some stupid error I'm making somewhere else that is making the indices to surface instead of subject codes? I'd appreciate all 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 provi