Displaying 20 results from an estimated 10000 matches similar to: "Read vector as multi-dimensional data in R by row"
2013 Mar 06
2
How to combine conditional argument and logical argument in R to create subset of data...
Dear R user
I have data created using code below
b<-matrix(2:21,nrow=4)
b[,1:3]=NA
b[4,2]=5
b[3,1]=6
Now the data is
> b
[,1] [,2] [,3] [,4] [,5]
[1,] NA NA NA 14 18
[2,] NA NA NA 15 19
[3,] 6 NA NA 16 20
[4,] NA 5 NA 17 21
I want to keep data in column 4 greater than 15 and the value in column 1 &
2 either greater than 4
2012 Sep 05
4
Summarizing data containing data/time information (as factor)
Dear R user
I want to create a table (as below) to summarize the attached data
(Test.csv, which can be read into R by using 'read.csv(Test.csv, header=F)'
), to indicate the day that there are any data available, e.g.value=1 if
there are any data available for that day, otherwise value=0.
28/04 29/04 30/04 01/05 02/05
532703 0 1 1
2012 Mar 13
4
Converting factor data into Date-time format
Dear R-user,
I have read a dataset from .csv file into R. This dataset includes one
column containing some data in 'date and time' format, e.g. 'dd/mm/yyyy
hh:mm'.
These data were automatically read and saved as 'factor' in R. When I was
trying to produce some plots (such as time series) with the above 'date and
time' on x-axis, it caused some disodering problem,
2012 Mar 21
2
Check results between two data.frame
Dear R-user,
I'm trying to compare two sets of results and wanted to find out which
element in the two data frame/matrix are different.
I wrote the following function and it works ok, and gives me a long list of
"good" as outcomes.
CHECK<-
function (x = "file1", y = "file2")
{
for (i in 1:nrow(x)) {
for (j in 1:ncol(x)) {
if (x[i, j]
2012 May 25
4
Reading a bunch of csv files into R
Dear R users
I am struggling from a data importing issue:
I have some hundreds of csv files needed to be read into R for futher
analysis. All those csv files are named in one of the three formats:
(1) strings: e.g. London_Oxford street
(2) Integer: e.g. 1234_5678
(3) combined: e.g. London_1234
I intend to use read.csv("xxxx_xxx.csv") but I only dealt with
sigle documents before and
2012 Mar 15
2
Importing multiple worksheets from one Excle/ csv file into R
Dear R experts,
I am trying to import some data from some Excle files into R. My Excle file
contains about 50 sheets.
One solution I can think about is to convert my Excle file into csv file
first and then load data into R using 'read.csv'.
But it seems to me that 'read.csv' only supports reading one sheet (or 'one
file') each time, so that seems I have to create 50 csv
2011 Feb 18
6
sort a 3 dimensional array across third dimension ?
I'm attempting to sort a 3 dimensional array that looks like this
> x
, , 1
[,1] [,2]
[1,] 9 9
[2,] 7 9
, , 2
[,1] [,2]
[1,] 6 5
[2,] 4 6
, , 3
[,1] [,2]
[1,] 2 1
[2,] 3 2
Such that it ends up like this ....
> y
, , 1
[,1] [,2]
[1,] 2 1
[2,] 3 2
, , 2
[,1] [,2]
[1,] 6 5
[2,] 4 6
, , 3
[,1] [,2]
2012 Jun 08
3
Resolution issue with exporting plots from R and write tables in Latex code for producing pdf document
Dear R users
I am trying to exporting plots from R to an external folder, or to the
working directory, but the resolution of plots (pdf file) largely reduced.
Any way I can get same quality as my original plots?? e.g. I tested the
plotting part using one example and obtained pretty good (/readable)
quality for each plot in the (4*4) multiple graph. But when I did the loop
and tried to export
2012 Feb 09
2
fill an array by rows
I've dug around but not been able to find anything, am probably missing
something obvious.
How can I fill a three-dimensional (or higher dimension) array by rows
instead of columns.
eg
new1 <- array(c(1:125), c(5,5,5))
works fine for me but fills it by columns and
new2 <- array(c(1:125), c(5,5,5), byrow=TRUE)
throws an error.
Am I missing something obvious? I also tried
2012 Mar 27
2
Supperscript, subscript and double lines in the main/sub title and using greek letters
Dear R-help,
I am trying to express myself as best as I can here. If you also use Latex
to edit math reports or other languages with similar editing method,
you'll see what I'm talking about. My sincere appologies if my question is
not clear enough to some extend, as also I'm not able to provide my code
here because I don`t know which one I can use...
When editing the title in R
2012 Aug 06
1
How to convert data to 'normal' if they are in the form of standard scientific notations?
Dear R users
I read two csv data files into R and called them Tem1 and Tem5.
For the first column, data in Tem1 has 13 digits where in Tem5 there are 14
digits for each observation.
Originally there are 'numerical' as can be seen in my code below. But how
can I display/convert them using other form rather than scientific
notations which seems a standard/default?
I want them to be in
2013 May 02
2
Calculating distance matrix for large dataset
Dear R users
I wondered if any of you ever tried to calculate distance matrix with very
large data set, and if anyone out there can confirm this error message I
got actually mean that my data is too large for this task.
negative length vectors are not allowed
My data size and code used
dim(mydata_nor)[1] 365000 144> d <- dist(mydata_nor, method = "euclidean")
Here my
2012 Oct 15
2
Chopping a two column data frame by rows into a three dimensional array.
If I have a two column data frame like:
> dat <- cbind("x"=c(1:100),"y"=c(100:1))
How can I create an array that splits every ten rows of that data frame
into a third dimension of an array so that:
> newarray[,,1]
,,1
x y
1 100
2 99
3 98
... ...
10 91
,,2
x y
11 90
12 89
... ...
...
Thanks.
[[alternative HTML version deleted]]
2009 Nov 09
1
multiple tests: t-statistic for vectors in 4-dimensional array
Hi everyone,
I created a four dimensional vector (dim (128,128,1,8)). This third
dimension is necessary for another function somewhere. Now I'd like to
perform a t-test on every vector of length 8 in my array on the fourth
dimension.
I'd like to obtain a new array of three dimensions with dimensions
128x128x1 with all these test statistics.
I tried this with a double loop:
A <-
2008 Jul 21
2
avoid loop with three-dimensional array
Dear R user,
I'm trying to find a solution for optimizing my code. I have to run a 50.000
iteration long simulation and it is absolutely necessary to have an
optimized code.
I have to do this operation
*sum_t ( t(X_t) %*% A %*% X_t )*
where X_t is a (d*k) matrix which changes in time and A is a constant in
time (d*d) matrix.
I have put all my X_t in a three dimensional array X of dimension
2011 May 19
2
Add a vector to the values in a specific dimension of an array
Hello,
A simple question, although I can't find an answer via my google/forum
search:
I have a 4-dimensional array; call it A[1:M,1:N,1:P,1:Q]. I have a vector x
that is N by 1.
I would like to "quickly" add x to the 2nd dimension of A; in other words, I
want a quicker way of doing the following:
for (m in 1:M) {
for (p in 1:P) {
for (q in 1:Q) {
A[m,,p,q] =
2013 Sep 13
2
xtable use plus minus
I am using a similar dataset to the following:
a= c("Fruits", "Adam","errorA", "steve", "errorS",
"apples", 17.1,2.22, 3.2,1.1,
"oranges", 3.1,2.55, 18.1,3.2 )
a_table=data.matrix(t(matrix(a,nrow=5)))
I would like to plus minus every second column starting from errorA (using
xtable/ hmisc)
example output (ignoring
2010 Dec 02
1
latex tables for 3+ dimensional tables/arrays
I'm looking for an R method to produce latex versions of tables for
table/array objects of 3 or more dimensions,
which, of necessity is flattened to a 2D display, for example with
ftable(), or vcd::structable, as shown below.
I'd be happy to settle for a flexible solution for the 3D case.
> UCB <- aperm(UCBAdmissions, c(2, 1, 3))
> ftable(UCB)
Dept A B
2010 Dec 16
1
Subarray specification problem
Hi. I'm new to R, and I'm still learning R's system for addressing
subsets of data structures. I'm particularly interested in the
problem of selecting subarrays based on complex criteria involving the
dimnames (as opposed to the values of the cells) of the array. Here's
an example of such a problem.
Suppose I have an array x of unknown dimensions (it may have been
passed as
2006 Aug 02
2
multi dimensional array
how to implement multi dimensional array in ruby
in ruby multi dimension array look like tree structure
plz help me & explain with code
have a pleasant day
thx
narayana
--
Posted via http://www.ruby-forum.com/.