Displaying 20 results from an estimated 9000 matches similar to: "proper use of textConnection"
2011 Dec 31
2
read.csv error: invalid multibyte string
R version: 2.13.1
OS X
Colleagues,
I am working with a CSV file; for testing purposes, I created an XLS version of the file.
When I read these files using read.xls (gdata) or read.csv, I encounter an error:
Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) :
invalid multibyte string at '<b0>C'
The error occurs whether or not I invoke
2012 Oct 18
4
speeding read.table
R 2.15.1
OS X
Colleagues,
I am reading a 1 GB file into R using read.table. The file consists of 100 tables, each of which is headed by two lines of characters.
The first of these lines is:
TABLE NO. 1
The second is a list of column headers.
For example:
TABLE NO. 1
COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10
2012 Nov 28
3
Speeding reading of large file
R 2.15.1
OS X and Windows
Colleagues,
I have a file that looks that this:
TABLE NO. 1
PTID TIME AMT FORM PERIOD IPRED CWRES EVID CP PRED RES WRES
2.0010E+03 3.9375E-01 5.0000E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
2.0010E+03 8.9583E-01
2010 Feb 12
1
Identifying special characters in a text file
Colleagues
R 2.10.1 on a Mac
I read in textfiles using readLines, then I process those files, then I use R to execute another program. Occasionally those files contain characters other than letter / numbers / routine punctuation marks. For example, a bullet (option-8 on a Mac) triggers the problem.
Although R can read and process those characters, the other program cannot so I would like to
2011 Mar 10
1
about textConnection
I need read a table in a string with special format. I used read.csv and textConnection function.
But i am confuse about textConnection by follow code.
case A: It is OK£¡
str0 <- '{"abc",{"def","X,1&Y,2&Z,3"}}'
str1 <- strsplit(str0,'"')[[1]][6]
str2 <- gsub("&","\n", str1)
con <-
2007 May 15
3
textConnection
hello,
I don't understand what's happen just before the textConnection function runs good but now it doesn't run
> Line[1]
[1] "if C325=. then C743=(C152/C103)*100| else C743=(C152/C325)*100"
> textConnection(Line[1])
Erreur dans textConnection(Line[1]) : toutes les connexions sont utilisées
why R display that?
2003 Apr 30
1
textConnection taking a long time to open a big string
I was using 'textConnection' to read in a file with about 11,000 lines so I
could detect lines with incomplete data and delete them and then read them
in with 'scan'. I am using 1.7.0 on Windows. Here is the output from the
script and it was using 51 seconds just to do the textConnection.
Is there a limit on how large a text object can be to be used with
2002 Jun 21
1
textConnection appears to be slow
I was trying to read in a file and delete lines that did not have the
correct
number of fields on them. I was reading the file as one character vector
per line
using 'scan' with sep='\n'. I was then using 'count.fields' with
'textConnection' to the object I just read in.
I thought at first the system was locked up, but further testing showed
that the
2010 Aug 16
2
when to use textConnection ??
Hello.
I don't uderstant when to use textConnection and when not.
Some examples do it, some not.
I've even seen something like
con <- textConnection(rev(rev(ReadLines('data.txt'))[-(1:2]))
data <- read.table(con)
close(con)
--
View this message in context: http://r.789695.n4.nabble.com/when-to-use-textConnection-tp2327132p2327132.html
Sent from the R help mailing list
2010 May 19
1
apparent problems with the textConnection command
Dear list,
In my experiments in reading in text data, I have?obtained some peculiar results.?I would appreciate any help in understanding these results. Consider the following code :
## Reading in text data from a text file
### the first line of file f1.txt contains the text :??? c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;
f1<-file("C:\\Ex\\f1.txt")
c1<-readLines(f1,1)
2013 Jan 22
2
Creating a Data Frame from an XML
Hello,
I'm attempting to read information from an XML into a data frame in R using
the "XML" package. I am unable to get the data into a data frame as I would
like. I have some sample code below.
*XML Code:*
Header...
Data I want in a data frame:
<data>
<row BRAND="GMC" NUM="1" YEAR="1999" VALUE="10000" />
<row
2009 Dec 07
0
A Gamma-GLM with log link
Hi,
I have a set of data (total number of record = 144,122), and I would like to
use gamma-glm with log link to set up a model.
IC is number of records
IL is paid amount
The table below shows that I have
30.578% of the data in the level of "1 - 1000" paid amount
20.320% of the data in the level of "1001 - 2000" paid amount
and so on
My question is could i use the whole data
2017 Aug 09
1
Problem with serialization via readRDS() on a textConnection()
(Sorry for not linking to your message; I accidentally deleted the
original copy of your message.)
Your code
> zz = textConnection('tempConnection', 'wb')
> saveRDS(c("a", "b", "c"), zz, ascii = TRUE)
> serialized_obj = paste(textConnectionValue(zz), collapse='\n')
> readRDS(textConnection(serialized_obj))
Error in
2005 Mar 22
1
I modify my question in "textconnection output"
dear ALL-R-helper:
I modify my question in "textconnection output":
I wrote one function in Rgui:
output <- function(y){
x <- textConnection("foo","w")
sink(x)
a <-5
b <-6
z <-a*b
z
e <-"spss"
h <-c(1,2,3)
ls()
r<-c("s","p","s","s")
p<-list(1:10)
p
y <- foo
sink()
2008 Apr 29
2
reproducible segmentation fault caused by textConnection()
Dear all,
It seems that textConnection() can trigger a segmentation fault. The
following script (using two large loops) makes this bug reproducible:
for (i in 1:10000) {
z=textConnection(NULL,open='w')
for (j in 1:100) {
write(runif(1)*1e6,file=z)
write('\n',file=z)
}
close(z)
}
The bug could be reproduced on R-2.6.1, R-2.7.0 and on the latest
R-devel
2001 Nov 01
1
textConnection
List Members,
I am using R 1.3.1 for windows and trying to capture the output of some
summaries using textConnection. I then want to incorporate the text with
summary graphics output. The code below works (captures the output) when it is
not used in a loop or function. When placed in a loop or function, the cat
outputs are captured to 'foo' but the summary outputs are not. The
2011 Oct 22
1
Does R has a similar way as DATA in SPSS?
Hi there,
In SPSS, small piece of data can be input as following:
DATA LIST LIST /x1 x2 x3 x4 x5 .
BEGIN DATA
5700 12.8 2500 270 25000
1000 10.9 600 10 10000
3400 8.8 1000 10 9000
3800 13.6 1700 140 25000
4000 12.8 1600 140 25000
8200 8.3 2600 60 12000
1200 11.4 400 10 16000
9100 11.5 3300 60 14000
9900 12.5 3400 180 18000
9600 13.7 3600 390 25000
2009 Nov 13
5
Help with complicated regular expression
Colleagues,
I am using R (2.9.2, all platforms) to search for a complicated text
string using regular expressions. I would appreciate any help you can
provide.
The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)
Examples include:
WORD ( 123 )
WORD(1 )
2009 Oct 19
1
source and textConnection
Is this warning given on purpose?
> myconn<-textConnection("print(11*11)")
> source(myconn)
[1] 121
Warning message:
In source(myconn) : argument 'encoding = "native.enc"' will be ignored
Could it be omitted, since the docs state that encoding is only use if
the corresponding argument is a file name or url?
--
Erich Neuwirth, University of Vienna
2020 Oct 24
5
Package recommendations for outputting table with cell formatting
R 4.0.2
OS X
Colleagues
I have the unfortunate need to create a large number of tables (destined for a Word document). I need to color cells depending on the contents, e.g., blue if the value is < 0.5, red if the value is > 1.5.
If the output went initially to Excel, that would work; outputting directly to Word would be even better.
I expect that several packages can accomplish this. I