similar to: Relative subscripts?

Displaying 20 results from an estimated 60000 matches similar to: "Relative subscripts?"

2007 Apr 16
2
Histograms of lots of variables
Hi R-helpers, I wish to produce frequency histograms of all of the variables in my dataframe (except some identifying variables). I have tried >hist(dataframe[,3:20]) to produce histograms of the 3rd through 20th variables in my dataframe, but R doesn't like that. Could anyone provide a suggestion? Also, once I produce the histograms, I'd like to save them as graphic files on my
2007 May 10
1
how to pass "arguments" to a function within a function?
I have searched the r-help files but have not been able to find an answer to this question. I apologize if this questions has been asked previously. (Please excuse the ludicrousness of this example, as I have simplified my task for the purposes of this help inquiry. Please trust me that something like this will in fact be useful what I am trying to accomplish. I am using R 2.4.1 in Windows XP.)
2009 Jul 23
4
remove multiple columns by name from dataframe
Hi there, I'm trying to remove multiple columns by name from a data.frame. As a result I need to get back the modified data.frame without the removed columns. My columns I want to delete are listed in a vector called "delete". data <- read.csv2("data.csv") delete <- c("col1", "col2", "col3") newData <- subset(data, select =
2007 Apr 19
1
Histogram with uneven bins
Hi R-helpers I would like to produce a histogram with uneven bins (e.g., 0, 1-2, 3-5, 6-10, 10-20, >20) but I would like the resulting bars to be the same width ( i.e., a bar's width would not be proportional to its corresponding bin size). Also, the x and y axes of my histograms frequently (almost always, actually) extend beyond the axis labels (i.e., there are unlabeled bars). I would
2008 Sep 26
1
How to update a column in a dataframe, more simply...
Hello, I would like to be able to update an existing column in a dataframe, like this... data$score[data$type=="1" & data$year=="2001"]<-data$score * 0.111 data$score[data$type=="1" & data$year=="2002"]<-data$score * 0.222 data$score[data$type=="1" & data$year=="2003"]<-data$score * 0.333 ...but, if possible,
2010 Mar 18
4
Please help with loop, thanks
Dear R helpers, I would like to write a loop that makes 4 objects (called A, B, C, and D) each of which contains ten random numbers. This attempt: individuals<-c("A","B","C","D") for(i in 1:length(individuals)) { individuals[i]<-rnorm(10) } does not work because "individuals[i]" is not the proper way to extract each letter from the
2009 Jun 30
1
How to wrap my (working) code in a loop or function? (loop/function newbie alert)
Dear R-helpers, I have split a dataframe into a list with five elements, with the following code: > datalist<-split(data,data$UNIT) I would now like to run some code (below) on each element of the list to extract rows from the list elements; then I would like to rbind the extracted rows into a new dataframe containing all of the extracted rows from all of the list elements. I don't
2008 Jun 14
1
Correcting the display of colnames and rownames
Dear all, I have a data frame of dimension 720 columns by 360 rows, to which I am trying to add numerical row and column labels to, using the 'sequence' command. The original data, which I read in using 'read.table', had no such labels at all. I've got as far as successfully using the sequence command and getting the labels to display. However, I'm finding that for the
2010 Feb 04
1
replace a for loop with lapply or relative
Dear helpers. I often need to make dichotomous variables out of continuous ones (yes, I realize the problems with throwing away much of the information), but I then like to check the min and max of each category. I have the following simple code to do this that cuts each variable (x1,x2,x3) at the 90th percentile, and then prints the min and max of each category:
2009 Jul 01
2
getOptions("max.print") in R
I am typing the following on the command prompt: >variab = read.csv(file.choose(), header=T) >variab It lists 900,000 ( this is the total number of observations in "variab" ) minus 797124 observations and prompts the following message [ reached getOption("max.print") -- omitted 797124 entries ]] Is there a way to see the entire set of data, ie all of 900,000 obs, and
2008 Oct 14
2
list syntax question: which subscript is which
Hi, Sorry to bother with something that should be simple, but I can't find it. Suppose I have a list, each element of which is a 2xN dataframe, where N could be different for each element. Is there some simple structure to let me examine all the elements of each element's first column? For example: >foo $first [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 $second
2009 May 04
1
Please help me subset this dataframe, thanks...
Dear R-helpers, I have a dataframe called "trackpoints" with several columns including a column called "time", eg: > trackpoints ?? ? ? ?time 1 ? 12:00:00 2 ? 12:00:01 3 ? 12:00:02 . . . 298 12:04:57 299 12:04:58 300 12:04:59 I also have a dataframe called "data" that contains columns called "ID", "start" and "stop", eg: > data
2009 Jul 18
7
(-8)^(1/3) == NaN?
Why does the expression "(-8)^(1/3)" return NaN, instead of -2? This is not answered by http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-powers-of-negative-numbers-wrong_003f Thanks, Dave [[alternative HTML version deleted]]
2010 Feb 08
2
Counting by rows based on multiple criteria
Dear all, I have a data frame of 6 columns and ~60000 rows which I hope to perform the following calculation on. For each row, I wish to determine whether there are a greater number of positive or negative numbers. Then, if there are more positive numbers in the row, count how many occur - but if there are more negative numbers in the row, count them instead and insert a minus symbol before
2008 Sep 16
2
Turn of "save workspace" prompt (WinXP, R 2.7.2)
Hi, I'd like R to no longer prompt me to save my workspace every time I quit. I seem to recall seeing this option (maybe in the OS X console?) but I can't seem to find it in WinXP. Can anyone help? Thanks! Mark
2008 Oct 06
1
querry in simple "for" loop in Box plot
Dear R users, I am new users of this software. I want to make box plot. Here, i have simulated data set with following commands: x<-matrix(rnorm(90),nrow=10,ncol=9) x a<-matrix(c(1,1,1,1,1,2,2,2,2,2),nrow=10,ncol=1) xx<-cbind(a,x)
2008 May 15
2
Adding columns to dataframe
Hi, I have a dataframe SDF1 that looks like this: Char1 Char2 Char 3 W.2007.02 W.2007.09 W.2007.16 W.2008.13 A C1 F1 F2 F3 A C2 F4 B C3 F5 F6 I have another dataframe SDF2 with 163 cols that has the following column names Char1 Char2 Char 3 W.2007.02 W.2007.03 W.2007.04
2010 Aug 01
3
remove extreme values or winsorize – loop - dataframe
Hi everyone! #I need a loop or a function that creates a X2 variable that is X1 without the extreme values (or X1 winsorized) by industry and year. #My reproducible example: firm<-sort(rep(1:1000,10),decreasing=F) year<-rep(1998:2007,1000) industry<-rep(c(rep(1,10),rep(2,10),rep(3,10),rep(4,10),rep(5,10),rep(6,10),rep(7,10),rep(8,10),rep(9,10), rep(10,10)),1000) X1<-rnorm(10000)
2009 Jun 23
2
Problem with ifelse statement
Hi R-helpers, I am trying to use this ifelse statement to recode a variable: > data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B" & data$MALE>4, "C", "B") (i.e., if social status is B and there are more than 4 males, then recode social status to C; otherwise, leave it B) But, it's not working. See the below R output. Notice that there were 71
2008 Aug 12
2
Multiple column/row names?
Hi all, I wonder if there is a way to create a matrix with two (or even more) column/row names? Thank you very much. Have a nice day. -- ??? Hesen Peng http://hesen.peng.googlepages.com/