similar to: using "table" in R

Displaying 20 results from an estimated 40000 matches similar to: "using "table" in R"

2009 Dec 17
2
Problem with spliting a dataframe values
Hi all, Hi this is kiran I am facing a problem to split a dataframe that is.. i have a string like: "a,b,c|1,2,3|4,5,6|7,8,8" first I have to split with respect to "|" I did it with command unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,")) after getting that set i made it as a dataframe and it comes like a,b,c 1,2,3 4,5,6 7,8,8 now i have to
2010 Dec 29
2
subset question
Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column "gene" stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the
2012 Jun 07
1
Relative frequencies in table
Hi, I'm trying to create a stacked bar plot with the satisfaction scores from a customer satisfaction survey. I have results for three stores over several weeks and want to create a weekly graph with a stacked bar for each store. I can flatten the dataframe into a table with absolute frequencies, but I can't find how to get relative frequencies. My dataset looks similar to the example
2006 Aug 22
1
Selection on dataframe based on order of rows
I have a dataframe with the following structure id date value ------------------------- 1 22/08/2006 48 1 24/08/2006 50 1 28/08/2006 150 1 30/08/2006 100 1 01/09/2006 30 2 11/08/2006 30 2 22/08/2006 100 2 28/08/2006 11 2 02/09/2006 5 3 01/07/2006 3 3 01/08/2006 100 3 01/09/2006 100 4 22/08/2006
2007 Mar 05
1
Matrix/dataframe indexing
Hi all, I am hoping someone can help me out with this: If I have dataframe of years and ages and the first column and first row are filled with leading values: Df<- age1 age2 age3 Yr1 1 0.4 0.16 Yr2 1.5 0 0 Yr3 0.9 0 0 Yr4 1 0 0 Yr5 1.2 0 0 Yr6 1.4 0 0 Yr7 0.8 0 0 Yr8 0.6 0 0 Yr9 1.1 0 0 Now the rest of the cells need to be filled according to the previous year and age
2010 Nov 24
3
apply over list of data.frames
R users, This probably involves a simple incantation of one of the flavors of apply... that I can't yet figure out. Consider a list of data frames. I'd like to apply a function (mean) across the list and return a dataframe of the same dimensions where each cell represents the mean of that cell across all dataframes. # set up the list x <- vector("list",2) names(x) <-
2013 Jan 11
3
Using table to get frequencies of several factors at once
Hi, I have a dataframe with n columns, but I am only looking at five of them. And lots of rows, over 700. So I would like to find frequencies for each of the numeric columns (variables) using the table function. However, is there a fast way to produce a frequency table where the 5 rows represent the 5 numeric variables and the columns refer to the values (levels) of the respective numeric
2012 Sep 06
2
How can I improve an ugly, dumb hack
Hi Folks: Here's the situation: > m <- cbind(x=letters[1:3], y = letters[4:6]) > m x y [1,] "a" "d" [2,] "b" "e" [3,] "c" "f" ## m is a 2 column character matrix > d <- data.frame(a=1:3,b=4:6) > d$c <- m > d a b c.x c.y 1 1 4 a d 2 2 5 b e 3 3 6 c f ## But please note (as was remarked
2010 May 31
1
Creating dropout time from longitudinal data with missing data
Dear R users,   Please assist me with the following problem. I have a dataset that looks like the following:   dat<-data.frame(   'id'=rep(c(1,2,3),each=3),   'time'=rep(c(1,2,3),3),   'y'= c(2,2,NA,2,NA,NA,2,5,7) )   I wish to create a variable for dropout time in dataframe 'dat' such that the dropout time is the time to drop out by the subject as follows:    
2006 Sep 18
2
merge strings
Hi all, I have a vector and want to merge its elements one by one into a single string or number. For example, x=c(1,2,3), what I want is a new number 123. I used "paste" but it just output "1" "2" "3" which is not what I want. Is there any way to do this? Thanks!
2016 Apr 27
3
Same sum, different sets of integers
Hi, Do you have ideas, how to find all those different combinations of integers (>0) that produce as a sum, a certain integer. i.e.: if that sum is 3, the possibilities are c(1,1,1), c(1,2), c(2,1) 4, the possibilities are c(1,1,1,1),c(1,1,2),c(1,2,1),c(2,1,1),c(2,2),c(1,3),c(3,1) etc. Best regards, Atte Tenkanen
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists: xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) ) xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site , FUN=function(z)yield[z])) I can convert xa to a dataframe easily with: as.data.frame(xa) But if i try the same with xb I get: as.data.frame(xb) Error in as.data.frame.default(xb) : can't coerce array into a data.frame What
2024 Nov 27
1
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
On 11/27/24 08:30, Sorkin, John wrote: > I am an old, long time SAS programmer. I need to produce R code that processes a dataframe in a manner that is equivalent to that produced by using a by statement in SAS and an if first.day statement and a retain statement: > > I want to take data (olddata) that looks like this > ID Day > 1 1 > 1 1 > 1 2 > 1 2 > 1 3 > 1 3 >
2008 Nov 06
3
unlist & dataframes
Dear all, I would like to know whether it is possible to unlist elements and keep the original format of the data. To make it more clear, let me give an exemple: I have a list l of dataframes that I created with apply but which looks like this: x1=data.frame(Name=LETTERS[1:2],Age=1:2) x2=data.frame(Name=LETTERS[3:4],Age=3:4) l=list(x1,x2) l [[1]] Name Age 1 A 1 2 B 2 [[2]] Name
2006 Nov 14
3
Creating a table
Dear R List, I am a new to R, so my question may be easy to answer for you: I have a dataframe, for example: df<-data.frame(loc=c("A","B","A","A","A"), year=as.numeric(c("1970","1970","1970","1976","1980"))) and I want to create the following table without using loops: 1970-74 ;
2011 Mar 19
2
persuade tabulate function to count NAs in a data frame
Hi, I'd like to ask you a question again. It is basically about data frames, NAs and tabulate function. I have this data frame. I already used this in one of the previous questions of mine. It intentionally looks this simple, my real 'df' dataframe is much bigger actually and again, I am not willing to annoy anyone with huge databases... So, my database: id
2005 Mar 28
2
Generating list of vector coordinates
Hi. Can anyone suggest a simple way to obtain in R a list of vector coordinates of the following form? The code below is Mathematica. In[5]:= Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2] Out[5]= {{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1 ,2,4},{1,2, 5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3}, {1,4,
2010 Oct 31
3
extracting named vector from dataframe
Suppose df is a dataframe with one named row of numeric observations. I want to coerce df into a named vector. as.vector does not work as I expected: as.vector(df) returns the original dataframe, while as.vector(df,mode="numeric") returns an unnamed vector of NAs. This works: > v <- as.numeric(as.matrix(df)); names(v) <- names(df); I just wanted check if there
2024 Nov 27
7
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
I am an old, long time SAS programmer. I need to produce R code that processes a dataframe in a manner that is equivalent to that produced by using a by statement in SAS and an if first.day statement and a retain statement: I want to take data (olddata) that looks like this ID Day 1 1 1 1 1 2 1 2 1 3 1 3 1 4 1 4 1 5 1 5 2 5 2 5 2 5 2 6 2 6 2 6 3 10 3 10 and make it look like this: (withing each
2007 Feb 19
2
Another subsetting enigma
Hello again, I'm trying to do the following: subset(dataframe,list %in% strsplit(dataframe[[Field]],",")) But This returns always the complete dataframe, since the strsplit(dataframe[[Field]],",") is evaluated as one big list for the whole data frame rather than one list per row. How can I have this evaluated on a per row basis? After 1.5 h hitting head against wall -