Displaying 20 results from an estimated 40000 matches similar to: "how to load packages from different location"
2009 Jul 05
3
allocation/initialization of arrays/lists
Dear list,
I have a question regarding how to allocate or initialize the proper type of
the arrays or lists.
I have a for loop, each iteration, I want it to assign a subset of a data
frame to an element of an array or list.
However, I am wondering how I should initialize or allocate the empty array
or list so that it has the same number of the elements as the subsets I am
going to assign and
2009 Mar 07
4
merge data frames with same column names of different lengths and missing values
Hello, I'm switching over from SAS to R and am having trouble merging data frames. The data frames have several columns with the same name, and each has a different number of rows. Some of the values are missing from cells with the same column names in each data frame. I had hoped that when I merged the dataframes, every column with the same name would be merged, with the value in a complete
2009 Dec 08
3
re-ordering x-lables using barchart()
Hi R Users,
I'm trying to re-order the "site names" ("Waseca", "Morris", ...). I'm using
following code:
libarry(lattice)
barchart(yield ~ variety | site, data = barley,
groups = year, layout = c(6,1), aspect=.7,
ylab = "Barley Yield (bushels/acre)",
scales = list(x = list(abbreviate = TRUE, rot=45,
2011 Feb 17
2
sort by column and row names
Hello, All,
How can one sort on column and row names. For example:
How can this
X1 X3 X2
X1 1 0 0
X3 0 1 0
X2 0 0 1
become this?
X1 X2 X3
X1 1 0 0
X2 0 1 0
X3 0 0 1
Thank you for your time!
Jim
[[alternative HTML version deleted]]
2009 Mar 11
4
R-help: grep in for loop using index - doesn't work
Hi everyone
I am trying to use grep in a for loop to compare a string value. It works
if I use
the actual index value but when I use the for loop index, it doesn't work.
Any suggestions plz.
Here is the code:
data <- read.table(file="Sigmoid.csv", head=FALSE, sep=",");
c1 <- data$V1
c2 <- data$V2
c3 <- data$V3
c1data <- data.frame(c1);
c2data <-
2010 Oct 01
3
Suppressing printing in the function
Hello!
I wrote a function that returns a data frame. Nowhere in the function
do I say print(my.data.frame), but when I run the function - the data
frame is printed on the console.
Is there any way to suppress it?
Thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2010 Jul 28
2
read.delim()
I am reading in a very large file with names in it and R is truncating the number of rows it reads in. The separator in this file is a pipe '|' and so I use
dat <- read.delim('pathToMyFile', header= TRUE, sep='|')
It turns out that it is reading up to row 61145 and stopping and I think I see why, but am not sure of the best solution to this problem. I see the name of
2009 Aug 07
3
Simple Question: adding points to a boxplot
I apologize in advance for the simplicity of this question. I use R 2-3 times a year, and I seem to forget more in the intervening months than I learn during my days of panicked reading.... I HAVE tried looking at the help resources; I'm just not very good at understanding them.
I have a dataframe with 18 observations of 5 different things, and a second dataframe with and estimate for those
2010 Feb 13
2
lm function in R
Hello,
I am trying to learn how to perform Multiple Regression Analysis in R. I
decided to take a simple example given in this PDF:
http://www.utdallas.edu/~herve/abdi-prc-pretty.pdf
I created a small CSV called, students.csv that contains the following data:
s1 14 4 1
s2 23 4 2
s3 30 7 2
s4 50 7 4
s5 39 10 3
s6 67 10 6
Col headers: Student id, Memory span(Y), age(X1), speech rate(X2)
Now
2011 May 24
2
Extracting day of month from Date objects
I've always found the chron library to be useful for
tasks like this:
> x <- round(runif(10)*100000, digits=0)
> y <- as.Date(x, origin="1970-01-01")
> library(chron)
> days(y)
[1] 7 25 26 25 10 24 1 31 12 8
31 Levels: 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < ... < 31
Notice that it returns the days as
2010 Oct 28
2
Determining a basal correct count
Here's another interesting problem: if you recall I have a data frame (LCvars1) that consists of about 1500 cases (rows) of data from kids who took a test of listening comprehension. The columns are their scores (1 = correct, 0 = incorrect, . = missing) on 140 test items. The items are numbered sequentially and are ordered by increasing difficulty as you go from left to right across the
2009 Apr 28
4
Producing customized tickmarks when producing a graph using "curve"
Hello!
I am using function "curve" to create a line graph.
I was wondering, if it's possible to "turn off" the default tick marks
and introduce those tick marks in specific locations.
For example, currently in my X axis tick marks are (automatically) at
10, 11, 12, 13 but I want them to be in 5 specific locations, like
9.89, 10.34, etc.
Any hint would be greatly
2006 Nov 01
3
matrix manipulation with a for loop
Hi,
Having a matrix F.zoo (6575,189) with NA's in some columns I'm trying to
extract from each column the percent of days within an specific range,
so I've wrote this procedure:
length(subset(F.zoo[,86],(F.zoo[,86]>=5) & (F.zoo[,86]<=
9)))/(length(F.zoo[,86])-length(subset(F.zoo[,86],is.na(F.zoo[,86]))))*100
But to do this for each column (189) is pretty hard, so I want
2009 Oct 04
2
Row to Column help
Dear R Community,
I am attempting to transpose a dataset from rows to columns but am stuck. I
have tried using reshape() with little luck, possibly due to the categorical
nature of the data. For example:
id<-c(1,2,2,3,3,3)
author<-c("j","k","k","l","l","l")
2008 May 01
3
how to not sort factors when plotting
Hello,
When making a graph, plot and boxplot automatically sort my factor
levels (y axis) into alphabetical order. Is there a way to make it
NOT do this? I've tried:
sort.by="none", sorted=FALSE, sort=FALSE, reorder=FALSE.
Thank you.
2010 Nov 29
3
List elements of NULL to value
Hi everyone,
I am posting this because i know its easy and i cant for the life of me
figure out how to do it though i have tried and through a ridiculously
complex loop made it happen. I need to convert some list elements of NULL
value to 0s so they mesh with my data frame properly. So for
A<-list(1,NULL)
returns
[[1]]
[1] 1
[[2]]
NULL
Would instead return
[[1]]
[1] 1
[[2]]
[1] 0
2009 Dec 17
1
Problem reading binaries created with fortran (More infos)
The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)
here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4 34.5 ......
I tried to read the first line with readBin (results are copied below):
2008 May 14
4
Newbie question about vector matrix multiplication
Hello All,
I have a covariance matrix, generated by read.table, and cov:
co<-cov(read.table("c:/r.x"))
X Y Z
X 0.0012517684 0.0002765438 0.0007887114
Y 0.0002765438 0.0002570286 0.0002117336
Z 0.0007887114 0.0002117336 0.0009168750
And a weight vector generated by
w<- read.table("c:/r.weights")
X Y
2010 Sep 13
2
proportion
Hi ,
SO i have been on a role of asking simple questions lately. So much for
feeling like im getting this R business.
I wrote a script 2 weeks ago that utilized "proportion" to turn values in a
table (from "table") into proportions to then graph. I now get an error
that proportion is not a function so im confused. I ran the script a few
times and im thinking maybe i had
2006 Sep 06
2
JPEG struct mismatch on Intel Macs (PR#9209)
Full_Name: Phil Spector
Version: 2.3.1
OS: Mac OS X (Tiger)
Submission from: (NULL) (128.32.135.22)
Trying to close a jpeg() device on an Intel Mac causes the following:
> jpeg('out.jpg')
> plot(1:10)
> dev.off()
JPEG parameter struct mismatch: library thinks size is 372, caller expects 376
null device
1
>
An empty jpg file is produced in 'out.jpg'