Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
I suppose you could try quote=TRUE Jim On Sun, Sep 4, 2016 at 8:13 PM, Christofer Bogaso wrote: > Thanks Jim. But my data is like that and I have to live with that. Any > idea on workaround. Thanks, > > On Sun, Sep 4, 2016 at 3:40 PM, Jim Lemon

Re: [R] Creating a loop with code from the mblm package

2016-09-04 Thread Bert Gunter
Please go through an R tutorial or two before posting further here. There are many good ones on the web. Some recommendations can be found here: https://www.rstudio.com/online-learning/ Your question: "And my Year column is the first column in my csv file, which I thought made it column 0. Am I

Re: [R] Problem with adding a row in a data table

2016-09-04 Thread Jeff Newmiller
The "c" function creates vectors. Rows of data frames are data frames, not vectors. new_row <- data.frame( Prod_name = "Day_name", `Date 1`=1, `Date 2`=2,`Date 3`=3 ) data_may <- rbind( new_row, data_may ) Furthermore, data frames are NOT spreadsheets. "Day_num" looks suspiciously UNlike a

[R] Problem with adding a row in a data table

2016-09-04 Thread Filippos Katsios
Dear All, I am relatively new to R and certainly new to the e-mailing list. I need your help. I am working on a data frame, which looks like this: Prod_name | Date 1 | Date 2 | Date 3 | --|-||--| Product 1| 3 | 4 |

Re: [R] Problem with adding a row in a data table

2016-09-04 Thread Jeff Newmiller
Please use Reply-all to keep the mailing list in the loop. I cannot provide private assistance, and others may provide valuable input or respond faster than I can. It is very common that people cannot provide the original data. That means more work for YOU, though, not for us. It is up to

[R] Splines

2016-09-04 Thread Filippo Monari
Hi, I would like to use the C spline functions if R for a FORTRAN subroutine. What header file should I refer to? Regards Filippo Monari __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Christofer Bogaso
Didnt work getting unused argument error. On Sun, Sep 4, 2016 at 4:47 PM, Jim Lemon wrote: > I suppose you could try quote=TRUE > > Jim > > > On Sun, Sep 4, 2016 at 8:13 PM, Christofer Bogaso > wrote: >> Thanks Jim. But my data is like that

Re: [R] Creating a loop with code from the mblm package

2016-09-04 Thread Jim Lemon
Hi Bailey, Treat it as a guess, but try this: for (i in c(1:3)){ y<-mydata[,i] x <- mblm(y ~ Year, mydata, repeated = FALSE) print(x) } I'm not sure that you can mix indexed columns with column names. Also, Year is column 4, no? Jim On Sun, Sep 4, 2016 at 11:43 AM, Bailey Hewitt

Re: [R] impossible # of errors in a simple code

2016-09-04 Thread Michael Dewey
A useful rule is to fix the first error you understand and hope that the others go away. On 04/09/2016 04:05, Tamar Michaeli wrote: Any help in resolving the following errors will be appreciated: pollutantmean <- function(directory, pollutant, id=1:332) + file_inc <- list.files("specdata",

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
Shouldn't get that with write.csv. Jim On Sun, Sep 4, 2016 at 9:29 PM, Christofer Bogaso wrote: > Didnt work getting unused argument error. > > On Sun, Sep 4, 2016 at 4:47 PM, Jim Lemon wrote: >> I suppose you could try quote=TRUE >> >>

Re: [R] Need advice on linear programming in R

2016-09-04 Thread Giorgio Garziano
Hi Michael, On top of all suggestions, I can mention the following packages for linear programming problems: https://cran.r-project.org/web/packages/linprog/linprog.pdf https://cran.r-project.org/web/packages/lpSolve/lpSolve.pdf https://cran.r-project.org/web/packages/clue/clue.pdf (see

[R] Error in reading subset of data from CSV file

2016-09-04 Thread Christofer Bogaso
Hi again, I was trying to read a subset of Data from a CSV file using below code as example : library(sqldf) Dat = structure(list(`col 1` = c(133261L, 133261L, 133262L, 133262L ), `col 2` = structure(1:4, .Label = c("aaa1", "aaa2", "bbb1, bbb", "bbb3, bbb"), class = "factor"), `col 3` =

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Jim Lemon
Hi Christofer, You have embedded commas in your data structure. This is guaranteed to mess up a CSV read. Jim On Sun, Sep 4, 2016 at 5:54 PM, Christofer Bogaso wrote: > Hi again, > > I was trying to read a subset of Data from a CSV file using below code > as

Re: [R] Error in reading subset of data from CSV file

2016-09-04 Thread Christofer Bogaso
Thanks Jim. But my data is like that and I have to live with that. Any idea on workaround. Thanks, On Sun, Sep 4, 2016 at 3:40 PM, Jim Lemon wrote: > Hi Christofer, > You have embedded commas in your data structure. This is guaranteed to > mess up a CSV read. > > Jim > > >

[R] impossible # of errors in a simple code

2016-09-04 Thread Tamar Michaeli
Any help in resolving the following errors will be appreciated: > pollutantmean <- function(directory, pollutant, id=1:332) + file_inc <- list.files("specdata", full.names=TRUE) > dat <- data.frame() > for(i in 1:10) { + dat <- rbind(dat, read.csv(file_inc[i])) + } Error in read.table(file =

Re: [R] Problem with adding a row in a data table

2016-09-04 Thread Filippos Katsios
Dear all, I believe that this will be a more helpful way to put the problem: structure(list(Prod_name = c("Banana", "Apple", "Orange", "Yoghurt", "Eggs", "Milk", "Day_num"), X1.1.2000 = c("1", "0", "4", "3", "6", "2", "1"), X2.1.2000 = c("2", "4", "1", "5", "3", "0", "2" ), X3.1.2000 = c("1",

Re: [R] Problem with adding a row in a data table

2016-09-04 Thread Jeff Newmiller
My suggested approach: dta <- structure(list(Prod_name = c("Banana", "Apple", "Orange", "Yoghurt", "Eggs", "Milk", "Day_num"), X1.1.2000 = c("1", "0", "4", "3", "6", "2", "1"), X2.1.2000 = c("2", "4", "1", "5", "3", "0", "2" ), X3.1.2000 = c("1", "5", "2", "3", "0", "4", "3"), X4.1.2000 =

Re: [R] impossible # of errors in a simple code

2016-09-04 Thread Bob Rudis
pretty sure you just missed the `{` at the beginning of the `function` definition block. On Sun, Sep 4, 2016 at 7:38 AM, Michael Dewey wrote: > A useful rule is to fix the first error you understand and hope that the > others go away. > > On 04/09/2016 04:05, Tamar

Re: [R] impossible # of errors in a simple code

2016-09-04 Thread David Winsemius
> On Sep 3, 2016, at 8:05 PM, Tamar Michaeli wrote: > > Any help in resolving the following errors will be appreciated: > >> pollutantmean <- function(directory, pollutant, id=1:332) > + file_inc <- list.files("specdata", full.names=TRUE) >> dat <- data.frame() >> for(i

Re: [R] Treating a vector of characters as object names to create list

2016-09-04 Thread Bert Gunter
Time for an R tutorial or two to learn how to use the "apply" family in R. I think what you want is: merged_list <- lapply(merging, get) -- 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

[R] element wise pattern recognition and string substitution

2016-09-04 Thread Jun Shen
Dear list, I have a vector of strings that cannot be described by one pattern. So let's say I construct a vector of patterns in the same length as the vector of strings, can I do the element wise pattern recognition and string substitution. For example, pattern1 <-

[R] Treating a vector of characters as object names to create list

2016-09-04 Thread Ryan Utz
Hello, I have a vector of characters that I know will be object names and I'd like to treat this vector as a series of names to create a list. But, for the life of me, I cannot figure out how to treat a vector of characters as a vector of object names when creating a list. For example, this does

Re: [R] Treating a vector of characters as object names to create list

2016-09-04 Thread Jim Lemon
Hi Ryan, How about: names(merged.parameters)<-merging Jim On Mon, Sep 5, 2016 at 7:57 AM, Ryan Utz wrote: > Hello, > > I have a vector of characters that I know will be object names and I'd like > to treat this vector as a series of names to create a list. But, for the >

Re: [R] Treating a vector of characters as object names to create list

2016-09-04 Thread Dénes Tóth
On 09/05/2016 12:07 AM, Bert Gunter wrote: Time for an R tutorial or two to learn how to use the "apply" family in R. I think what you want is: merged_list <- lapply(merging, get) Or even: named_merged_list <- mget(merging) Anyway, probably you could arrive to a list of parameters

Re: [R] Treating a vector of characters as object names to create list

2016-09-04 Thread Bert Gunter
Thank you, Dénes. Better yet. -- 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 Sun, Sep 4, 2016 at 4:13 PM, Dénes Tóth wrote: >

[R] evaluating expressions as R console

2016-09-04 Thread Adrian Dușa
Dear R users, I am trying to simulate a pseudo R console, evaluating commands. This is a simple example of a series of command lines which get evaluated: foo <- function(x) { print(x) } print)foo) foo(2) If I copied and pasted this example in an R console, this is the result to replicate

Re: [R] evaluating expressions as R console

2016-09-04 Thread Bert Gunter
You might want to look at the "evaluate" package. 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 Sun, Sep 4, 2016 at 4:47 PM, Adrian Dușa

Re: [R] element wise pattern recognition and string substitution

2016-09-04 Thread Jeff Newmiller
Your opening assertion is false. Provide a reproducible example and someone will demonstrate. -- Sent from my phone. Please excuse my brevity. On September 4, 2016 9:06:59 PM PDT, Jun Shen wrote: >Dear list, > >I have a vector of strings that cannot be described by one

Re: [R] element wise pattern recognition and string substitution

2016-09-04 Thread Bert Gunter
Well, he did provide an example, and... > z <- c('TX.WT.CUT.mean','mg.tx.cv') > sub("^.+?\\.(.+)\\.[^.]+$","\\1",z) [1] "WT.CUT" "tx" ## seems to do what was requested. Jeff would have to amplify on his initial statement however: do you mean that separate patterns can always be combined via