Displaying 20 results from an estimated 40000 matches similar to: "how to write and read an array ?"
2020 Oct 20
5
write.csv covert Åland to <c5>land
Hi there,
I tried to export the names of country to a csv file with write.csv().
In the resulted file, ?land was coverted to <c5>land. Is there any way
could prevent this happening? Thanks!
> abc
[1] "?land"
> write.table(abc, file = "")
"x"
"1" "<c5>land"
Best,
Jinsong
2020 Oct 20
0
write.csv covert Åland to <c5>land
Hi there,
Why the same string is displayed in different form?
> abc[,1]
[1] "?land" "Afghanistan"
> abc
name
1 <c5>land
2 Afghanistan
And more...
> dput(abc, "aa.txt")
> dget("aa.txt")
name
1 <c5>land
2 Afghanistan
> dget("aa.txt")[,1]
[1] "<c5>land"
2018 Sep 29
1
Improvement to documentation in dput.Rd
If the "Matrix" package is attached, 'example(dget)' fails:
> library(Matrix)
> example(dget)
dget> fil <- tempfile()
dget> ## Write an ASCII version of function mean to our temp file
dget> dput(mean, fil)
dget> ## And read it back into 'bar'
dget> bar <- dget(fil)
Error in initialize(value, ...) : '...' used in
2014 Jun 20
1
dget() much slower in recent R versions
Hello,
I've noticed that dget() is much slower in the current and devel R
versions than in previous versions. In 2.15 reading a 10000-row
data.frame takes less than half a second:
> (which.r <- R.Version()$version.string)
[1] "R version 2.15.2 (2012-10-26)"
> x <- data.frame(matrix(sample(letters, 100000, replace = TRUE), ncol = 10))
> dput(x, which.r)
>
2005 Aug 22
3
read a table ignoring specific rows ?
Dear R users,
First of all sorry for this question, surely quite naive.
(I searched on the R site but was unable to find by myself).
I have a table, called infile :
1 2 3
4 5 6
7 8 9
I would like to read it and ignore the rows with 1st element > 3
I do it now with a for loop, and it's ok,
but I was expecting something simpler, like :
intable = read.table(infile);
newtable =
2007 Oct 17
1
dget not restoring dput in R 2.6.0 (PR#10350)
Full_Name: David States
Version: 2.6.0
OS: Windows XP64
Submission from: (NULL) (141.211.38.9)
# The pair of commands
#
# dput(object, "file.dput")
# object = dget("file.dput")
#
# should be a no op, but this is not working correctly for all objects.
#
# Simple example:
#
# make a simple object of class "hclust"
cl = hclust(dist(matrix(nrow=4,ncol=4, c(1:16))))
#
1999 Feb 12
1
more on dput
I would like to write data so that I can re-read it and reproduce results,
preferably in both R and Splus. In the past when I have done this my data has
been relatively simple and I've just scan()ed it. Now I have a fairly
complicated structure I would like to preserve and I've been trying to use dput
and dget. Is there a better way? If not, the following truncation by dput,
which I
2008 Aug 20
2
Reading in a value of .Random.seed in .Rprofile
For reasons that are best known to myself [ ;-) ] I have a value
of .Random.seed
saved (via dput()) in a file ``.Random.seed.save''.
In my .Rprofile I have the lines:
.Random.seed <- dget(".Random.seed.save")
Junk <- dget(".Random.seed.save")
print(all.equal(.Random.seed,dget(".Random.seed.save")))
2004 Jul 15
1
dput and dget
I am seeking advice about dput() and dget().
We are using the ascii format supported by these functions as a way to
write data from other programs that can be read into R easily. We are able
to save complicated results (in the form of an R list) to a single file
that can be read trivially into R or S-Plus.
My question is whether that format can be considered a safe one for
medium-term (say
2004 Aug 25
5
S <-> R
Hello! I would like to be able to read in list data objects in R/S
created in R/S. (Ie R->S or S->R.) I have tried 'dput' and 'dump' in S,
but neither of the created files could be read into R (with 'dget' nor
'source'). Is there any way that I can save a list object in S that can
be read into R?
Sincerely,
Zachary Skrivanek, PhD
Research Scientist
2020 Oct 20
1
write.csv covert Åland to <c5>land
It looks like an encoding problem.
It works fine for me with R encoding set to UTF-8
Here is part of my sessionInfo() results
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
I would suggest issuing the command
sessionInfo()
and seeing what your encoding is.
On Tue, 20 Oct 2020 at 08:22,
2007 Apr 22
1
dput/dget when a data frame has 2 rows (PR#9627)
This doesn't seem right; I'm using R version 2.4.1 (2006-12-18) on Mac OS
and Win XP and find the same issue:
> mydataframe <- data.frame(ppi=c(.5,.5),mmu=c(5,10))
> dput(mydataframe,"mydataframe.txt")
> dget("mydataframe.txt")
Error in attributes(.Data) <- c(attributes(.Data), attrib) :
row names must be 'character' or 'integer', not
2020 Oct 20
1
write.csv covert Åland to <c5>land
You don't say, but I'd guess you're using Windows. In your code page,
the character ? is probably not representable. At some point in the
sequence of operations involved in printing the dataframe R puts the
string into the native encoding, and since that's impossible on your
system, it substitutes the <c5> instead. The fact that you can
sometimes display it is because
2006 Oct 10
1
error in dput applied to dataframe (PR#9286)
Full_Name: Daniel F Higgins
Version: 2.4.0
OS: Windows XP and Mac OSX
Submission from: (NULL) (128.111.242.49)
Create a dataframe as indicated below and apply 'dput' to it; note that the
row.names attribute is incorrect!
> aaa <- c("AAA","BBB","AAA")
> bbb <- c(1,2,3)
> df <- data.frame(aaa,bbb)
> dput(df)
structure(list(aaa =
2008 Dec 19
1
How to write a Surv object to a csv-file?
Dear All,
trying to write a data.frame, containing Surv objects to a csv-file I get
"Error in dimnames(X) <- list(dn[[1L]], unlist(collabs, use.names = FALSE)) :
length of 'dimnames' [2] not equal to array extent".
See example below.
May be, I overlooked something, but I expected
that also data.frames containing Surv objects may be written to csv files.
Is there a
2006 Jun 15
3
matrix selection return types
Dear Rusers,
I would like some comments about the following results
(under R-2.2.0)
> m = matrix(1:6 , 2 , 3)
> m
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
> z1 = m[(m[,1]==2),]
> z1
[1] 2 4 6
> is.matrix(z1)
[1] FALSE
> z2 = m[(m[,1]==0),]
> z2
[,1] [,2] [,3]
> is.matrix(z2)
[1] TRUE
Considered together, I'm a bit surprised about
2009 Jun 29
2
How to read a list into R??
Dear R helpers:
I have tried many times to find some way to read a list into R. But I faid. Here is an example:
I have a file 'List.txt' which includes data as follows:
[[1]]
[1] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0
[19] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
[[2]]
[1] 0.0000000 0.5000000 0.0000000 0.0000000
2008 Aug 07
3
how to save an R object selectively?
Hi,
How to save an R object for example a matrix or vector and not all objects created in a session (which is usually performed by save.image or q("yes"))?
Best,
Carol
[[alternative HTML version deleted]]
2004 May 05
1
weirdness in sourc()ing a dump() (bug?)
Hi all,
I dump the result of a long simulation, which I know has run to
completion and returned a fairly complex list of lists of things.
However, when I try to read it back in, I get the following error:
> source ('../SIMULATIONS/run.1.R')
Error in structure(list(do.extinction.runs, alpha = 1.8, delta.change =
0.005, : Object "do.extinction.runs" not found
I think the
2007 Jun 27
3
Import from excel
Hello,
I have imported data from Excel using the command
cours=read.delim("w:/apprentissage/cours_2.txt")
after transforming my initial file with tab delimiters
It seemed to work
It is 2-dimensionnal. When I type cours[5,5],
I get this type of message : "[1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217"
And when I want to