similar to: dataframe manipulation

Displaying 20 results from an estimated 20000 matches similar to: "dataframe manipulation"

2006 Oct 11
1
panel-dependent distribution in qqmath
In qqmath, how would one go about having 'distribution' change with panel.number? I've tried set.seed(1) mydata <- data.frame(ind = factor(rep(2:4, each = 100))) mydata$val <- rt(300, df=rep(2:4, each = 100)) plot<-qqmath(~ val | ind, layout=c(3,1), data = mydata, prepanel = function(x, distribution, ...) {
1999 Apr 07
1
library
I also have several packages in my RW0633 in Windoze and I would like to keep them in one place when I update the R system. Brian say to modify Rprofile to ..lib.loc <- c("c:/MyR/library",.Library) now Rprofile has a line like .lib.loc <- unique(c(unlist(strsplit(getenv("RLIBS"),":")),.Library) Sorry to be dense but where should I put the
2001 Sep 13
1
row-wise dataframe calculation
Hi, i have a dataframe such as: Exp1 Exp2 Exp3 name1 12.6 78.0 45.6 name2 11.9 19.0 21.0 name3 10.0 14.0 17.0 ... ... ... Real datasets might be quite large - 20,000 rows by 100 columns I want to calculate metrics such as the variation *row-wise*. So, var for name1, var for name 2, var for name3 etc. Can someone kindly guide me on how best to code this? Also, once such a metric has
2006 Dec 26
2
sequential row selection in dataframe
Dear all; I'm wondering if there is any 'efficient' approach for selecting a sample of 'every nth rows' from a dataframe. For example, let's use the dataframe GAGurine in MASS library: > length(GAGurine[,1]) [1] 314 # select an 75% of the dataset, i.e. = 236 rows, every 2 rows starting from row 1 > test<-GAGurine[seq(1,314,2),] > length(test[,1]) [1] 157 #
2013 Feb 11
2
Inserting rows of interpolated data
Dear help list - I have light data with 5-min time-stamps. I would like to insert four 1-min time-stamps between each row and interpolate the light data on each new row. To do this I have come up with the following code: lightdata <- read.table("Test_light_data.csv", header = TRUE, sep = ",") # read data file into object "lightdata" library(chron) mins <-
2009 Feb 17
1
using sapply to apply function to some columns of a dataframe
Hello: I would like to sum every x columns of a dataframe for each row. For instance, if x is 10, then for dataframe df, this function will sum the first ten elements together and then the next ten: sapply(list(colnames(df)[1:10], colnames(df)[11:20]),function(x)apply( df[,x], 1, sum)) If the number of columns is quite large (1000's), then manually entering the list above is not practical.
2009 Sep 19
3
Replacing values in dataframes
Hi, This is a question of a newbie getting into the exciting world of R. I have several dataframes in the same format as NAD: > NAD[1:3,1:3] Sample.Id Main.abs..1 Main.abs..2 148 10a 0.04836 0.04994 167 11a_1109 0.32245 0.36541 173 11b_1109 0.29293 0.32815 What I want to do is to replace the Sample.Id with a corresponding number.The number
2005 Apr 05
4
lists: removing elements, iterating over elements,
I'm writing R code to calculate Hierarchical Social Entropy, a diversity index that Tucker Balch proposed. One article on this was published in Autonomous Robots in 2000. You can find that and others through his web page at Georgia Tech. http://www.cc.gatech.edu/~tucker/index2.html While I work on this, I realize (again) that I'm a C programmer masquerading in R, and its really
2013 Mar 29
1
Dataframe manipulation
Hi Adam, I hope this is what you wanted: dat1<- read.csv("example.csv",sep="\t",stringsAsFactors=FALSE) ?str(dat1) #'data.frame':??? 102 obs. of? 5 variables: # $ species? : chr? "B. barbastrellus" "E. nilssonii" "H. savii" "M. alcathoe" ... # $ period?? : chr? "dusk" "dusk" "dusk"
2009 May 10
1
Select the rows in a dataframe that matches a criteria in another dataframe
Hi everyone! Thank you for the help you have been given to me, and here I'm with another problem with my dataframes: I have two dataframes (with much more observations), like these: Dataframe1 Firm Year cash 500400200 2007 100 500400200 2006 200 500400200 2005 400 500400300 2007 300 500400300 2006 240 500400300 2005 120 500400400
2007 May 14
2
creating a "list of 3 dataframes" from a "list of 2 dataframes" and a dataframe?
#I wish to create a "list of three dataframes" ("results2") from a "list of two dataframes" (temp) and a dataframe ("c")? #Please advise. a <- data.frame(x=c(1,2,3),y=c(5,7,9)) b <- data.frame(x=c(2,4,7,9),y=c(2,3,5,4)) c <- data.frame(x=c(22,34,7,9),y=c(52,63,5,4)) results1 <- list(a,b,c) #what I want #but this is how I need to get there
2009 Mar 21
2
Creating dataframe names on the fly?
I am aware that it is easily possible to create var names on the fly. e.g. assign(paste("m",i,sep=""),j) but is it possible to assign dataframes to variables created on the fly? e.g. If I have a dataframe called master and I wanted to subset parts of those data into separate dataframes, I could do: m1=subset(master,master$SAMPLE=='1')
2007 Oct 22
3
median value dataframe coming from multiple dataframes
Hi all, I am not a skillful R programmer and has I am handling with large dataframes (about 30000 x 300) I am in need of an efficient function. I have 4 dataframes with the same dimension. I need to generate other dataframe with the some dimension than the others where in each position it has the median value of the 4 values in the same position coming from the 4 dataframes. Grateful by your
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
2011 May 29
1
Oddity: I seem to have a variable in a dataframe that doesn't show in colnames() - can anyone advise?
I may be being dopey, I surely am, but I'm baffled by this. I've been working, on and off for a few days in R version 2.13.0 (2011-04-13) i386-pc-mingw32/i386 (32-bit) working it through ESS. I've got a dataframe created a couple of days back, during the session: > dim(AllDat) [1] 27270 94 I came back this morning and misremembered my variables and thought I had a variable
2010 Mar 26
4
Competing with SPSS and SAS: improving code that loops through rows (data manipulation)
Dear R-ers, In my question there are no statistics involved - it's all about data manipulation in R. I am trying to write a code that should replace what's currently being done in SAS and SPSS. Or, at least, I am trying to show to my colleagues R is not much worse than SAS/SPSS for the task at hand. I've written a code that works but it's too slow. Probably because it's
2003 May 18
1
How to split a dataframe into smaller constituent dataframes
I have read a large dataset into a dataframe using RODBC, the rows of data in the dataframe are (integer) timestamped and I would like to divide the original dataframe into n smaller dataframes where dataframe 1 contains all rows that had timestamps falling in the period 0-x1 minutes, dataframe 2 contains all rows that had timestamps falling between x1+1 and x2, etc.. Does anyone know how to
2002 Apr 30
2
display of character NA's in a dataframe in 1.5.0
I understand that NA's in character vectors are displayed differently than NA's in factor vectors. > c("x", NA, "y") [1] "x" NA "y" > as.factor(c("x", NA, "y")) [1] x <NA> y Levels: x y That seems sensible enough. But shouldn't I see the same behavior in a dataframe? > test <- data.frame(a =
2012 Feb 08
2
Split dataframe into new dataframes
Hi, I want to split a dataframe based on a grouping variable (in one column). The resulting new dataframes should be stored in a new variable. I tried to split the dataframe using split() and to store it using a FOR loop, but thats not working so far: df <- data.frame(A=c("A1","A1","A2","A2"),B=seq(1:4)) Fsplit <- function(x,y){ ls <-
2012 Jul 19
2
problem with using apply for dataframe
Dear people, I am including an example of a dataframe: mydataframe<-data.frame(X=c(1:4),total_bill=c(16.99,10.34,21.01,23.68),tip=c(1.01,1.66,3.50,3.31),sex=c("Male","Male","Male","Female")) When I use the sapply function getting the information about the factors works: sapply(mydataframe,function(x)is.factor(x)) X total_bill tip