Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread David Winsemius
On Jun 26, 2015, at 3:02 PM, Rich Shepard wrote: > On Fri, 26 Jun 2015, MacQueen, Don wrote: > >> I would have just assigned them all to the first day of the month, using >> as.Date( paste0(allchem$sampdate,'-01') ) >> (or maybe the middle of the month represented by the 15th) >> and then had a

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread Rich Shepard
On Fri, 26 Jun 2015, MacQueen, Don wrote: I would have just assigned them all to the first day of the month, using as.Date( paste0(allchem$sampdate,'-01') ) (or maybe the middle of the month represented by the 15th) and then had a variable that was of the Date class in the base R (with which I

Re: [R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread MacQueen, Don
If a <- read.table(args[1],sep="\t",header=T, stringsAsFactors=F) fails but a <- read.table("/path/to/file/filename.txt", header=T,sep="\t", stringsAsFactors=F) succeeds, then since those two commands are otherwise identical, you had better put print(args[1]) before the call to read.table

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread MacQueen, Don
I would have just assigned them all to the first day of the month, using as.Date( paste0(allchem$sampdate,'-01') ) (or maybe the middle of the month represented by the 15th) and then had a variable that was of the Date class in the base R (with which I am familiar, no small consideration). Depe

Re: [R] question

2015-06-26 Thread David L Carlson
Do not post to the list in html and always copy your message to the list so others can follow the discussion. That should not matter if the possible values in a row are only 0, 1, 2 as you indicated. No matter how large the matrix is, the table should only have three columns. If more values are

Re: [R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Kate Ignatius
Oops - error on my part. Sorry. On Fri, Jun 26, 2015 at 2:54 PM, Bert Gunter wrote: > ... and you should also know by now to cc the list and not respond just to me! > Bert Gunter > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." >-- Cliffor

Re: [R] large dummy-variable set in R

2015-06-26 Thread David Winsemius
On Jun 26, 2015, at 10:14 AM, Sarah Goslee wrote: > Guess what? > > On Fri, Jun 26, 2015 at 9:09 AM, ritschko wrote: >> Hey! Have you ever found a solution to your problem? I have exactly the same >> issue. >> >> Best >> Dear ritschko; People on the R-help list generally feel annoyed when

Re: [R] Formatting YYYY-MM after reading text file

2015-06-26 Thread David Barron
as.yearmon(allchem$sampdate) worked for me. David On 26 June 2015 at 19:44, Rich Shepard wrote: > Data file 'example.dat' has this format: > > stream,sampdate,param,quant > B,1992-03,Cl,4 > B,1992-03,SO4,33 > B,1992-03,pH,8.43 > B,1992-04,Cl,4 > B,1992-04,SO4,32 > B,1992-04,pH,8.46 > B,1992-0

Re: [R] question

2015-06-26 Thread David L Carlson
Don't use html formatting in your emails and use dput() to provide data. Assuming your matrix is called mat: > mat <- structure(c(0L, 1L, 2L, 1L, 0L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 0L, 1L, 0L, 2L, 0L, 0L, 1L, 2L, 0L, 0L, 0L, 2L, 2L, 0L, 0L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Dim = c(5L, 7L), .Dimna

Re: [R] Formatting YYYY-MM after reading text file [RESOLVED]

2015-06-26 Thread Rich Shepard
On Fri, 26 Jun 2015, Rich Shepard wrote: allchem$sampdate <- as.yearmon(format(%Y-%m))allchem$sampdate Reading the yearmon help page again led me to try allchem$sampdate <- as.yearmon(allchem$sampdate) which produces the following structure: 'data.frame': 2226 obs. of 4 variables

Re: [R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Bert Gunter
... and you should also know by now to cc the list and not respond just to me! Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Fri, Jun 26, 2015 at 10:58 AM, Kate Ignatius wrote: > "reading in a tab delimited fi

[R] Formatting YYYY-MM after reading text file

2015-06-26 Thread Rich Shepard
Data file 'example.dat' has this format: stream,sampdate,param,quant B,1992-03,Cl,4 B,1992-03,SO4,33 B,1992-03,pH,8.43 B,1992-04,Cl,4 B,1992-04,SO4,32 B,1992-04,pH,8.46 B,1992-05,Cl,4 B,1992-05,SO4,31 B,1992-05,pH,8.43 It's read into R with allchem <- read.table('example.dat', stringsAsFacto

[R] question

2015-06-26 Thread Lida Zeighami
Hi there, I have a matrix (n*m) which rows including 0,1,2 I want to know the frequency of each elements (0 , 1 , 2) separately for each row! for example : 123 456 7 A 0 1 10 222 B 1 1 1200 2 C 21 10 0

Re: [R] how to change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

2015-06-26 Thread Shi, Tao via R-help
Hi Jens, Thanks for the example!  I can see that you can change the 'filename' attribute for a ff object one-by-one, but is there a way to issue one command that will automatically change the attribute to all the ff objects in your workspace, as you can imagine when I have large number of object

Re: [R] how to change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

2015-06-26 Thread Shi, Tao via R-help
Hi David, Normally, I would have a R code example for this, but since I'm new to this too and just didn't have time to do that.  Hopefully, Jen's code illustrates the problem. Tao On Thursday, June 25, 2015 8:53 PM, David Winsemius wrote: On Jun 25, 2015, at 4:04 PM, Shi, Tao vi

Re: [R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Bert Gunter
?? Are you expecting us to guess what your code was from "reading in a tab delimited file using args" ? You've posted here before and should know by now that explicit code should be provided whenever possible. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And

[R] Error: unexpected symbol in [with read.table]

2015-06-26 Thread Kate Ignatius
When reading in a tab delimited file using args I keep getting the error: Error: unexpected symbol in "Name index" Execution halted The code is this: a <- read.table(args[1],sep="\t",header=T, stringsAsFactors=F) When inputting the file directly, as follows, this produces no errors: a <- read

Re: [R] large dummy-variable set in R

2015-06-26 Thread Sarah Goslee
Guess what? On Fri, Jun 26, 2015 at 9:09 AM, ritschko wrote: > Hey! Have you ever found a solution to your problem? I have exactly the same > issue. > > Best > The people who read the R-help email list have exactly zero idea what you're talking about. The above is all that shows up on the maili

Re: [R] large dummy-variable set in R

2015-06-26 Thread ritschko
Hey! Have you ever found a solution to your problem? I have exactly the same issue. Best -- View this message in context: http://r.789695.n4.nabble.com/large-dummy-variable-set-in-R-tp4700833p4709112.html Sent from the R help mailing list archive at Nabble.com. ___

[R] Fread: add one to skip string identifier

2015-06-26 Thread Trevor Davies
I'm trying to read in a file using the function fread. The file that I'm trying to read in has about 100 lines of information I don't want prior to getting to my matrix of data that I do want. On the line prior to the data I want there is always a string identifier "*end*" The following fread ca

Re: [R] 'class(.) == **' [was 'Call to a function']

2015-06-26 Thread David Winsemius
On Jun 25, 2015, at 11:52 PM, Steven Yen wrote: > Thanks Davis. But actually, the line is legitimate: I didn't say it was illegitimate, only confusing. > > if (inherits(wt,what="character")) wt<-data[,wt] What you are asking for is known in R as non-standard evaluation. Examples include th

Re: [R] Extracting data from a file containing data

2015-06-26 Thread Peter Tuju
Dear Jim Holtman, Thank you very much for your help. Theproblem I'm trying to solve is “To determine weather the evolutionof ENSO can influence rainfall over Tanzania”. In this study I havetwo types of data, ie Rainfall data (for 23 stations) and Ninoindices data, both spanning a period of 31 y

Re: [R] Plotting legend outside of chart area

2015-06-26 Thread Antonio Serrano via R-help
First, you have to increase the bottom margin to have enough space for the legend. You do it like this: par( mar = c(6,4,4,2) ) From R help: ‘mar’ A numerical vector of the form ‘c(bottom, left, top, right)’ which gives the number of lines of margin to be specified on

Re: [R] extracting significant response variables

2015-06-26 Thread Bert Gunter
Offtopic. This list is about R programming. Post to a statistics list like stats.stackexchange.com instead. Better yet, find a local expert to help you. What you describe sounds confused and likely to produce nonsense to me. You may not even have the information needed to answer the question you as

Re: [R] counting similar strings in data.frame

2015-06-26 Thread PIKAL Petr
OK. I do not have canned solution for you, but temp <- apply(test,1, table) gives you number of occurences in each row. From this it shall be possible to extract name info and number info lapply(temp, function(x) x[x>1]) [[1]] four 2 [[2]] one two 2 2 [[3]] three 2 [[4]] four

Re: [R] counting similar strings in data.frame

2015-06-26 Thread Knut Krueger
Am 26.06.2015 um 10:38 schrieb PIKAL Petr: Hi I am little bit lost in your logic. Why triple in your fourth line is one. I expected it will be four? Petr Sorry yes you are right ... type mismatch Knut __ R-help@r-project.org mailing list -- To UNS

Re: [R] counting similar strings in data.frame

2015-06-26 Thread Knut Krueger
Sorry last count was wrong ... test =data.frame("first"=c("seven","two","five","four"), "second"=c("three","one","three","one"), "third"=c("four","two","three","four"), "fourth"=c("four","one","one","four")) count =data.frame("dobule1"=c("four",

Re: [R] how to change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

2015-06-26 Thread Jens Oehlschlägel
Tao, I do assume that the ff-files are still at some location and not deleted by a finalizer. The following explains how to manipulate file locations with ff and ffdf objects. Kind regards jens library(ff) path1 <- "c:/tmp" path2 <- "c:/tmp2" # create ffdf, # using non-standard path sets fin

Re: [R] counting similar strings in data.frame

2015-06-26 Thread PIKAL Petr
Hi I am little bit lost in your logic. Why triple in your fourth line is one. I expected it will be four? Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Knut > Krueger > Sent: Friday, June 26, 2015 10:10 AM > To: r-h...@stat.math.ethz.ch > Su

Re: [R] Usage of sink()

2015-06-26 Thread Jianwen Luo
just use same file handle. From: My List Date: 2015-06-26 15:37 To: R-help Subject: [R] Usage of sink() All: I have the following code segment. msg <- file("msg.txt", open="wt") out <- file("out.txt", open="wt") sink(msg, type="message") sink(out, type="output") write("write() to stderr"

[R] counting similar strings in data.frame

2015-06-26 Thread Knut Krueger
Dear Members, is there a better solution to count the amounts of occurrence in a row with string data than with loops to get the count data.frame? test =data.frame("first"=c("seven","two","five","four"), "second"=c("three","one","three","one"), "third"=c("four

Re: [R] Usage of sink()

2015-06-26 Thread My List
I used the following code - msg <- file("ABC.txt", open="a") out <- file("ABC.txt", open="a") sink(msg, type="message") sink(out, type="output") write("write() to stderr", stderr()) write("write() to stdout", stdout()) and it works. Thanks !!! -Harmeet On Fri, Jun 26, 2015 at 12:48 PM, Jianwen L

[R] Usage of sink()

2015-06-26 Thread My List
All: I have the following code segment. msg <- file("msg.txt", open="wt") out <- file("out.txt", open="wt") sink(msg, type="message") sink(out, type="output") write("write() to stderr", stderr()) write("write() to stdout", stdout()) This works fine, when I want the messages to goto mes.txt and

Re: [R] prmatrix and print.matrix

2015-06-26 Thread Göran Broström
On 06/25/2015 11:18 PM, Therneau, Terry M., Ph.D. wrote: The help page for prmatrix states that it only exists for backwards compatability and strongly hints at using print.matrix instead. However, there does not seem to be a print.matrix() function.' I asked this very same question here