similar to: rownames, colnames, and date and time

Displaying 20 results from an estimated 8000 matches similar to: "rownames, colnames, and date and time"

2006 Jul 03
1
rownames, colnames, and date and time
Hi all I was wondering whether there has ever been an update on the rownames and colnames behaviour as described by Eric below? I still get the same behaviour, exactly as described by Eric, on my WinXP installation of R-2.3.0. I also posted a message to r-help on Friday but looking through the online archives it seems to have not made it to the list. I would agree with Eric that a consistent
2008 Mar 28
3
Converting a data frame to matrix
Hello: I have a tab delim file with 100 rows and 100 columns. I have numerical values in this table. What I want is to create an image color map with color gradation. my values range from -5 to 0. max value is 0. to acheive this, I need to convert my data.frame into matrix. I tried following : mydf <- read.table('mytable',sep='\t',header=T) mydf1 <- mydf[,2:100]
2017 Nov 06
2
For each entry type in column?
Matti - Since you are asking about looping through a column, not looping across columns, it is simply the following: # Note: data.frame() turns strings into factors by default. myDF <- data.frame(type = c("a", "j", "a", "a", "j"), weight = c(12.3, 6.8, 10.5, NA, "5.5")) myDF$type # ... is a vector of factors
2017 Nov 06
0
For each entry type in column?
Boris: "As others have remarked, for added efficiency with large datasets we often use functions from the apply() family, rather than for-loops." That is generally false, though it is a common misconception. Apply-type functions are used to maintain fidelity -- and for some, clarity -- to a functional programming paradigm. Cheers, Bert Bert Gunter "The trouble with having an
2007 Mar 16
1
Rownames are always character?
Gurus, Can I rely on the rownames() function, when applied to a matrix, always returning either NULL or an object of type character? It seems that row names can be entered as integers, but as of now (R 2.4.1 on Windows) the function returns character vectors, not numbers (which is my desired result). I am using elements of the returned vector to index the matrix. e.g., nams <-
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
Hello! I have a data frame with dates. I need to create a new "month" that starts on the 20th of each month - because I'll need to aggregate my data later by that "shifted" month. I wrote the code below and it works. However, I was wondering if there is some ready-made function in some package - that makes it easier/more elegant? Thanks a lot! # Example data:
2017 Jun 27
2
paste strings in C
Dear R-devs, Below is a small example of what I am trying to achieve, that is trivial in R and I would like to learn how to do in C, for very large matrices: > (mymat <- matrix(c(1,0,0,2,2,1), nrow = 2)) [,1] [,2] [,3] [1,] 1 0 2 [2,] 0 2 1 And I would like to produce: [1] "a*C" "B*c" Which can be trivially done in R via something like: foo
2008 May 08
2
Microseconds for a zoo object?
Hello I have a string which contains microseconds, can anyone help on constructing this in to a time object, with the microseconds, that I can take to a ZOO file? Thanks Sean > UK[1,3] [1] "17:09:53.824" > UK[1,1] [1] "2007-12-11 00:00:00" > mydates <- paste( substr(UK[,1], 1, 10), UK[,3]) > mydates[1] [1] "2007-12-11 17:09:53.824" >
2010 Mar 23
2
Adding matrix rows that have the same name?
Does anyone know if there is an R function that will take a matrix like this jim 1 0 0 0 0 0 jim 0 1 0 0 0 0 jim 0 0 1 0 0 0 bob 1 0 0 0 0 0 bob 0 0 1 0 0 0 harry 0 0 1 0 0 0 harry 0 0 0 1 0 0 harry 0 0 0 0 1 0 harry 0 0 0 0 0 1 and make it like this? (that is, add together rows that have the same name?) jim 1 1 1 0 0 0 bob
2010 Jul 15
2
replace negative numbers by smallest positive value in matrix
Hi Group, I have a matrix, and I would like to replace numbers less than 0 by the smallest minimum number. Below is an small matrix, and the loop I used. I would like to get suggestions on the "R way" to do this. Thanks, Juliet # example data set mymat <- structure(c(-0.503183609420937, 0.179063475173256, 0.130473004669938, -1.80825226960127, -0.794910626384209, 1.03857280868547,
2008 Sep 21
1
How to put given values in lower triangle of splom-plot?
Dear R-experts, I have found a splom-modification online which is given below. This works perfectly, but I would like to have a matrix of given correlation values to be used in the lower triangular part (lower.panel) of the splom-plot instead of calculated correlation values. Here is the matrix I would like to use (it can be any other convenient data structure):
2011 Oct 01
1
class definition
Hi everybody! I have a matrix of class "myClass", for example: myMat <- matrix(rnorm(30), nrow = 6) attr(myMat, "class") <- "myClass" class(myMat) When I extract part of ''myMat'', the corresponding class ''myClass'' unfortunately disappear: myMat.p <- myMat[,1:2] class(myMat.p) Please for any advice / suggestions, how
2007 Nov 12
4
time plotting problem
I am completely misunderstanding how to handle dates. I want to plot a couple of data series against some dates. Simple example 1 below works fine. Unfortunately I have multiple observations per day (no time breakdowns) and observations across years. (example 2 very simplistic version ) Can anyone suggest a quick fix or point me to something to read? I thought that zoo might do it but I seem
2017 Nov 06
0
For each entry type in column?
Hello, If you want to loop through the columns of a data.frame you can do for(i in names(df)){ [code] } Another way would be lapply(names(df), function(somecol) class(df[[somecol]])) where class(df[[somecol]]) is just an example, you would use whatever fits your needs. When you say that the column in question holds "levels" do you mean it's a factor? (factors are R's
2005 Oct 11
1
problems with levelplot and contourplot
Hello, Using the following code i want to make a level or contourplot of some data that I produced library(grid);library(lattice); mydata <- read.table("avgee.dat"); mymat <- as.matrix(mydata); mymat <-t(mymat) vals<-as.vector(mymat); conc<-c(0.0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5); a<- c(0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5,5.0, 7.5,10,
2011 Aug 25
2
How to store the output of a loop into a matrix??
Hello, I want to create a matrix of N random numbers with a uniform distributions. Later, I want to repeat T times each row of this matrix. For this I do the following loop: N<-45 T<-10 n<-N*T a<-matrix(runif(N,min=-1,max=1),nr=N) mymat<-matrix(rep(NA,n),nr=n,nc=1) for(i in i:N){ b<-rep(a[i,],T) mymat[i,]<-b } Mi problem is that with this loop I can see the output of the
2010 Jan 15
1
Lattice: How to color the data points in splom() according to the panel they are plotted?
Dear ExpeRts, I have the scatter plot matrix as given below. I would like the different "sub-plots" in the scatter plot matrix to be colored differently. How do I get all points shown in the upper-left plot (on position (1,1) in the scatter plot matrix) to be plotted in blue, and the points shown in the plot to the right (on position (1,2) in the scatter plot matrix) to be plotted in
2011 Feb 21
1
Query: matrix definition
Dear list users, if within a function I first define a matrix mymat <- matrix(NA, nrow=m, ncol=n) and somewhere afterwards by mistake mymat <- c(1,2,3) this second command deletes the first one. How can I make sure that within the function mymat will always remain the matrix defined at the beginning, without possibility of changing it throughout the code? Secondly, is it possible to define
2010 Aug 09
2
coef(summary) and plyr
Dear all, I?m having trouble getting a list of regression variables back into a dataframe. mydf <- data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100)) mydf$fac<-factor(sample((0:2),replace=T,100)) mydf$y<- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rnorm(100) dlply(mydf,.(fac),function(df) lm(y~x1+x2+x3,data=df))->dl here I?d like to use ldply(dl,coef(summary)) or something
2009 Jul 13
1
Add grand mean to every entry in a matrix
Hi, I have a matrix: mymat <- matrix(runif(10*4), ncol=4) I wish to subtract the column means, down the colums, subtract the row means from the rows and add back the grand mean - all the means should be the means of mymat rather than of the new matrix. How can I do this? Any help much appreciated. Thanks Tom _________________________________________________________________