Displaying 20 results from an estimated 20000 matches similar to: "Help with dates and characters"
2010 Mar 23
2
Transform data set
Dear R Experts,
I am having some trouble creating a variable in R. I have data on
self-placement of voters, their placement of parties, and which party
they feel closest to. The data is structured like this:
Party_Close lrplaceself lrplaceParty1 lrplaceParty2 ...
party1 2 4 5
party2 5 6 4
party1 6 2 1
etc...
I want to format the data set so it looks like this:
Party_Close
2010 Jul 19
3
Reshaping data
Dear All,
I have some data in the following shape:
ID begin_t1 end_t1 begin_t2 end_t2
Thomas 11/03/04 13/05/06 04/02/07 16/05/08
... ... ... ... ...
Jens 24/01/02 23/05/03 07/06/03 14/11/05
I would like to reshape this data to have the following form:
ID Begin_Time End_Time
Thomas 11/03/04 13/05/06
Thomas 04/02/07 16/05/08
... ... ...
Jens 24/01/02 23/05/03
Jens
2010 Apr 23
3
Event History Data Recoding
Dear R list,
I have an event history data set that is structured like this:
Legislative act Discussion Agreement Time Event
Act1 2006-05-30 2006-06-19 20 1
Act2 2004-03-01 2004-06-14 105 1
.
.
.
I have information on the meetings in the legislature between adoption
periods in a separate variable (the
2010 Mar 29
5
Finding common an unique elements in character vectors
Dear R-list,
I have a problem which I think is quite basic, but so far google has not
helped me.
I have two vectors like this:
vector_1 <- c(Belgium, Spain, Greece, Ireland, Luxembourg, Netherlands,
Portugal)
vector_2 <- c(Denmark, Luxembourg)
I would like to find the elements in vector_1 that are not in vector_2
so that i get a vector with these countries: Belgium, Spain, Greece,
2017 Dec 28
3
Help with dates
Hi all,
I?m struggling to get the dates in proper format.
I have dates as factors and is in the form 02/27/34( 34 means 1934). If I use
as.Date with format %d%m%y it gets converted to 2034-02-27. I tried changing the origin in the as.Date command but nothing worked. Any help is appreciated.
Thanks,
Ramesh
2005 Apr 05
2
extract date
Dear all,
please, is there any possibility how to extract a date from data
which are like this:
....
"Date: Sat, 21 Feb 04 10:25:43 GMT"
"Date: 13 Feb 2004 13:54:22 -0600"
"Date: Fri, 20 Feb 2004 17:00:48 +0000"
"Date: Fri, 14 Jun 2002 16:22:27 -0400"
2020 Feb 15
2
Colocar objeto Dates dentro de un vector.
Hola,
Estoy encontrando un problema al intentar poner un objeto Dates en un
vector o dataframe.
Mi ejemplo
# preliminares
install.packages( lubridate ); library( lubridate )
v <- c(0, 0, 0)
original<-c(2019,308,1700, 25) # c(año, día del año, hora, temperatura)
esto sale así de un sensor de temperatura
# convertimos los datos originales en algo que entienda R
a <-
2010 Mar 30
2
Create a new variable
Dear R-list,
Sorry for spamming the list lately, I am just learning the more advanced
aspects of R!
I have some data that looks like this:
Out Country1 Country 2 Country 3 ... CountryN
1 1 1 1 1
0 1 1 0 1
1 1 0 1 0
I want to create a new variable that counts the number of zeros in every
row whenever Out is equal to 1, and else it is a zero, so it would look
like this:
new_var
0
0
2
I
2012 Jun 21
4
convert 'character' vector containing mixed formats to 'Date'
Dear all
I have a 'character' vector containing mixed formats (thanks Excel!)
and I'd like to translate it into a default "%Y-%m-%d" Date vector.
x <- c("1/3/2005", "13/04/2004", "2/5/2005", "2/5/2005", "7/5/2007",
"22/04/2004", "21/04/2005", "20080430", "13/05/2003",
2010 Feb 01
3
Convert a column of numbers to a column of strings
Hello,
Please excuse me if this question has been asked before. I'm new to R, and
have been trying to google the answers without any success.
I would like to convert a set of date and time into R date-time class. Right
now, the dates and times are in integer format, so I first need to convert
them into string, and then to R date-time using strptime. However, I have a
problem converting them
2020 Feb 17
2
Colocar objeto Dates dentro de un vector.
Carlos, muchas gracias, voy a probarlo.
Pero me sigue intrigando por que no puedo ponerlo como elemento de un
vector... Misterios del R. SI lo averiguo os lo digo.
Jaume.
El sáb., 15 feb. 2020 a las 19:08, Carlos Ortega (<cof en qualityexcellence.es>)
escribió:
> Hola,
>
> Una alternativa que te puede ayudar es enfocar el problema de esta otra
> forma.
> Puedes ir guardando
2010 Dec 10
2
Remove 100 years from a date object
Hello,
I have some data that has dates in the form 27.02.37. I convert them to
a date object as follows:
as.Date(data$date,format="%d.%m.%y")
But this gives me years such as 2037 when I would like them to be 1937.
I thought of trying to take off some time i.e.
as.Date(camCD$DoB,format="%d.%m.%y") - 100*365
But that doesn't seem to work out correctly. Any ideas how to
2010 Jan 20
1
Line Plot with Dates on X-axis
I am trying to generate a line graph with quarterly time buckets (with
nice labels) on the x-axis. The first block of code below will
generate the graph with nicely formatted x-axis labels, but the
"type=" and "col=" options are not recognized when factors are used
for the x-axis.
The second block, where the quarter values are mapped into dates, will
plot the line nicely but
2020 Feb 24
2
Colocar objeto Dates dentro de un vector.
Muchas gracias,
Probaré eso también y ya os cuento.
Jaume.
El lun., 17 feb. 2020 a las 22:10, Javier Marcuzzi (<
javier.ruben.marcuzzi en gmail.com>) escribió:
> Estimado Jaume Tormo
>
> En lo personal yo utilizo un enfoque como el que comenta Carlos Ortega, se
> me ocurre que posiblemente funcione si a su código le coloca algo de
> formato, me refiero a esta forma:
>
2007 Feb 01
3
Extracting part of date variable
Dear all,
Suppose I have a date variable:
c = "99/05/12"
I want to extract the parts of this date like month number, year and day. I can do it in SPSS. Is it possible to do this in R as well?
Rgd,
---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers
[[alternative HTML version deleted]]
2011 Sep 29
2
String manipulation with regexpr, got to be a better way
Help-Rs,
I'm doing some string manipulation in a file where I converted a string date in mm/dd/yyyy format and returned the date yyyy.
I've used regexpr (hat tip to Gabor G for a very nice earlier post on this function) in steps (I've un-nested the code and provided it and an example of what I did below. My question is: is there a more efficient way to do this. Specifically is
2004 Nov 08
2
Converting strings to date
Hello,
I have the following problem:
test is a data frame with 9 fields. The field test$Date is factorized with dates. The format is dd-mm-yyyy (using Oracle notation). I want to convert this to Date in '%Y-%m-%d format.
What I am doing is:
for (i in 1:nrow(test))
{
test[i,]$Data<-strptime(substring(test[i,]$Data,1,10),"%d-%m-%Y")
}
test is a data frame.
The error is:
2011 Mar 01
3
inefficient ifelse() ?
dear R experts---
t <- 1:30
f <- function(t) { cat("f for", t, "\n"); return(2*t) }
g <- function(t) { cat("g for", t, "\n"); return(3*t) }
s <- ifelse( t%%2==0, g(t), f(t))
shows that the ifelse function actually evaluates both f() and g() for
all values first, and presumably then just picks left or right results
based on t%%2.
2012 May 02
3
factor conversion to date/time
Hi, I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. I've tried as.Date, as.POSIXlt and strptime the problem is that the database has put a T between the numbers and R will not accept any conversions. currently it sees the date as a factor with the format as 1981-01-02T08:00I would like to keep only the year and month, but my
2001 Oct 30
2
creating chron object aggregates (e.g. sums by day)
What is the recommended/optimal way to perform aggregates on data frames
with chron objects?
Here is an example:
>raw.data
1 07/09/01 4000
2 07/09/01 2000
3 07/11/01 1000
4 07/13/01 800
5 07/13/01 700
6 07/16/01 600
7 07/17/01 500
I'm trying to construct a function that would first aggregate the data
(second column) by day (grouping by the first column) according to a