similar to: about sink and scan

Displaying 20 results from an estimated 100000 matches similar to: "about sink and scan"

2007 May 15
1
Efficiently reading random lines form a large file
I need to read two different random lines at a time from a large ASCII file (120 x 296976) containing space delimited 0-1 entries. The following code does the job and it's reasonable fast for my needs: lineNumber = sample(120, 2) line1 = scan(filename, what = "integer", skip=lineNumber[1]-1, nlines=1) line2 = scan(filename, what = "integer",
2008 Nov 04
1
Problems with scan
I have been having problems with using scan(). I searched the archives and found someone with the same problem several years ago, but did not find a solution. I want to prompt the user for input, scan in that input, and then go on to use it as a variable. The simplest version of my program is cat("enter m","\n") m <- scan(n = 1, quiet = T) m If I enter these lines one
2012 Apr 01
1
scan() vs readChar() speed
Dear list, I am trying to find a fast solution to read moderately large (1 -- 10 million entries) text files containing only tab-delimited numeric values. My test file is the following, nr <- 1000 nc <- 5000 m <- matrix(round(rnorm(nr*nc),3),nr=nr) write.table(m, file = "a.txt", append=FALSE, row.names = FALSE, col.names = FALSE) scan() is faster than
2013 Dec 03
1
caracteres como argumentos
r-help-es, en muchas situaciones me encuentro con la necesidad de pasar el nobre de un objeto como argumento a una funciĆ³n: for (i in 1:3) cat(paste( "avglrss",i," <- ", "scan(\"","avgl",i,".rep","\"",",skip=7",")" ,sep="")) en este ejemplo estoy creando objetos "avglrss1",
2003 Apr 11
4
Can I improve the efficiency of my scan() command?
Hi, Suppose I use the following codes to read in a data set. ############################################### > rating <- scan("../Data/Rating.csv", + what = list( + usage = "", + mileage = 0, + sex = "", + excess = "", + ncd = "", +
2001 May 01
1
scan without line numbers?
When using the function scan(quiet=TRUE) the line numbers are printed. Example: > scan(quiet=TRUE) 1: 123 [ENTER] 2: [ENTER] [1] 123 > Is it possible to not show the line numbers? I know about readLines() but I would like to be able to use the extra features of scan(). Thanks for you help! Henrik Bengtsson henrikb at braju.com
2002 May 15
0
Reading multi-line FWF data
I keep getting these fixed-width format (FWF) data files where variables for a single subject are spread across multiple lines and each line has a different format (apparently created with SAS or SPSS). To read them I stole some stuff from `read.fwf' in base R and threw together the function included below. Please feel free to test this function with your own data and let me know of any
2005 Apr 18
1
how to use sink.number()
Dear All R-helper, my question is how to use sink.number. if I want to label the output was sinked by sink function how should I do ? example: zz <- file("c:\\sinktest1.txt",open="wt") sink(zz) g<- 1:10 cat(g,"\n") f<-list(1:100) h<-capture.output(f) cat(h) sink() I want there are marks in "sinktest1.txt" files, let me know the number of
2008 Feb 29
1
How to export tables in list separately using write.table or sink?
R users, My intention is to take factors out of DF, create list of tables and export these tables separately using write.table or sink function. write.table writes tables out as DF:s, should I use sink instead? Here is my example: a <- data.frame( indx = 1:20, var1 = rep(c("I20", "I40", "A50", "B60"), each=5),
2009 Mar 28
2
Output an RWeka model via sink
When I sink the output of an RWeka model to a text file, the output file appears empty: library(RWeka) model = LogitBoost(Species~.,data=iris) print(model) sink("output.txt") print(model) #file output.txt is created, but it is blank sink() Am I doing anything wrong? [[alternative HTML version deleted]]
2002 Feb 14
1
immortal connections
I have several data input functions that include a construct like the following: indat <- function(stuff) { [...] awkp <- paste("awk ...yada yada...", stuff, etc.) scan(pipe(awkp),quiet=TRUE) } I use these functions a lot, and as I do, a lengthening list of closed, but undestroyed, connections accumulates. Ultimately this appears to stuff things up and cause
2015 Mar 18
0
Proposing a change in the base::sink interface for type argument
It's only an illusion until one actually tries providing a vector. > sink('foo', type=c('s','m')) Error in match.arg(type) : 'arg' must be of length 1 The additional benefit of match.arg() which you may have not appreciated is that it allows the user to abbreviate. That is, > sink('foo', type='o') is valid usage. The essential
2011 Jun 23
2
Loading List data into R with scan()
Hi All, I've been given a data file of the form: 1: 3,4,5,6 2:1,2,3 43: 5,7,8,9,5 and i want to read this data in as a list to create the form: (guessing final look) my.list [[1]] [1] 3 4 5 6 [[2]] [1] 1 2 3 [[43]] [1] 5 7 8 9 5 I can get to a stage using scan: scan("my.data", what = character(0), quiet = TRUE) to load [1] "1: 3,4,5,6" [2] "2:1,2,3" [3]
2010 Jul 16
3
Help with Sink Function
iterations <- 100 nvars <- 4 combined <- rbind(scaleMiceTrain, scaleMiceTest) reducedSample <- combined reducedSample <- subset(reducedSample, select = -pID50) reducedSample <- subset(reducedSample, select = -id) for (i in 1:iterations) { miceSample <- sample(combined[,-c(1,2)],nvars, replace=FALSE) miceSample$pID50 <- combined$pID50 miceTestSample <-
2008 Feb 05
2
Incomplete ouput with sink and split=TRUE
Dear List, I am trying to get R's terminal output to a file and to the terminal at the same time, so that I can walk through some tests and keep a log concurrently. The function 'sink' with the option split=TRUE seems to do just that. It works fine for most output but for objects of class htest, the terminal output is incomplete (the lines are there but empty). Here is an
2010 Aug 19
1
texi2dvi: option "clean" also deletes the generated pdf file
Dear expeRts, below are two examples of using texi2dvi. The problem becomes clear from the second example: on cleaning, texi2dvi also deletes the generated .pdf file. Is there a solution? Cheers, Marius ## Example 1: texi2dvi cleans fine, without deleting the generated .pdf require(tools) sink(file="myLaTeXFile1.tex") cat("\\documentclass{article}\n")
2023 Mar 13
0
scan(..., skip=1e11): infinite loop; cannot interrupt
With ?if?(!j--)?{ ?????R_CheckUserInterrupt(); ?????j?=?10000; ?} as?in?current?R?devel?(r83976),?j goes negative (-1) and interrupt is checked every 10001 instead of 10000. I?prefer ?if?(!--j)?{ ?????R_CheckUserInterrupt(); ?????j?=?10000; ?} . In?current?R?devel?(r83976),?if?EOF?is?reached,?the?outer?loop?keeps?going,?i?keeps?incrementing?until?nskip.
2003 Jan 17
1
More info - S-Plus compatability
Dear all, Thanks to those of you who have replied, the majority of the comments pointed out that the error caused by scan may originate from another function, and closer inspection of the output from traceback() reveals that it is in fact the read.table function where the error is originating from the full output of which I have included below. The error msg I recieve is Error in
2007 Jul 05
2
sink() and source()
hello, I have a problem running a R script actually I'm using source() and sink() and it doesn't work source("T:/agents/melyakhlifi/R/essai_rep.r") to execute a file and the file contain sink("T:/agents/melyakhlifi/R/sortie.html") cat("<html><body><pre>\n") matrix.merge2 cat("</pre></body></html>\n") sink() I
2010 Dec 08
2
Parallel Scan of Large File
Is it possible to parallel scan a large file into a character vector in 1M chunks using scan() with the "doMC" package? Furthermore, can I specify the tasks for each child? i.e. I'm working on a Linux box with 8 cores and would like to scan in 8M records at time (all 8 cores scan 1M records at a time) from a file with 40M records total. file <-