similar to: Adding a row at top of dataframe

Displaying 20 results from an estimated 10000 matches similar to: "Adding a row at top of dataframe"

2010 Dec 16
2
Compare two dataframes
Hello, I have two dataframes DF1 and DF2 that should be identical but are not (DF1 has some rows that aren't in DF2, and vice versa). I would like to produce a new dataframe DF3 containing rows in DF1 that aren't in DF2 (and similarly DF4 would contain rows in DF2 that aren't in DF1). I have a solution for this problem (see self contained example below) but it's awkward and
2010 May 13
2
Adding name to nth row
Hello, I have a data frame with many rows, and I want to create a column with a name only at every 12th row, starting from 97 to 278. Thanks in advance!
2010 May 26
2
How to calculate mean of means
I have 3 columns of numbers, and i want to find the mean of each separately, and then the mean of all of the means. ive tried: av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3)) av3daysB but it only gives me the mean of the first column (avr1) Any suggestions? Thanks, Emilija
2010 May 28
2
if negative value, make zero
I have a data frame with both positive and negative values, and I want to make all the negative values equal zero, so i can eventually take an average. I've tried temp2 <- ifelse(tempr<0, 0, tempr) but it doesn't seem to work. Any suggestions? Thanks!
2010 Jun 09
1
[R-sig-Geo] How to extract coordinates values from a shapefile?
I'm not sure if this is what you want. But the function coordinates() in sp package gives you the coordinates of SpatialObjects. Regards. Rodrigo. 2010/6/9 Nikhil Kaza <nikhil.list@gmail.com> > You need to execute gpclibPermit() to enable gpclib. > > library(maptools) should have issued a warning to that effect. > > > Nikhil Kaza > Asst. Professor, > City and
2010 May 04
1
Extract rows with non-zero elements
Dear all, In my dataset I have 12 columns and 5824 rows. The second column contains information about the height of a claim: it might be zero or positive. I would like to do an analysis on the positive part of this matrix, but I do need the other colums with this. So if there are like 1000 rows where the second column is positive, I would like to extract this 1000x13 matrix into another matrix.
2010 Jun 21
2
Calculating a daily average
I have a set of data with 12 readings for temperature per day, with 180 days. I want to find the average temperature of each day. I am able to do this one by one, but with that many days to calculate the average for, it will get very long. I'm sure there is a faster way to do this, I just don't know how. What i have so far is: av1 <- subset(ER9r, Day == 98, select = c
2010 Jul 19
2
replacing elements of distance matrix
Hi! I am trying to implement non-bipartite matching. I have around 500 sites which can be clustered by 10 regions. I am able to calculate pairwise Mahalanobis distances between sites (thanks to another post in the forum). However, I want to constrain my match to sites within the same region. Thus I want to replace elements of the distance matrix with a high value, say 999999, for sites not of the
2010 Aug 03
4
Need help on upper.tri()
HI, I am really messing up to make a symmetrical matrix using upper.tri() & lower.tri() function. Here is my code:   > set.seed(1) > mat = matrix(rnorm(25), 5, 5) > mat            [,1]       [,2]       [,3]        [,4]        [,5] [1,] -0.6264538 -0.8204684  1.5117812 -0.04493361  0.91897737 [2,]  0.1836433  0.4874291  0.3898432 -0.01619026  0.78213630 [3,] -0.8356286  0.7383247
2010 Jun 20
3
Spatial: number of independent components?
Hi all, I am sorry if this is a very basic quesion, but I have no experience with analyzing spatial data and could not find the right function/package quickly. Any hints would be much appreciated. I have a matrix of spatial point patterns like the one below and want to find the number of independent components (if that's the right term) in that matrix (or in that image). x=matrix(c(0,1,0,0,0,
2010 Jun 28
1
Subtraction loop
I have a data frame with 2 columns, one for day and one for average. The day starts at 97 all the way to 279. I want to subtract day 98 average- day 97 average, then day99 average -day 98 average and so on down my list, creating another column with the subtracted results. I have: Day DailyAverage 1 97 0.6076782 2 98 0.7121478 3 99 0.8059347 4 100 0.9545806 5
2009 Oct 22
1
Recode issue
I am having trouble with the recode function that is provided in the CAR package. I trying to create a new factors based on existing factors. E.g. >x <- as.factor(1:20) >y <- recode(x, " 1:5='A'; 6:10='B'; 11:15='C'; 16:20='D' ") >y [1] A A A A A 6 7 8 9 A A A A A A A A A A A Levels: 6 7 8 9 A Could someone point to me, my error?
2009 Nov 06
2
another question: how to delete one of columes in two ones with high correlation(0.95)
my programe is below: a=c(1,2,1,1,1); b=c(1,2,3,4,1); c=c(3,4,3,3,3); d=c(1,2,3,5,1); e=c(1,5,3,5,1) data.f=data.frame(a,b,c,d,e) origin.data<-data.f cor.matrix<-cor(origin.data) origin.cor<-cor.matrix m<-0 for(i in 1:(cor.matrix[1]-1)) { for(j in (i+1):(cor.matrix[2])) { if (cor.matrix[i,j]>=0.95) { data.f<-data.f[,-i]; i<-i+1 }
2010 Jul 28
2
Beginner stucked with raster + geoR package.
Hello everyone. I am trying to build up understanding in R by trying to develop just some simple scenarios. I would like to explain you what I am trying to do and what I did so far. I would like to put inside a RasterLayer (raster package) a Gaussian field (for given covariance) using grf function (geoR package) 1. First I created a Raster Layer object r <- raster() # Default values are
2010 Jul 13
1
Batch file export
Dear all, I have a code that generates data vectors within R. For example assume: z <- rlnorm(1000, meanlog = 0, sdlog = 1) Every time a vector has been generated I would like to export it into a csv file. So my idea is something as follows: for (i in 1:100) { z <- rlnorm(1000, meanlog = 0, sdlog = 1) write.csv(z, "c:/z_i.csv") Where "z_i.csv" is a filename that is
2010 Oct 20
1
help identifying clusters
Dear list: I have a dataset of geographical data that looks like this example data: dat<- data.frame( lon = c(rnorm(1000, mean=-10), rnorm(1000, mean=10), rnorm(1000, mean=5)), lat = c(rnorm(1000, mean=40), rnorm(1000, mean=30), rnorm(1000, mean=0))) plot(dat$lon, dat$lat) My positions are clearly clustered (in this example there are 3 clusters). Is there any R algorithm that allows me to
2010 Jul 25
1
Left Outer Join 2 DF's on Multiple Conditions
Hi, I am trying to execute the following SQL statement using two data frames: tab1, tab2 : Two Tables Select tab1.*, tab2.*, tab1.tobiiTime - tab2.ruiTime as timeDiff, IFNULL(n-m, -9999999) as alwaysIncrement FROM tab1 LEFT OUTER JOIN tab2 On tab1.data1 - tab2.mouseX = 0 And tab1.data2 - tab2.mouseY = 0 I am trying to do the following in R:- *#Getting error here:* data
2010 Jul 22
1
Updating a Data Frame
Hi, I have a global data-frame in my R script. At some point in my script, I want to update certain columns of this data-frame by calling in an update function. The function looks like this: # get events data. This populates a global event data frame in the R-script events <- getEvents(con, eventsFilePath) # events has columns eventid, timeStamp, isSynchronized, timeDiff; with millions of
2010 Aug 09
2
efficient matrix element comparison
It is a simple problem in that I simply want to convert the For loop to a more efficient method. It simply loops through a large vector checking if the numeric element is not equal to the index of that element. The following example demonstrates a simplified example: > rows <- 10 > collusionM <- Matrix(0,10,10,sparse=TRUE) > matchM <- matrix(c(1,2,3,4,4,6,7,9,9,10)) > >
2010 Jul 07
1
Batch files process and String parsing
Here are what i am going to accomplish: I have 400 files named as xxx.txt. the content of the file looks like the following: name count 1. aaa 100 2. bbb 2000 3. ccc 300 4. ddd 3000 ........ more that 1000 rows in each files. these are the areas i need help: 1. how can i only read in the files with the string patterns ggg or fff as part of the file names? for instance, I