Displaying 20 results from an estimated 100000 matches similar to: "Dataframe calculations"
2010 Apr 20
5
Assigning Week Numbers
R experts,
How could I extract the week number from a date vector (in Date class)
such that week numbering (week 1...2...) begins (May 01) and ends
(October 31) on the same specific dates each year? Week numbering
must conform to the following day numbering format (Sat=1,Sun=2,Mon=3.....Fri=7).
This means that new weeks must begin on Saturdays, and end on Fridays
(except for the first date
2010 Mar 18
2
Dataframe manipulation
Hello R users,
I spent most of my workday yesterday trying unsuccessfully to
write code that will perform a series of calculations on my
dataframe (partial copy is attached). What I need to do is
multiply the 24 hr time in the 'DEPART' column by the time
(in the 'TRAVEL' column (travel time in minutes), and store this
result in the 'ARRIVE' column for the following
2010 Aug 13
1
assign multiple variables at once
R Experts,
I would like to create a series of variables without having
to assign a separate line of code for each new variable. My dataframe (DF) contains
two groups of linked variables (ESP1:ESP9) and (ECRL1:ECRL9). Within ESP1:ESP9 are
abbreviated species codes (full dataframe contains 26 codes). ECRL1 represents the
number of species x in variable ESP1 harvested, and so on through ESP9 and
2011 Jun 14
0
sqlFetch and factor conversion
R users,
Hello, I used sqlFetch to import a data table from MS Access 2007 and I set as.is = TRUE to
prevent character vectors from becoming factors. However, I can't figure out how to prevent
the $ operator from being added by sqlFetch to the end of each character vector(e.g. TD$ and SITE$).
This causes subsequent parts of my code not to work and also results in some behavior that I
2013 Apr 11
1
Dotchart per groups
Hi all,
I would like to ask you for help. I did a dotplot - using dotchart
function.
There are two localites (loc) with values 75 or 56 in my data ZZ.
The f column has 4 levels: P1, S1, S8, R6.
The dataframe is ordered by N value, pchloc value is assign to use "pch" in
plot.
> head(ZZ)
loc f N color ordered pchloc
98 75 S1 6.39 green 1 16
99 75 S8 6.44 blue
2010 Mar 05
2
How to assign week numbers to a time-series
Hello everyone,
My progress has stalled on finding a way of creating a somewhat complicated variable to add to my existing dataframe and I am hoping one of you could help me out. The dataframe below contains only a fraction of the data of my complete dataframe, but all of the variables. What I want to do is add another variable named 'WEEK' to this dataframe that is assigned 1 for row 1
2011 Feb 17
0
Data frame sampling
R users,
I have been trying to write a program in R that will extract rows from a data frame and combine the rows
into a new smaller data frame while meeting several criteria. I would greatly appreciate any advice
that could help me get started down the right path. What I want to do is to extract two rows WEEK
(26 weeks total) from the data frame by sampling without replacement from the
2013 Feb 27
2
matrix multiplication
Hi,
Try this:
#mat1 is the data
res<-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) {new1<-do.call(rbind,lapply(seq_len(nrow(mat1[-i,])),function(j) {x1<-rbind(mat1[i,],mat1[j,]); x2<-(abs(x1[1,1]-x1[2,1])*abs(x1[1,5]-x1[2,5]))+(abs(x1[1,2]-x1[2,2])*abs(x1[1,6]-x1[2,6]))+(abs(x1[1,3]-x1[2,3])*abs(x1[1,7]-x1[2,7]))+(abs(x1[1,4]-x1[2,4])*abs(x1[1,8]-x1[2,8]))}));new1}))
2008 Feb 08
1
Can I index a dataframe with a reference from/to a second dataframe?
Hello,
I am unable to figure out how to code a new column in a data frame based
on an existing column that matches a column in a reference data frame,
in a relational-db fashion. I would like this to maintain a minimum set
of reference tables that may be reused over several similar datasets.
Specifically, I have two data frames as listed below, 'Bos' and 'tree.'
For each case in
2011 Jul 31
3
export/import matrix
Hello
I have a problem on keeping the format when I export a matrix file with the write.table() function.
When I import the data volcano from rgl package it looks like this in R:
> data[1:5,]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] 100 100 101 101 101 101 101 100 100 100 101 101 102 102
[2,] 101 101 102 102 102 102 102
2013 Jan 03
2
Sas by function in R
Hello,
It's an alternative to use SAS by function in R?
I want to plot d histograms by plot.from example bellow:
Thank you!
plot d
1 1 16.3
2 1 25.0
3 1 57.8
4 1 17.0
5 2 10.8
13 2 96.4
17 3 76.0
18 3 32.0
19 3 11.0
20 3 11.0
24 3 106.0
25 3 12.5
21 4 19.3
22 4 12.0
26 4 15.0
27 5 99.3
32 7 11.0
36
2009 May 28
2
ggplot2 legend
Hi:
I need some help with the legend. I got 14 samples(Muestreo) and I
am trying to plot a smooth line for each sample. I am able to accomplish that but the problem is that the legend only displays every other sample. How can I force the legend to show all of my Muestreos? Thanks in advance.
fish_ByMuestreo <- structure(list(data = structure(list(SampleDate = structure(c(3L,
3L, 3L, 3L,
2013 Mar 29
1
Create values based on a table of conditions
Hi R help forum,
I have a simple data frame of four columns - one of numbers (really a
categorical variable), one of dates and one
of data. I have over 500,000 data points to work with, spread over 40
files, each named after a different animal.
These are contact data recorded by proximity loggers over two years
between the animals of the file name and
collars being worn by other animals. The
2012 Nov 05
2
fusion of overlapping intervals
Hello,
I have start and end coordinates from different experiments (DNase
hypersensitivity data) and now I would like to combine overlapping
intervals. For instance (see my test data below) (2) 30-52 and (3) 49-101
are combined to 30-101. But 49-101 and 70-103 would not be combined because
they are on different chromosomes (chr a and chr b).
Does anybody have an idea?
Thanks
Hermann
> df
2011 Jul 27
1
create a index.date column
Dear
R users,
I
created a matrix that tells me the first day of use of a category by
id.
#Calculate
time difference
test$tdiff<-as.numeric(difftime(as.Date("2002-09-01"), test$ftime, units = "days"))
#
obtain the index date per person and dcategory
index.date.test<-tapply(test$tdiff,
list(test$id, test$rcat), max)
Nonetheless,
at the moment I think will be
2012 Oct 29
4
replace repeated id in a pedigree list
Hello,
I have a pedigree file such this:
FAMID ID FA ID MO ID SEX STATUS
1 1 0 0 2 0
1 2 3 1 2 2
1 4 3 1 1 2
1 5 3 1 1 0
1 6 3 1 1 0
1 7 3 1 2 2
1 8 3 1 1 0
1 9 3 1 1 0
1 10 3 1 2 0
1 11 3 1 1 0
1 3 0 0 1 0
2 12 13
2012 Jun 22
1
Plotting linear fit
I am trying to plot the linear fit by id of the following data (test.l):
id year incidents
100 1 0
101 1 1
102 1 21
103 1 27
104 1 3
105 1 12
100 2 5
101 2 5
102 2 19
103 2 10
104 2 2
105 2 12
100 3 0
101 3 0
102 3 22
103 3 14
104
2013 Oct 19
3
bold dot size and name in plot
Dear useRs,
I have the following data "z" of two variables "x"(z[,1]) and "y"(z[,2]).
> dput(z)
structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
2004 May 05
1
Limit filters
it is posible to do more than 2048 filter rules and classes like this:
/sbin/tc class add dev eth1 parent 1:15 classid 1:101 htb rate 1kbit ceil 6128kbit prio 1 quantum 1500
/sbin/tc filter add dev eth1 protocol ip pref 0 parent 1: u32 match ip dst 10.10.24.17 flowid 1:101
/sbin/tc qdisc add dev eth1 parent 1:101 handle 101: sfq
/sbin/tc class add dev eth1
2004 Oct 06
8
Dataframe manipulation question
Hello,
I have a data frame that has three fields.
Resp# ActCode ProdUsed
100 3 2
100 3 2
100 4 3
100 4 3
101 3 6
102 2 1
102 3 1
103 5 1
103 5 1
103