Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread David Winsemius
On Oct 15, 2015, at 3:10 PM, William Dunlap wrote: > C can tell when it hits the end of input. Reading the lines with > readLines and passing them to scan() does not help - it is the > same as having scan read the original file. > > My problem is that the file (or other connection) has a variab

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread Jeff Newmiller
I don't know what OS-independent function you use in C that performs the way you describe. I would write the below function in C myself in order to get this functionality in that language. readListOfVectors <- function( input ) { lines <- readLines( input ) if ( "" == lines[ length( lines ) ]

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread William Dunlap
C can tell when it hits the end of input. Reading the lines with readLines and passing them to scan() does not help - it is the same as having scan read the original file. My problem is that the file (or other connection) has a variable number of fields on each "line", and perhaps no fields on so

Re: [R] SQL Server "float" is not handled by RODBC -- Is there a workaround?

2015-10-15 Thread Mark Dalphin
Hi Jim, Yes, your Java versions need to match bit width. As for drivers, I do not use the Microsoft one; it used to be hard to obtain for Linux users; I don't know if it still is. I currently use "jtds" from Sourceforge: http://jtds.sourceforge.net/ >From their site: > jTDS is an open source

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread Jeff Newmiller
This is a problem in C as well... and the solution is to read the lines yourself and then give those lines to scan. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#.

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread William Dunlap
scan(nlines=) does this post-processing, which is why I'm using it instead of readLines. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Oct 15, 2015 at 2:06 PM, Sarah Goslee wrote: > Thus the post-processing, which I assume you'd have to do with scan() as well. > >> tcon <- file(tfile, "r"

[R] rvest and the not css selector

2015-10-15 Thread James Toll
Hi, I'm trying to use rvest to scrape a page and I am having difficulty excluding child element superscripts via a CSS selector. For example, here I've read the html and selected nodes. p <- read_html(targetUrl) p %>% html_nodes("td.xyz") The result looks something like this: {xml_nodeset

[R] DeSolve package

2015-10-15 Thread Andre Jackson
I have the following differential equations and return list: dCgd.dt = -kad*y[1]-kgd*y[1] # PK model equation gut d dCld.dt= kad*y[1]-rhyd-rmetd #pk model equation liver d dCgl.dt = -kal*y2[1]-kgl*y2[1] # PK model equation gut l dCll.dt= kal*y2[1]-rhyl-rmetl #pk model

[R] varying color in scatter3D plot

2015-10-15 Thread amish azeem
Dear R family,I am trying to develop a 3D Scatterplot for the following data> dput(fer)structure(c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 54.682478566783, 73.7179265155391, 56.0442812544372, 123.944575771864, 81.6715941711683, 51.7551364274066, 64.017245155324, 73.3252689749

[R] varying color in scatter3D plot

2015-10-15 Thread amish azeem
Dear R family, I am trying to develop a 3D Scatterplot for the following data > dput(fer) structure(c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 54.682478566783, 73.7179265155391, 56.0442812544372, 123.944575771864, 81.6715941711683, 51.7551364274066, 64.017245155324, 73.32526897

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread Sarah Goslee
Thus the post-processing, which I assume you'd have to do with scan() as well. > tcon <- file(tfile, "r") # or tcon <- textConnection(t) > allfile <- readLines(tcon, n=1) > strsplit(paste(allfile, collapse="\n"), "\"") [[1]] [1] "A " "Two line\nentry""\n\n" "Three\nline\ne

Re: [R] SQL Server "float" is not handled by RODBC -- Is there a workaround?

2015-10-15 Thread jim holtman
Mark, Thanks for the suggestion. I will have to look into that option. I assume that if I am running on a 64-bit system, I also have to use the 64-bit version of Java. We have had some problems in the past because the company standard is a 32-bit version of Java and we had to also load in the 6

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread William Dunlap
readLines() does not work for me since it breaks up multiline fields that are enclosed in quotes. E.g., the text file line A "Two line\nentry" should be imported as 2 strings, the second being "Two line\nfield", not "\"Two line" with the next call to readLines bringing in "fentry\"". Bill Dunla

Re: [R] Can scan() detect end-of-file?

2015-10-15 Thread Sarah Goslee
I've always used system("wc -l myfile") to get the number of lines in advance. But here are two other R-only options, both using readLines instead of scan. There's probably something more efficient, too. Your setup: t <- 'A "Two line\nentry"\n\n"Three\nline\nentry" D E\n' tfile <- tempfile() cat(t

Re: [R] Creating a package with specail caracters

2015-10-15 Thread peter dalgaard
> On 15 Oct 2015, at 13:45 , jpara3 wrote: > > I have tried: > > tktitle(tt) <- iconv("¡GUI estadística", from="latin1",to="UTF8") > tktitle(tt) <- iconv("¡GUI estadística", from="",to="UTF8") > tktitle(tt) <- iconv("¡GUI estadística", to="UTF8") > > > But there are no good results. > Hmm,

[R] Can scan() detect end-of-file?

2015-10-15 Thread William Dunlap
I would like to read a connection line by line with scan but don't know how to tell when to quit trying. Is there any way that you can ask the connection object if it is at the end? E.g., t <- 'A "Two line\nentry"\n\n"Three\nline\nentry" D E\n' tfile <- tempfile() cat(t, file=tfile) tcon <- file

Re: [R] SQL Server "float" is not handled by RODBC -- Is there a workaround?

2015-10-15 Thread Mark Dalphin
Hi Jim, No answers over the course of 24 hours so I'll give it a shot. First, I always work under Linux, so my answers may well be worthless for your Windows scenario. Second, I don't know if my workaround works as I don't actually have a SQL Server DB using float. Now the workaround: I have h

Re: [R] create zoo object within a for loop

2015-10-15 Thread David Winsemius
On Oct 15, 2015, at 4:07 AM, Wiebke Ullmann wrote: > Dear everyone. > > I have a data frame with relocation data of several animals > >> head(data) It would be better to post output of dput(head(data)) > >timestamp > > > individual > > > easting > > > nor

Re: [R] Variable names conflict

2015-10-15 Thread Jeff Newmiller
My strategy is to be specific about the names of columns at the top level. As I see it, letting functions internally come up with their own column names makes fragile code. foo <- function(df, newColName ) { x <- setNames( df[, 1, drop = FALSE], newColName ) dfOut <- data.frame(df, x) dfOut }

Re: [R] 'strange' R graphics problem | Linux...

2015-10-15 Thread Evan Cooch
Tried compiling all previous version of R 3.x.x. Compilations went fine. Code works, but every version throws the 'graphics problem' (basically, spawns the X1 window, which more or less becomes a static screen capture of the desktop under the spawned window. What I think is related (cause?) is

Re: [R] Variable names conflict

2015-10-15 Thread Adams, Jean
Axel, The solution you propose looks fine to me, if an error is the outcome that you want in such a situation. Were you hoping for a different outcome? Would you, for example, prefer that the "x" in the data frame be given a different name, rather than the "x" in the function? Jean On Thu, Oct

Re: [R] Variable names conflict

2015-10-15 Thread Giorgio Garziano
May this be fine ? foo <- function(df) { x <- df[, 1, drop = FALSE] available <- rev(letters[(letters %in% colnames(df)) == FALSE]) colnames(x) <- available[1] dfOut <- data.frame(df, x) dfOut } Data <- data.frame(x = c(1, 2), y = c(3, 4)) foo(Data) x y z 1 1 3 1 2 2 4 2 -- GG

[R] Variable names conflict

2015-10-15 Thread Axel Urbiz
Hello, I have a variable named 'x' defined inside a function, which may conflict with a variable name supplied in the argument to the function. What is the best practice to avoid this conflict? foo <- function(df) { x <- df[, 1, drop = FALSE] dfOut <- data.frame(df, x) dfOut } Data <- da

Re: [R] Error in rep.int() invalid 'times' value

2015-10-15 Thread William Dunlap
Doing enumerative combinatorics with rejection methods rarely works well. Try mapping your problem to the problem of choosing m-1 items from n-1. E.g., your code was f0 <- function(n, m) { stopifnot(n > m) D<-matrix(0,nrow=n-m+1,ncol=m-1) for (i in 1:m-1){ D[,i]<-seq(0,n-m,1) }

Re: [R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Rainer M Krug
Boris Steipe writes: > Sorry - two typos coorected: > > If you need x[,"a"] + x[,"b"] equal to 1, then replace any non-zero initial > value of x[,b] with 1-x[,a]. > But if you really need "less than" h, you'll need to specify what your > desired distribution of h - (x[,"a"] + x[,"b"]) should loo

Re: [R] algorithmic method quantile regression

2015-10-15 Thread Cade, Brian
>From ?rq.fit.pfn I see: Details: Preprocessing algorithm to reduce the effective sample size for QR problems with (plausibly) iid samples. The preprocessing relies on subsampling of the original data, so situations in which the observations are not plausibly iid, are likely

[R] processing time line by line

2015-10-15 Thread Sheila the angel
Hello All, I am looking for any package/function which can give processing time for each line of a given function. I came through the package "profr" but don't know how to find line number. Any help will be appreciated. Thanks -- Sheila [[alternative HTML version deleted]] __

[R] Problem in SVM model generation

2015-10-15 Thread Bhawana Sahu
I am using R in my project for analysis of data, and I have generated SVM model using kernlab package with the dataset (3000 rows and 281 columns). Now I want to generate this model for dataset containing 8000 rows and 281 column, but here I am getting an error saying that "cannot allocate vector

[R] create zoo object within a for loop

2015-10-15 Thread Wiebke Ullmann
Dear everyone. I have a data frame with relocation data of several animals >head(data) timestamp individual easting northing 25.03.2014 07:00 animal1 410712.5 5913542 25.03.2014 08:00

[R] Error in rep.int() invalid 'times' value

2015-10-15 Thread Maram SAlem
Dear All, I'm trying to do a simple task (which is in fact a tiny part of a larger code). I want to create a matrix, D, each of its columns is a sequence from 0 to (n-m), by 1. Then, using D, I want to create another matrix ED, whose rows represent all the possible combinations of the elements of

Re: [R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Boris Steipe
Sorry - two typos coorected: If you need x[,"a"] + x[,"b"] equal to 1, then replace any non-zero initial value of x[,b] with 1-x[,a]. But if you really need "less than" h, you'll need to specify what your desired distribution of h - (x[,"a"] + x[,"b"]) should look like. On Oct 15, 2015, at 9:5

Re: [R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Boris Steipe
If you need h equal to 1, then replace any non-zero initial value of x[,b] with 1-x[,a]. But if you really need "less than", you'll need to specify what your desired distribution of h - x[,"a"] + x[,"b"] should look like. No? B. On Oct 15, 2015, at 9:27 AM, Rainer M Krug wrote: > Boris St

Re: [R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Rainer M Krug
Boris Steipe writes: > I don't think the problem is well defined. Otherwise you could just > pick very small numbers from a range that is guaranteed to keep the > sum < h. What further information is missing? That the variables should be covering the whole range from 0 to 1? OK - forgotten to s

Re: [R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Boris Steipe
I don't think the problem is well defined. Otherwise you could just pick very small numbers from a range that is guaranteed to keep the sum < h. B. On Oct 15, 2015, at 8:48 AM, Rainer M Krug wrote: > Hi > > I need a Latin Hypercube with the following conditions: > > 0 < x[,"a"] < 1 > 0 < x

[R] Latin Hyper cube with condition col1+ col2 < x

2015-10-15 Thread Rainer M Krug
Hi I need a Latin Hypercube with the following conditions: 0 < x[,"a"] < 1 0 < x[,"b"] < 1 0 < x[,"c"] < 1 but also x[,"a"] + x[,"b"] < h The first three are easy: --8<---cut here---start->8--- n <- 1000 lhc <- lhs::randomLHS(n=n, k=3 colnames(lhc) <- c("a

[R] Installing R 3.2.2 on machine with old libcurl

2015-10-15 Thread Bjørn-Helge Mevik
We have to install R 3.2.2 on machines with too old libcurl to be able to use https when installing packages, etc. When a user tries to use install.packages() (with the default value of the "repos" option), she is presented with a list of https-repos, which is not very useful. She also gets an er

Re: [R] Creating a package with specail caracters

2015-10-15 Thread jpara3
I have tried: tktitle(tt) <- iconv("¡GUI estadística", from="latin1",to="UTF8") tktitle(tt) <- iconv("¡GUI estadística", from="",to="UTF8") tktitle(tt) <- iconv("¡GUI estadística", to="UTF8") But there are no good results. Can maybe exist a code to insert after the special characters, as \´i f

Re: [R] Creating a package with specail caracters

2015-10-15 Thread peter dalgaard
Read more carefully! That is what I did to _reproduce_ your problem. Try tktitle(tt) <- iconv("¡GUI estadística", to="UTF8", from="latin1") or maybe from="", or from=, depending on how confused your system is about the current encoding, > On 15 Oct 2015, at 11:59 , jpara3 wrote: > > Hi P

Re: [R] Creating a package with specail caracters

2015-10-15 Thread jpara3
Hi Peter, Thanks for your help, but the problem is still happening. I have done this: funcion<-function(){ tt<-tktoplevel(bg="white") x<-iconv("¡GUI estadística",to="latin1") Encoding(x) <- "UTF8" tktitle(tt)<-x } - Guided Tours Basque Country Guided tours in the three ca

Re: [R] Creating a package with specail caracters

2015-10-15 Thread peter dalgaard
> On 15 Oct 2015, at 09:52 , jpara3 wrote: > > Hi, > > I want to create my own package with a very simple GUI. The problem is that > I need to use special latin characters, as ¿,¡,ñ... > > The function i have made is: > > funcion<-function(){ > tt<-tktoplevel() > tktitle(tt)<-"¡GUI de estadí

[R] Creating a package with specail caracters

2015-10-15 Thread jpara3
Hi, I want to create my own package with a very simple GUI. The problem is that I need to use special latin characters, as ¿,¡,ñ... The function i have made is: funcion<-function(){ tt<-tktoplevel() tktitle(tt)<-"¡GUI de estadística" } The problem is that when i run this function, instead est