Re: [R] Looping Through List of .csv Files to Work with Subsets of the Data

2015-06-08 Thread William Dunlap
participant.files <- list.files("/Users/cdanyluck/Documents/Studies/MIG - Dissertation/Data & Syntax/MIG_RAW DATA & TXT Files/Plain Text Files") Try adding the argument full.names=TRUE to that call to list.files(). Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Jun 8, 2015 at 7:15 PM, C

Re: [R] Looping Through List of .csv Files to Work with Subsets of the Data

2015-06-08 Thread Chad Danyluck
Thank you Don. I've incorporated your suggestions which have helped me to understand how loops work better than previously. However, the loop gets stuck trying to read the current file: mig.processed.data <- read.csv("/Users/cdanyluck/Documents/Studies/MIG - Dissertation/Data & Syntax/mig.log.dat

Re: [R] Looping Through List of .csv Files to Work with Subsets of the Data

2015-06-08 Thread MacQueen, Don
So you have 80 files, one for each participant? It appears that from each of the 80 files you want to extract three subsets of rows, one set for baseline one set for audio one set for "free" What I think I would do, if the above is correct, is create one "master" file. This file will have e

Re: [R] subsetting a dataframe

2015-06-08 Thread William Dunlap
Use is.element(elements,set), or its equivalent, elements %in% set: df <- data.frame(dd = c(1, 2, 3), rows = c("A1", "A2", "A3"), columns = c("B1", "B2", "B3"), numbers = c(400, 500, 600)) test_rows <-c("A1","A3") df[ is.element(df$rows, test_rows

[R] subsetting a dataframe

2015-06-08 Thread Bogdan Tanasa
Dear all, would appreciate your suggestions on subsetting a dataframe : please let's consider an example dataframe df: dd<-c(1,2,3) rows<-c("A1","A2","A3") columns<-c("B1","B2","B3") numbers <- c(400, 500, 600) df <- dataframe(dd,rows,columns, numbers) and a vector : test_rows <-c("A1","A3") ;

[R] Looping Through List of .csv Files to Work with Subsets of the Data

2015-06-08 Thread Chad Danyluck
Hello, I want to subset specific rows of data from 80 .csv files and write those subsets into new .csv files. The data I want to subset starts on a different row for each original .csv file. I've created variables that identify which row the subset should start and end on, but I want to loop throu

[R] load a very big .RData - error reading from connection

2015-06-08 Thread carol white via R-help
Hi,How is it possible to load a very big .RData that can't be loaded it's very big and the following error msg is displayed load(".RData") Error: error reading from connection Thanks Carol   [[alternative HTML version deleted]] __ R-help@r-proj

Re: [R] web scraping image

2015-06-08 Thread Curtis DeGasperi
Thanks to Jim's prompting, I think I came up with a fairly painless way to parse the HTML without having to write any parsing code myself using the function getHTMLExternalFiles in the XML package. A working version of the code follows: ## Code to process USGS peak flow data require(dataRetrieval

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
Sarah, Many, many thanks. 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) > B

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread peter dalgaard
On 08 Jun 2015, at 17:03 , Sarah Goslee wrote: > > I'd import them with check.names=FALSE, then modify them explicitly: > > >> mynames <- c("x y", "x y", "x y", "x y") >> mynames > [1] "x y" "x y" "x y" "x y" >> mynames <- sub(" ", ".", mynames) >> mynames > [1] "x.y" "x.y" "x.y" "x.y" >> myn

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread William Dunlap
> mynames [1] "x.y" "x.y" "x.y" "x.y" > mynames <- paste(mynames, seq_along(mynames), sep="_") In addition, if there were a variety of names in mynames and you wanted to number each unique name separately you could use ave(): > origNames <- c("X", "Y", "Y", "X", "Z", "X") > ave(origNames

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread Sarah Goslee
I've taken the liberty of copying this back to the list, so that others can participate in or benefit from the discussion. On Mon, Jun 8, 2015 at 10:49 AM, John Sorkin wrote: > Sarah, > I am not sure how I use check.names to replace every space in the names of > my variables with an underline. C

[R] [R-pkgs] New version of wikipediatrend

2015-06-08 Thread Peter Meissner
Dear UseRs, wikipediatrend - a package to retrieve Wikipedia page access statistics - has jumped from version 0.2 to 1.1.3 and now is more streamlined, feature richer, more tested and comes with a vignette as well as a lot of fun. packge information: http://cran.rstudio.com/web/packages/

[R] [R-pkgs] New R package kwb.hantush (0.2.1): calculation of groundwater mounding beneath an (stormwater) infiltration basin

2015-06-08 Thread Michael Rustler
Dear R users, It is a pleasure for me to announce the availability of the new package kwb.hantush (0.2.1)  on CRAN. Its objective is the calculation of groundwater mounding beneath an (stormwater) infiltration basin by solving the Hantush (1967) equation. For checking the correct implementation

[R] [R-pkgs] New package stepR: fitting step-functions

2015-06-08 Thread Thomas Hotz
Dear R users, It is my pleasure to announce the availability of package stepR (1.0-2) on CRAN. The main purpose of the package is to fit piecewise constant functions (a.k.a. step-functions or block signals) to serial data in a fully data-driven manner under certain (Gaussian or non-Gaussian)

Re: [R] mismatch between match and unique causing ecdf (well, approxfun) to fail

2015-06-08 Thread Martin Maechler
> Aehm, adding on this: I incorrectly *assumed* without testing that rounding > would help; it doesn't: > ecdf(round(test2,0)) # a rounding that is way too rough for my application... > #Error in xy.coords(x, y) : 'x' and 'y' lengths differ > > Digging deeper: The initially mentioned call to un

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread David L Carlson
Then using Sarah's suggestion something like? > dat <- read.table(text=" + 'Var 1' Var.2 + 1 6 + 2 7 + 3 8 + 4 9 + 5 10", header=TRUE, col.names=c("Var_1", "Var.2")) > dat Var_1 Var.2 1 1 6 2 2 7 3 3 8 4 4 9 5 510 David C From: John Sorkin [mailto:jsor..

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread Duncan Murdoch
On 08/06/2015 10:23 AM, Sarah Goslee wrote: > Easiest? Use sub() to replace the periods after the fact. > > You can also use the check.names or the col.names arguments to > read.table() to customize your import. Yes, check.names is the right idea. Use check.names = FALSE, then use sub() or gsub(

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread Mark Sharp
John, I like using stringr or stringi for this type of thing. stringi is written in C and faster so I now typically use it. You can also use base functions. The main trick is the handy names() function. > example <- data.frame("Col 1 A" = 1:3, "Col 1 B" = letters[1:3]) > example Col.1.A Col.1

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
David,I appreciate you suggestion, but it won't work for me. I need to replace the space for a period at the time the data are read, not afterward. My variables names have periods I want to keep, if I use your suggestion I will replace the period inserted when the data are read, as well as the p

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread Sarah Goslee
Easiest? Use sub() to replace the periods after the fact. You can also use the check.names or the col.names arguments to read.table() to customize your import. Sarah On Mon, Jun 8, 2015 at 10:15 AM, John Sorkin wrote: > I am reading a csv file. The column headers have spaces in them. The spaces

Re: [R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread David L Carlson
You can use gsub() to change the names: > dat <- data.frame("Var 1"=rnorm(5, 10), "Var 2"=rnorm(5, 15)) > dat Var.1Var.2 1 9.627122 14.15376 2 10.741617 16.92937 3 8.492926 15.23767 4 12.226146 15.19834 5 8.829982 14.46957 > names(dat) <- gsub("\\.", "_", names(dat)) > dat Var_1

[R] Blank spaces are replaced by period in read.csv, I want to replace blacks with an underline

2015-06-08 Thread John Sorkin
I am reading a csv file. The column headers have spaces in them. The spaces are replaced by a period. I want to replace the space by another character (e.g. the underline) rather than the period. Can someone tell me how to accomplish this?Thank you, John John David Sorkin M.D., Ph.D. Professor

Re: [R] Cannot Sum with DDPLY

2015-06-08 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi82 > Sent: Monday, June 08, 2015 12:48 PM > To: r-help@r-project.org > Subject: [R] Cannot Sum with DDPLY > > Hi All, > Kindly see the below code I have used: > maxorder<-ddply(test, ~ ORIGIN,sum

Re: [R] Summarizing data based on Date

2015-06-08 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Shivi82 > Sent: Monday, June 08, 2015 11:23 AM > To: r-help@r-project.org > Subject: Re: [R] Summarizing data based on Date > > Hi Petr, > Thanks for the explanation below. > I tried the code you sup

Re: [R] Mean error message missing

2015-06-08 Thread Christian Brandstätter
Thank you very much, I didn't know that. On 08/06/2015 6:04 AM, Christian Brandstätter wrote: Thank you for the explanation. But if you take for instance plot.default(), being another generic function, it would not work like that: plot(1,2,3,4), only plot(1,2) is accepted. From R-help (Usag

Re: [R] Mean error message missing

2015-06-08 Thread Duncan Murdoch
On 08/06/2015 6:04 AM, Christian Brandstätter wrote: > Thank you for the explanation. > But if you take for instance plot.default(), being another generic > function, it would not work like that: > plot(1,2,3,4), only plot(1,2) is accepted. > > > From R-help (Usage): > ## Default S3 method: > m

Re: [R] source code for dbeta

2015-06-08 Thread Duncan Murdoch
On 07/06/2015 11:05 PM, Varun Sinha wrote: > Hi, > > Thanks a lot. I downloaded the tar.gz file and I found the C code. > > I would really appreciate it if you could field another question: > I have to use sql, and I have to perform various statistical > calculations - like integrate, dbeta etc.

[R] Cannot Sum with DDPLY

2015-06-08 Thread Shivi82
Hi All, Kindly see the below code I have used: maxorder<-ddply(test, ~ ORIGIN,summarize,Weight=sum(CHG_WT)) Here I have written the code to summarize values based on origin and total weight however I am getting below error: Error: ‘sum’ not meaningful for factors Please advice. I need CHG_WT tota

Re: [R] mismatch between match and unique causing ecdf (well, approxfun) to fail

2015-06-08 Thread Meyners, Michael
Aehm, adding on this: I incorrectly *assumed* without testing that rounding would help; it doesn't: ecdf(round(test2,0))# a rounding that is way too rough for my application... #Error in xy.coords(x, y) : 'x' and 'y' lengths differ Digging deeper: The initially mentioned call to unique() is

Re: [R] Mean error message missing

2015-06-08 Thread Christian Brandstätter
Thank you for the explanation. But if you take for instance plot.default(), being another generic function, it would not work like that: plot(1,2,3,4), only plot(1,2) is accepted. From R-help (Usage): ## Default S3 method: mean(x, trim = 0, na.rm = FALSE, ...) What is puzzling, is that apparen

[R] mismatch between match and unique causing ecdf (well, approxfun) to fail

2015-06-08 Thread Meyners, Michael
All, I encountered the following issue with ecdf which was originally on a vector of length 10,000, but I have been able to reduce it to a minimal reproducible example (just to avoid questions why I'd want to do this for a vector of length 2...): test2 = structure(list(X817 = 3.39824670255344,

Re: [R] Summarizing data based on Date

2015-06-08 Thread Shivi82
Hi Petr, Thanks for the explanation below. I tried the code you supplied however it seems as my date is a factor hence it is not working. The error I got from the code was : Error: unexpected symbol in: "final<-aggregate(test$CHG_WT,list(format(test$CR_DT,"%d"),sum) final" str(test$CR_DT)- gives

[R] R to HTML problem

2015-06-08 Thread Pijush Das
Dear Jim Lemon, Thank you very much Jim for your help. Regards, Pijush [[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

Re: [R] Summarizing data based on Date

2015-06-08 Thread PIKAL Petr
Hi Is your Date really Date or is it character? What is result of str(Date) If you want to det summaries for dates you can use ?aggregate However in this case I strongly recommend to show us your data by dput(yourdata) and explain on the example what summary do you want. I can be completely

[R] Summarizing data based on Date

2015-06-08 Thread Shivi82
Hi All, I have a data set with 11000 rows & 19 columns. I have 2 columns on which I need to summarize the data:- Date & Weight. Snapshot is : Date 13/03/2015 31/03/2015 15/03/2015 17/03/2015 17/03/2015 11/3/2015 11/3/2015 19/03/2015 CHG_WT 0 0 0 770 3,730 70 10 500 N

Re: [R] Mean error message missing

2015-06-08 Thread Achim Zeileis
On Mon, 8 Jun 2015, Christian Brandstätter wrote: Dear list, I found an odd behavior of the mean function; it is allowed to do something that you probably shouldn't: If you calculate mean() of a sequence of numbers (without declaring them as vector), mean() then just computes mean() of the fi

[R] Mean error message missing

2015-06-08 Thread Christian Brandstätter
Dear list, I found an odd behavior of the mean function; it is allowed to do something that you probably shouldn't: If you calculate mean() of a sequence of numbers (without declaring them as vector), mean() then just computes mean() of the first element. Is there a reason why there is no warn

Re: [R] problems editing R console

2015-06-08 Thread Rosa Oliveira
Thanks all off you ;) I think I got it. I was saving the workplace and loading it, but after that I wasn’t calling my data ;) really naive. Thanks very much. best RO Atenciosamente, Rosa Oliveira -- Rosa Celest

Re: [R] source code for dbeta

2015-06-08 Thread Varun Sinha
Hi, Thanks a lot. I downloaded the tar.gz file and I found the C code. I would really appreciate it if you could field another question: I have to use sql, and I have to perform various statistical calculations - like integrate, dbeta etc. Sql does not have these functions, plus they are very dif