similar to: Summing data frame columns on identical data

Displaying 20 results from an estimated 110 matches similar to: "Summing data frame columns on identical data"

2010 Jan 22
1
Looping multiple dimensions
Dear all, I have 30 arrays, each with dimensions 720,360,12. The naming format for each of these 30 objects is: mrunoff_5221, mrunoff_5222... mrunoff_5250. For example: > str(mrunoff_5221) ? num [1:720, 1:360, 1:12] NA NA NA NA NA NA NA NA NA NA ...? (the initial NA's are nothing to worry about) I am looking for a way by which I can extract each of the third dimension of these grids
2010 Jul 10
3
a very particular plot
Hi all, Thanks for the really great help I've received on this board in the past. I have a very particular graph that I'm trying to plot, and I'm not really sure how to do it. I think I should be able to use ggplot for this, but I'm not really sure how. I have a data.frame which contains fifty sub frames containing one hundred data points each. I can do a histogram of each of
2013 Nov 01
1
Package(s) for making waffle plot-like figures?
Dear all, I am trying to make a series of waffle plot-like figures for my data to visualize the ratios of amino acid residues at each position. For each one of 37 positions, there may be one to four different amino acid residues. So the data consist of the positions, what residues are there, and the ratios of residues. The ratios of residues at a position add up to 100, or close to 100 (more on
2007 Sep 21
1
Help create a loopto conduct multiple pairwise operations
#Hello, #I have three data frames, X,Y and Z with two columns each and different numbers of rows. # creation of data frame X X.alleles <- c(1,5,6,7,8) X.Freq <- c(0.35, 0.15, 0.05 , 0.10, 0.35) Loc1 <- cbind( X.alleles,X.Freq) X <- data.frame(Loc1) #creation of data frame Y Y.alleles <- c(1,4,6,8) Y.Freq <- c(0.35, 0.35, 0.10, 0.20 )
2011 Feb 25
1
data.frame operations
Hi All, I've been doing circles with this all morning, although I'm sure there's a simple solution. I have a data.frame "pop" as follows: > pop ind xloc yloc gonad 1 1 5 2 12 2 1 5 4 25 3 1 3 3 30 4 1 5 4 10 5 1 1 4 08 . . . . . 10 1 1 4 11 And I need the following steps: 1. Sum
2011 Jul 27
2
Writing a summary file in R
Hello, I have an input file: http://r.789695.n4.nabble.com/file/n3700031/testOut.txt testOut.txt where col 1 is chromosome, column2 is start of region, column 3 is end of region, column 4 and 5 is base position, column 6 is total reads, column 7 is methylation data, and column 8 is the strand. I would like a summary output file such as:
2006 Dec 01
3
Make many barplot into one plot
Dear all, ## I have 4 tables like this: satu <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4), dimnames=list(c("Negative", "Positive"), c("Black", "Brown", "Red", "Blond"))) dua <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4), dimnames=list(c("Negative", "Positive"),
2007 Jun 11
1
Gini coefficient in R
If I use the Ineq library and the Gini function in this way: >Gini(c(100,0,0,0)) I obtain the result 0.75 instead of 1 (that is the perfect inequality). I think Gini's formula in Ineq is based on a formula as reported here: http://mathworld.wolfram.com/GiniCoefficient.html but in the case of perfect inequality: x_1=.......=x_n-1 =0 x_n>0 these formula are equal to 1 - 1/n, not to
2009 Nov 02
1
Using processed objects as arguments of a function
Dear R users, I wish to utilise processed and saved objects as arguments of a function. Specifically, I have created objects using *"assign"* & *"paste"* functions with an incremental index i, the names of the objects are: fund1, fund2, fund3,....., fund80,..... (where the numerical value increments according to the index i & class of these objects are
2012 Jun 14
1
merge many files together using R
I have hundreds of text files which has data like a data frame with three columns.The column names are same in all the files.I need to merge all files into a single big file. My files are like this file1 "new.col" "ppm.p." "freq.p." "1_3_diaminopropane" 3.13859 5.67516 "1_3_diaminopropane" 3.137 6.65388 "1_3_diaminopropane" 3.13541 8.0142
2016 Apr 14
3
Unequal column lengths
Hello, I?ve tried several times to learn R, but have never gotten past a particular gate. My data are organized by column in Excel, with column headers in the first row. The columns are of unequal lengths. I export them as CSV, then import the CSV file into R. I wish to summarize the data by column. R inserts NA for missing values, then refuses to operate on columns with NA. R is importing
2010 Jan 02
3
Help needed on applying a function across different data sets and aggregating the results into a single data set
Hi folks, Wish y'all a Happy New Year 2010! I need some help with the following: Say I have lots of data sets, on which I have to apply a certain function on the same set of columns in each of the data set. Let's take, for ex, the typical data set is: df1 <- as.data.frame(cbind(rnorm(10),rnorm(10))) names(df1)[1] <- "A" names(df1)[2] <- "B" There are many
2018 May 10
2
using for loop with data frames.
Hi, Is it possible use a loop to process many data frames in the same way? For example, if I have three data frames, all with same variables df_bs_id1 <- read.csv("test1.csv",header =TRUE) df_bs_id2 <- read.csv("test2.csv",header =TRUE) df_bs_id3 <- read.csv("test3.csv",header =TRUE) How could I would implement a code loop that , for instance, would
2012 Jul 20
3
Crosstab with Average and Count
I have the following data: x <- as.factor(c(1,1,1,2,2,2,3,3,3)) y <- as.factor(c(10,10,10,20,20,20,30,30,30)) z <- c(100,100,NA,200,200,200,300,300,300) I could create the cross tab of x and y with Sum of z as its elements using the xtabs function as follows: # X Vs. Y with Sum Z xtabs(z ~ x + y) y x 10 20 30 1 200 0 0 2 0 600 0 3 0 0 900 How do I replace
2012 Jul 27
4
why order doesn't work?
hi all, I want to get a cumsum according to the order of some variable. However, it doesnt' work. For example, ********************** test<-data.frame(cbind(x=c(3,5,2,6,7),y=c(8,1,4,9,0))) test[order(test$x),]$sumy<-cumsum(test[order(test$x),]$y) ********************** R complians Warning message: In `[<-.data.frame`(`*tmp*`, order(test$x), , value = list(x = c(2, : provided 3
2009 Mar 21
5
macro in a loop
Hi there, Thanks for your time in advance. I am trying to read in multiple files. For example, data.1940 <- read.table("c:/data/1940.csv",header=TRUE,sep=",") data.1950 <- read.table("c:/data/1950.csv",header=TRUE,sep=",") data.1960 <- read.table("c:/data/1960.csv",header=TRUE,sep=",") How can I write a loop to read the
2003 Feb 21
2
how to chage values in data frame to NA iside a function
Dear all I have a function in which I would like to change some values to NA according to some condition. dropout<-function(y, nahr=FALSE,...) { <some stuff for computing an index> if (nahr) y[index]<<-NA invisible(index) } in case y is a vector all works OK but if it is a part of data frame by calling dropout(df$y) or dropout(df[,number]) no change is done. Please can you
2009 Aug 28
2
new data.frame summed by date
Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, "%Y%m%d")
2018 Jan 18
0
Web scraping different levels of a website
I am web scraping a page at http://catalog.ihsn.org/index.php/catalog#_r=&collection=&country=&dtype=&from=1890&page=1&ps=100&sid=&sk=&sort_by=nation&sort_order=&to=2017&topic=&view=s&vk= From this url, I have built up a dataframe through the following code: dflist <- map(.x = 1:417, .f = function(x) { Sys.sleep(5) url <-
2010 Nov 15
2
Zero truncated Poisson distribution & R2WinBUGS
I am using a binomial mixture model to estimate abundance (N) and detection probability (p) using simulated count data: -Each site has a simulated abundance that follow a Poisson distribution with lambda = 5 -There are 200 simulated sampled sites -3 repeated counts at each site - only 50 percent of the animals are counted during each count (i.e, detection probability p =0.5, see codes) We removed