similar to: extracting month from date in numeric form

Displaying 20 results from an estimated 6000 matches similar to: "extracting month from date in numeric form"

2007 Aug 17
4
matching elements from two vectors
Hi, Imagine a vector x with elements (1,2,1,1,3,5,3,3,1) and a vector y with elements (2,3). I need to find out what elements of x match any of the elements of y. Is there a simple command that will return a vector with elements (F,T,F,F,T,F,T,T,F). Ideally, I would like a solution that works with dataframe colums as well. I have tried x==y and it doesn't work. x==any(y) doesn't work
2010 Aug 20
3
change object name within for loop
Hi, I am writing a for loop that creates one object, say 'outn' on every round of the loop. I would like the name of each object to include the index of the loop as in, for example: out1, out2, out3, ... And I would like the naming of the object to take place automatically as the loop moves through? Similarly, I would like to be able to call different objects (in1, in2, in3,
2007 Aug 17
1
finding the row(s) for a date in a data frame
Hi, If I have a data frame A with the following format: Day1 Day2 Day3 Day4 1 1979-11-02 1979-11-03 1979-11-04 <NA> 2 1979-12-06 <NA> <NA> <NA> 3 1979-12-13 1979-12-14 1979-12-15 1979-12-16 4 1979-12-20 <NA> <NA> <NA> And a date "1979-12-14", for
2012 Nov 08
4
Accessing selected elements of a list
Hi, If I have a vector: junk <- c(2,0,0,3,0) and want to access, say, all the elements that are greater than zero. I just do: junk[which(junk>0)] Now, If I have a list: jlist <- list(NULL,c(1,0),NULL,c(1,2,3), NULL) and want to access all the elements that have length greater than zero, I know how to find the elements with: which(sapply(jlist,length)>0) But how do I get a
2013 Nov 21
2
overlaying 2D grid on randomly distributed points
Hi, I have a cloud of randomly distributed points in 2-dimensional space and want to set up a grid, with a given grid-cell size, that minimizes the distance between my points and the grid nodes. Does anyone know of an R function or toolbox that somehow addresses this problem? This is a problem of optimizing the location of the grid, not a problem of deciding what should be the grid-cell size,
2008 Mar 13
2
joining matrices, vectors, scalars in one object
Hi, I have: a <- matrix(c(0,1,0,1),nrow=2) b <- matrix(c(1,1,1,0,0,0),nrow=3) c <- 1 d <- c(1,0,1) And I would like to join them in an object 'thing' so that I can access a, b, c, or d through an index in a for loop. For example: thing[4] would return [1] 1 0 1 Note however, that I have many of these 'thing' components. So many that a command like thing
2011 Sep 08
3
Density function: Area under density plot is not equal to 1. Why?
Hi, I have a vector 'data' of 58 probability values (bounded between 0 and 1) and want to draw a probability density function of these values. For this, I used the commands: data <- runif(58) a <- density(data, from=0, to=1) plot(a, type="l",lwd=3) But then, when I try to approximate the area under the plotted curve with the command: area <- sum(a$y)*(a$x[1]-a$y[2])
2009 Jan 21
1
finding row and column indices of date in multiple columns of a data frame
Hi, I have a data.frame SAMPLES with columns: Site Site# Season Day1 Day2 Day3 Day1, Day2, Day3 are class "Date", the other columns are numeric or factor. I have a date "mydate" that may or may not be listed in my data.frame and I need to find that out. If "mydate" is there, I want to get the number of the data.frame row where it occurs.
2008 Jan 27
1
calling a list element from a list name passed to a function
Hi, 'true_name' is a list of numerical, matrix, and text items I do pass_name <- "true_name" and pass the name of the list to a function so that the character class variable 'passed_name' contains the name of the list called 'true_name' Inside the function, how can I get a specified element from the list? For example, if I want to get
2008 Mar 15
3
locating minimum value in matrix
Hi, I have a matrix BEE and want to find the row and column numbers of the minimum value in that matrix. The command which(BEE==min(BEE)) returns only one value which, I take, is the position of the minimum in a vector with as many elements as the matrix. Is there a quick and simple way of getting row and column numbers? Thanks, Gonçalo [[alternative HTML version deleted]]
2007 Oct 15
2
clipping off words inside a vector of strings
Hi, I have a vector of strings (class character) with 6 elements (length 6). I call it 'names'. "Graham Chapman" "John Cleese" "Terry Gilliam" "Eric Idle" "Terry Jones" "Michael Palin" And I want to turn it into another vector of strings called 'shortnames' with the same length. The new vector should look like:
2008 Aug 30
1
writing text and output to file with flexibility
Hi, I want a function to write some of its output into a text file with the following format: 'some text' output matrix A 'some more text' output matrix B 'some other text still' output matrix C ... The dimensions of matrices A, B, ... are different and the total number of matrices that I want to place in the text file depends on what I pass to the function. (I
2009 Jan 30
1
simulating outcomes - categorical distribution (?)
Hi, I am simulating an event that has 15 possible outcomes and I have a vector 'pout' that gives me the probability of each outcome - different outcomes have different probabilities. Does anyone know a simple way of simulating the outcome of my event? If my event had only two possible outcomes (0/1) I would pick a uniform random number between 0 and 1 and use it to choose between the two
2007 Sep 11
0
Odp: storing text and decimal values in a matrix form
Hi Gon?alo Ferraz <gferraz29 at gmail.com> napsal dne 11.09.2007 16:35:57: > Thanks! What is the easiest way of declaring an empty data frame. Is there > anything similar to: > matrix(0,x,y) > In the help files, I am only finding longer commands that ask me to specify > each individual column. You can either do dat<-data.frame(x=rep(NA,10), y=rep(NA,10)) or to
2005 Sep 07
2
Month recognition issue
Dear all, I am running R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 Under Mac os X, a french version! I am preparing a package and I got the following issue I am trying to read dates that are written in english and have them recognized by R using as.Date function. I realized strangely that when I type > month.abb [1]
2017 Apr 12
3
"table(droplevels(aq)$Month)" in manual page of droplevels
The last line of the example in droplevels' manual page seems to be incorrect to me. I think it should read: "table(droplevels(aq$Month))". Amazingly (I don't understand) both variants seem to produce the same result (R 3.3.3): --- > aq <- transform(airquality, Month = factor(Month, labels = month.abb[5:9])) > aq <- subset(aq, Month != "Jul") >
2011 Dec 05
3
Plotting Time Series Data by Month
Hi, I have a dataset which includes monthly data for 17 years. I want to be able to see the monthly data behavior for the period of all 17 years. What my data looks like: http://r.789695.n4.nabble.com/file/n4162534/data.jpg I would like to represent the data in a graph such as the one below: http://r.789695.n4.nabble.com/file/n4162534/Untitled-2.jpg Any help would be appreciated. Thanks!
2009 Aug 20
4
expanding 1:12 months to Jan:Dec
Dear R users I would like to do some spreadsheet style expansion of dates. For example, I would need to obtain a vector of months. I approached in an obviously wrong way: > paste(01:12) [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" > as.Date(paste(01:12),
2008 Apr 25
4
Constructing dummy variables for months for a time series object
I have a TS of monthly observations. head(data4) 1991(1) 1991(2) 1991(3) 1991(4) 1991(5) 1991(6) 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488 Now I want to make 11 dummy variables indicating months. Therefore I did followings : For Jan : rep(c(rep(0,0), 1, rep(0, 11)), 17) For Feb : rep(c(rep(0,1), 1, rep(0, 10)), 17) ........ and so on But my
2015 Nov 22
2
[lld] R_MIPS_HI16 / R_MIPS_LO16 calculation
On Sun, Nov 22, 2015 at 1:28 AM, Rui Ueyama <ruiu at google.com> wrote: > I'm not sure if I understand the semantics of HI16 and LO16 relocations. If > my understanding is correct, a pair of HI16 and LO16 represents an addend > AHL. AHL is computed by (AHI<<16) | (ALO&0xFFFF). Can't we apply HI16 and > LO16 relocations separately and produce the same relocation