r

[R] putting text on the X Axis of Graphs

I need to plot a graph where the X values are all names -e.g. states of America and the Y values are numberic and in descending order- e.g. population of the states of America. Currently, when I use the plot function, it plots a graph but a) The Y values are not in descending order and b) the X Axis displays a bunch of ascending number...

Load Excel file to R while setting column equal to a factor

I have an Excel file that I am trying to load into R using the odbcConnectExcel and sqlQuery commands from RODBC package. One of the columns has numerical values with plus or minus signs, such as '5+ or '3-. However, if i do something like, conn <- odbcConnectExcel("file.xls") sqlQuery(conn, "SELECT * FROM `Sheet1$`") then the column ...

icc's when the number of judges is not constant

Hi, I have the following problem. I need to calculate the Shrout & Fleiss ICC's for the situation in which items are judged by a varying number of judges. For example, the competitive nature of an industry is judged for a set of industries, but with a different number of judges per industry. One industry is only judged by 2 judges, wher...

Difference between Rscript and littler

...besides the fact that Rscript is invoked with #!/usr/bin/env Rscript and littler with #!/usr/local/bin/r (on my system) in first line of script file. I've found certain differences in execution speed (seems like littler is a bit slower). I've created two dummy scripts, ran each 1000 times and compared average execution time. Here's...

Where in R do I permanently store my custom functions?

I have several custom functions that I use frequently in R. Rather than souce this file (or parts thereof) in each script, is there some way to add this to a base R file such that they are always available when I use R? ...

in R, creating time and id indexes for Panel data using PLM package--SOLVED BY MANAGING ENVIRONMENT! THX

Hi Everyone- I am trying to run a pooled cross sectional analysis with panel data in R. The first thing I have done after importing the data, is to drop (a) some variables and (b) some years, since I have compiled this data from multiple sources and I don't have all of the data for all of the years. The following is the code I have ...

Problem naming array dimensions

This is my first time using a 3 dimensional array and I am having problems naming the third dimension. ReplicateData <- array(0,c(240,500,5),dimnames=list(NULL, NULL, c("Returns","Replicates","Asset Class"))) I am getting the error "Length of dimnames not equal to array extent" This seems like it should be a simple issue but I can't fi...

Form matrix from rows in 3-dimensional array

I have X, a three-dimensional array in R. I want to take a vector of indices indx (length equal to dim(X)[1]) and form a matrix where the first row is the first row of X[ , , indx[1]], the second row is the second row of X[ , , indx[2]], and so on. For example, I have: R> X <- array(1:18, dim = c(3, 2, 3)) R> X , , 1 [,1] [,2] [1...

How to replace a column in R? strange behavior with dates...

Dear all, I am trying to convert a uncommon date format into a standard date. Basically I have a dataset that contains a period with semiannual frequency formatted like: 206 denoting the second half of 2006, 106 denoting the first half and so forth. In order to rearrange it to 2006-06-01 respectively 2006-01-01, i have written a small ...

[R] How do I split a vector into two columns to create ordered pairs for random assignment

I am trying to generate random pairs from 34 subjects for an experiment. Subjects will be assigned ID #'s 1-34. To generate the random ordered numbers (1-34) I used the following code: ### Getting a vector of random ordered numbers 1-34### pairs<-sample(1:34,34,replace=F) pairs [1] 16 22 8 13 4 25 18 12 17 5 6 31 29 27 30 ...

Recommendations for "Dynamic/interactive" debugging of functions in R ?

Hi all, When debugging a function I usually use library(debug) mtrace(FunctionName) FunctionName(...) And that works quite well for me. However, sometimes I am trying to debug a complex function that I don't know. In which case, I can find that inside that function there is another function that I would like to "go into" ("debug")...

How would I parse the XML file in R and carry out basic Statistics Analysis on the data.

Hi, I am trying to parse the XML file in R, so that I can analysis the data. I am trying to get the mean and standard deviation of the price. Also I would like to be able to get the rate of change in the time of the share price changing. I have tried entering the data by hand but am having problems with the date structure ( I have tried ...

Unexpected R dataframe problem

Hi, I have a long list of dates that i want to parse, they are in a dataframe (the_dates). I've loaded them into R (from a sqlite db) just fine, however, if i do str(the_dates) i get: 'data.frame': 3968 obs. of 1 variable: somehow R treats this as a single variable, which is why i am having trouble converting into Date format - i...

Algorithms and methods for attribute/feature selection?

I have data with continuous class and I'm searching for good methods to reduce number of attributes. Now I'm using correlation based filters, random forests and Gram–Schmidt algorithm. What I want to achieve is answer which attributes are more important/relevant to class attribute than others. By using methods that I mentioned befor...

display values in stacked lattice barchart [R]

Hi, I want to display the values of a 100% bar for each part of it. Unfortunately I don't know how to do it. The graph should be in lattice because of the legend position (I tried it with ggplot2, but you can't show the legend in one row). I'm pleased about any suggestions or ideas. Thanks, Sebastian library(lattice) data(postdoc, pac...

create 3 dimensional array with different lengths

hi, I am a beginner of R. I want to create a 3 dimensional array but I can not define the length of each dimension. I am analysing students' marks of a class. there are 10 classes but it has different number of students. And "Grade" will be 100-90, 89-80, 79-70... until there will be any student who got the relevant marks. I was going t...

Mapping the link network between blogs using R?

I would like any advice on how to create and visualize a link map between blogs so to reflect the "social network" between them. Here is how I am thinking of doing it: Start with one (or more) blog home page and collect all the links on that page Remove all the links that are internal links (that is, If I start from www.website.com. ...

Data visualization: Bubble charts, Venn diagrams, and tag clouds (oh my!)

Suppose I have a large list of objects (thousands or tens of thousands), each of which is tagged with a handful of tags. There are dozens or hundreds of possible tags and their usage follows a typical power law: some tags are used extremely often but most are rare. All but the most frequent couple dozen tags could typically be ignored, i...

John Tukey "median median" (or "resistant line") statistical test for R and linear regression

Hello guy, I'm searching the John Tukey algorithm which compute a "resistant line" or "median-median line" on my linear regression with R. A student on a mailling list explain this algorithm in these terms : "The way it's calculated is to divide the data into three groups, find the x-median and y-median values (called the s...

How can I alter a time series (XTS or ZOO) in R?

I am new to stackoverflow and fairly new to R but have searched long and hard and cannot find an answer to the following question. I have a number of data files that are temperature against a time series. I am importing the CSV as a ZOO object then converting to XTS. A correct file looks like this, with readings on the hour and the half...