search for: closeallconnect

Displaying 20 results from an estimated 295 matches for "closeallconnect".

2016 Oct 30
0
closeAllConnections() can really mess things up
...on class mode text "foo1" "textConnection" "w" "text" opened can read can write "opened" "no" "yes" > closeAllConnections() > con2 <- textConnection("foo2", open = "w") ## Hmm... at this point, con1 point to con2. > print(con1) description class mode text "foo2" "textConnection" "w"...
2009 Dec 08
1
data manipulation/subsetting and relation matrix
Hi List, Here is some example data. myDat <- read.table(textConnection("group id 1 101 1 201 1 301 2 401 2 501 2 601 3 701 3 801 3 901"),header=TRUE) closeAllConnections() corr_mat <-read.table(textConnection("1 1 .5 0 0 0 0 0 0 0 2 .5 1 0 0 0 0 0 0 0 3 0 0 1.0 0 0 0 0 0 0 4 0 0 0 1 .5 .5 0 0 0 5 0 0 0 .5 1 .5 0 0 0 6 0 0 0 .5 .5 1 0 0 0 7 0 0 0 0 0 0 1...
2008 Jul 09
3
randomly select duplicated entries
Using this data as an example dat <- read.table(textConnection("Id myvar 12 1 12 2 12 6 34 9 34 4 34 8 65 15 65 23"), header = TRUE) closeAllConnections() how can I create another data set that does not have duplicate entries for 'Id', but the included values are randomly selected from the available ones. Thanks! Juliet
2010 May 14
2
insert values based on common ID
...Well_80-2 6/19/2000 10:00 -166.728 80-2 1 NA 8 Well_80-2 6/19/2000 11:00 -167.490 80-2 1 NA 9 Well_80-2 6/19/2000 12:00 -167.490 80-2 1 NA 10 Well_80-2 6/19/2000 13:00 -167.490 80-2 1 NA 11 Well_80-2 6/19/2000 14:00 -168.506 80-2 1 NA 12 Well_80-2 6/19/2000 15:00 -168.506 80-2 1 NA"),header=T) closeAllConnections() b<-read.table(textConnection("week weekAvg 0 -147.3726 1 -181.3429 2 -151.7208 3 -188.8653 4 -163.7465 5 -161.6873 6 -158.5168 7 -146.6136 8 -175.4351 9 -100.9450 10 -151.3655 11 -125.8975 12 -162.5993"),header=T) closeAllConnections() -- View this message in context: htt...
2001 Oct 02
1
connections: remember to close it!
...organized. Thanks a bundle to the R Core for this excellent work!! One reminder for people new to connections: If you open connections inside a function, make sure they are closed before exiting from that function, otherwise you end up with connections that can not be closed (or at least I tried closeAllConnections() without success on WinNT4). Not being very smart or clear-headed, I turned a working R script that opens the connection and process the data into an R function, but introduced some bugs in the process. I forgot to add "on.exit(close(filecon))" right after I open the connection in...
2011 Feb 17
4
Find and replace all the elements in a data frame
Hi all, I'm having a problem once again, trying to do something very simple. Consider the following data frame: x <- read.table(textConnection("locus1 locus2 locus3 A T C A T NA T C C A T G"), header = TRUE) closeAllConnections() I am trying to make a new data frame, replacing "A" with "A/A", "T" with "T/T", "G" with "G/G", and "C" with "C/C." Note also the presence of an "NA" (missing data) in the data frame, which should be...
2008 Dec 05
0
applying a function several times
...d before to this list was rejected because of header (subject). I've changed it. The first maybe was not appropriate. I did a function (sec_conop) whose arguments are syndic, well and wellconop. sec_conop(syndic='01syndic.txt',well='well-1.csv',wellconop='well-1.dat');closeAllConnections() This function takes “well” and “syndic”, matching between them and then it does some transformations. The result is exported to “wellconop”. I will apply this function to one hundred different “wells”. Therefore, for each well I use, the “wellconop argument will change too. For intance if “...
2002 Jan 10
1
Closing binary file connections
...o" 12 "daten/t5_all.mea" "file" "rb" "binary" "opened" "yes" "no" 13 "daten/t5_all.mea" "file" "rb" "binary" "opened" "yes" "no" > closeAllConnections() Error in close(set[i]) : no applicable method for "close" In addition: Warning message: no sink to remove What does this mean? Thanks, Sven -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hor...
2009 Jul 17
1
Problem With Repeated Use Of Load/Save/Close Commands
...PathA = tempdir() conX = paste(PathA,"junk",sep="\\") outJunk = file(conX, open="wb") save(junk, file=outJunk) close(outJunk) for(i in 1:4000){ outMIA = file(conX, open="rb") load(file=outMIA) close(outMIA) closeAllConnections() unlink(conX) rm(outMIA) rm(junk) cat(" i = ",i,sep=" ") gc() zzz = showConnections(all=FALSE) cat(" zzz = ",zzz,"\n",sep=" ") } ---------------------------------------------------------------...
2009 Dec 11
1
some problems with ram usage and warnings
...1;1;1" data2 = "2;2;2;2;2;2;2;2;2;2;2;2;2;2" data3 = "3;3;3;3;3;3;3;3;3;3;3;3;3;3" datastring = paste("", head1,data1,data2,data3,"",sep="\n") # import operation res = read.table(textConnection(datastring), header=TRUE, sep = c(";")) closeAllConnections() # I use these two lines in a for-loop like this: #for( j in 1:length(data)) { # res[j] = read.table(textConnection(datastring[j]), header=TRUE, sep = c(";")) # closeAllConnections() #} I get these strings from a file which contains about 50 to 1000 of them, so I can read them al...
2016 May 02
1
Closing a fifo() on Windows core dumps R (3.2.5, 3.3.0 RC and devel)
...mode text opened can read "\016" "fifo" "wb" "text" "opened" "no" can write "yes" [core dump] C:\>R --quiet --vanilla -e "fifo('foo.tmp', open='wb'); closeAllConnections()" > fifo('foo.tmp', open='wb'); closeAllConnections() description class mode text opened can read "\016" "fifo" "wb" "text" "opened" "no" can write...
2008 Sep 22
2
adding layers in ggplot2 (data and code included)
...Connection("Est Group Tri 0 0 4.639644 1 0 4.579189 2 0 4.590714 0 1 4.443696 1 1 4.588243 2 1 4.650505 0 2 4.296608 1 2 4.826036 2 2 4.765386"),header=TRUE); closeAllConnections(); I can form two plots, scatter and lines, as follows: p <- ggplot(mydata, aes(x=Est, y=Tri)) p + geom_point(aes(colour=factor(Group),shape=factor(Group))) and p+ geom_smooth(aes(group=factor(Group),color=factor(Group)),method=lm,se=F). However, I am unable to have the plots together....
2005 Jun 29
2
"all connections are in use" error during lazyload stage of packa ge installation
...file, "r", encoding = encoding) : all connections are in use Execution halted make: *** [lazyload] Error 1 *** Installation of caTools failed *** I searched through R website and mailing lists but did not found many clues. I am not running R environment so showConnections and CloseAllConnections functions are not helpful. Did I run into some OS specific limit on number of files allowed? I closed all other programs and rebooted my machine but it did not help. Any hints would be appreciated. My System is: - R version: R 2.1.1 - Operating System: Win XP - Compiler: mingw32-gcc-3.4.2 Ja...
2012 Jan 19
2
Reading in tab (and space) delimited data within a script XXXX
...;id,workshop,gender,q1,q2,q3,q4 1,1,f,1,1,5,1 2,2,f,2,1,4,1 3,1,f,2,2,4,3 4,2, ,3,1, ,3 5,1,m,4,5,2,4 6,2,m,5,4,5,5 7,1,m,5,3,4,4 8,2,m,4,5,5,5" mydata <- read.table( textConnection(mystring), header=TRUE, sep=",", row.names="id", na.strings=" ") closeAllConnections() mydata Can anyone suggest a similar approach for reading in tab-delimited or single space delimited data? Example data: data3<- "OBSNO AGE SEX ALKPHOS LAB CAMMOL PHOSMMOL AGEGROUP 21 76 M 84 5 3.2 0.9 3 22 76 M 5 2.18 0.84 3 23 68 M 82 5 2.15 0.52 1 24 69 M 84 5 2.3 1.36 1 25 76 F...
2002 Oct 04
1
Getting rid of extra connections?
I'm trying to figure out how to get out of this situation: > source('monit.r') Error in file(file, "r") : All connections are in use > showConnections() description class mode text isopen can read can write > help.search('connection') Error in file(file, "r") : All connections are in use > q() Save workspace image? [y/n/c]: y Error
2010 Sep 26
2
Splitting a data frame into several completely separate data frames
...ompletely separate data frames (rather than separate data frames comprising a single "list")? Consider the following data, and my coding attempt: x <- read.table(textConnection("id type number indv.1 bagel 6 indv.2 bagel 1 indv.3 donuts 10 indv.4 donuts 9"), header = TRUE) closeAllConnections() x.split <- split(x, x$type) This is where I'm stuck. Now I have one "list" comprised of different data frames, but what I want is separate data frames. Ideally, I'd like to design a loop to give sequentially-numbered names to the separate data frames I create. This i...
2009 Jul 18
1
[R] Problem With Repeated Use Of Load/Save/Close Commands (PR#13841)
...te(PathA,"junk",sep="\\") > outJunk = file(conX, open="wb") > save(junk, file=outJunk) > close(outJunk) > for(i in 1:4000){ > outMIA = file(conX, open="rb") > load(file=outMIA) > close(outMIA) > closeAllConnections() > unlink(conX) > rm(outMIA) > rm(junk) > cat(" i = ",i,sep=" ") > gc() > zzz = showConnections(all=FALSE) > cat(" zzz = ",zzz,"\n",sep=" ") > } > ------------------...
2009 Oct 02
6
split-apply question
Hi, I have a data frame that looks like this: >x x1 x2 x3 A 1 1.5 B 2 0.9 B 3 2.7 C 7 1.8 D 7 1.3 I want to "group" by the x1 column and in the case of multiple x$x1 values (e.g., "B")d, return rows that have the smallest values of x2. In the case of rows with only one value of x1 (e.g., "A"), return the row as is. How can I do that?
2010 Jul 20
1
define subgroups based on position in table
...osition in the table. The first subgroup of A's and B's should have nr A1 and B1, the second nr A2 and B2, etc.. I hope the example below makes things more clear. This is what my data look like: x <- read.table(textConnection("group A A A B B A A B B B A A"),header=TRUE) closeAllConnections() group 1 A 2 A 3 A 4 B 5 B 6 A 7 A 8 B 9 B 10 B 11 A 12 A This is what it should become: group sub 1 A A1 2 A A1 3 A A1 4 B B1 5 B B1 6 A A2 7 A A2 8 B B2 9 B B2 10 B B2 11...
2002 Feb 28
2
Failed file("foo", "r") keeps file open? (PR#1333)
Full_Name: Henrik Bengtsson Version: R v1.4.0 OS: Solaris 8 Submission from: (NULL) (130.235.3.49) When I am trying the following on Rv1.4.0 on Solaris 8, I get that the "cannot close output sink connection": % R --vanilla tmpfile <- tempfile() # Create a filename that does not exist for(k in 1:100) { cat(k, ": "); try(fh <- file(tmpfile, "r"))