similar to: 2 Seemingly Simple Problems

Displaying 20 results from an estimated 50000 matches similar to: "2 Seemingly Simple Problems"

2002 Jun 12
4
Opening all files in a directory
Is there any way that R can be programmed so that it will cycle through all files in a directory without having to define file names? The reason I ask is because I will have about 50-100 files in a directory which will be randomly named. ie: MIDEX, OACES-CO2, ODEN91, etc... If not...are there any languages out there that will do this sort of things? Or is there another method you could
2002 May 21
2
Unwanted Levels in R
I searched the mailing list archives and found one post relevant to my problem, but it was not specific enough to solve my problem. I am reading in a large file of data (I believe it is in ASCII format). I have tried reading the file in as a data frame and as a list, and both methods result in unwanted levels being created which leads to problems when I try to copy or reference certain cells.
2010 Jan 17
4
How to convert character matrix or data.frame to numeric?
Hello, This turned out to be surprisingly hard for me: Let's say I have mm = matrix(as.character(seq(1,30, 1)), nrow=3); mm [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] "1" "4" "7" "10" "13" "16" "19" "22" "25" "28" [2,] "2" "5"
2002 Jun 13
1
problem with read.fwf
Here is an example of the data I'm reading in using read.fwf: 5342.0 5450.4 0.9200 0.4506 34.7030 27.8411 37.1306 46.0034 0.0000 5438.0 5549.6 0.9300 0.4477-34.7280 27.8616 37.1506 46.0234 0.0000 And the commands I'm using to read it in: widths <- c(7,7,8,8,8,8,8,8,8) filedata <- read.fwf(fileopen, widths,sep="",dec=".") The problem is with
2002 Jun 06
1
Dealing with data of varying format
I'm trying read some data files into data frames, but the formatting of their headers is creating problems when I try to reference certain columns. For instance...below I've pasted four of the headers to give an idea how they vary slightly. A 90404001 POLARSTERN GERMANY MIZEX A 819300 HUDSON CANADA
2013 Mar 03
4
Help searching a matrix for only certain records
Let me start by saying I am rather new to R and generally consider myself to be a novice programmer...so don't assume I know what I'm doing :) I have a large matrix, approximately 300,000 x 14. It's essentially a 20-year dataset of 15-minute data. However, I only need the rows where the column I've named REC.TYPE contains the string "SAO " or "FL-15". My
2002 May 29
2
Setting the Number of Columns
I am trying to read in a data set with 17 columns into a data frame. The problem is, there are some lines in the data that occasionally pop up with less than 17 numbers in a row. I was trying to use the command data <- read.table("dataset.dat", fill=TRUE, quote = "") There was no problem running this with an older version of R and the data was forced into a data frame
2006 Feb 05
3
reading in a tricky computer program output
Hi R user I need to read in some values from a computer program output. I can't change the output format because the developer of the program doesn't allow to change the format of output. There are two formats. First one looks like this if I have 10 variables, ------------------------------------------------------------------------------------------------------ [ 1]
2012 Apr 13
1
Seemingly simple "lm" giving unexpected results
I can't figure out why this is returning an NA for the slope in one case, but not in the other. I can tell that R thinks the first case is singular, but why isn't the second? ## Define X and Y ## There are two versions of x ## 1) "as is" ## 2) shifted to start at 0 y = c(58, 57, 57, 279, 252, 851, 45, 87, 47) x1 = c(1334009411.437, 1334009411.437, 1334009411.437,
2006 Aug 08
2
Getting data out of a loop
A stupid question but I just cannot see how to do this. I have a loop that does some calculations and puts the results in a vector for each iteration, but I cannot see how to get the data out of the loop in such a way that I can use it. I can print it but how do I get it into a set of vectors or what ever. Any help gratefully received. Thanks Example cata <- c( 3,5,6,8,0, NA) catb <-
2009 Apr 02
1
Updating a data frame
Folks, Updating values in a table is simple in SAS or SQL, but I've wracked my brain looking for an elegant solution in R to no avail thus far. Certainly this is a common need that's been solved in dozens of different ways. Given an initial dataframe nn and a smaller dataframe of updates uu, I'd like to replace the values in nn <- expand.grid('a'=1:4, 'b'=1:3)
2003 Dec 23
3
Why does simple smb.conf demand password?
I am trying to setup a simple Samba server using the instructions in the O'Reilly book "Using Samba" first edition on a Slackware 9.1 system which uses Samba 2.2.8a. The windows machine uses windows 98SE. The instructions under Server Configuration starting page 93 and Disk Share Configuration starting page 96 had me setup a very simple smb.conf which should then appear in Network
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a" and "b", still
1998 Feb 27
1
R-beta: is there a way to get rid of loop?
Here is a programming question. The code I am using is quite slow and I was wondering if there is a way to get rid of the for loop. I am dealing with "interaction" in 2x2 table, and am using Edwards's G_I (Likelihood, p. 194). I label the cells in the table as follows stim response "y" "n" total -------------------------------- y hit miss nsignal
2006 Jun 29
2
Biobass, SAGx, and Jonckheere-Terpstra test
Hi list, I tried to load the package SAGx and failed because it complains it's looking for the Biobass which is not there. Then I looked up the package list and Biobass is not found. I'm trying to run the Jonckheere-Terpstra test and from what I see in the R archive, SAGx is the only place it's been implemented. > library(SAGx) Loading required package: multtest Loading required
2003 Sep 03
2
lme in R and Splus
Good Day, Included below is some code to generate data and to fit a mixed effects model to this fake data. The code works as expected when I call the function "lme" in Splus but not in R. The error message from calling lme in R is: "Error in getGroups.data.frame(dataMix, groups) : Invalid formula for groups" I installed the nlme package for R around 20 August
2005 Jul 28
1
Unexpected behavior in recode{car}
Thanks to the R creators for such a great statistical system. Thanks to the R help list, I have (finally) gotten far enough in R to have a question I hope to be worth posting. I'm using the recode function from John Fox's car package and have encountered some unexpected behavior. Consider the following example: ## Begin cut-and-paste example require( car ) set.seed(12345) nn <-
2009 Jun 14
2
read.csv
If read.csv's colClasses= argument is NOT used then read.csv accepts double quoted numerics: 1: > read.csv(stdin()) 0: A,B 1: "1",1 2: "2",2 3: A B 1 1 1 2 2 2 However, if colClasses is used then it seems that it does not: > read.csv(stdin(), colClasses = "numeric") 0: A,B 1: "1",1 2: "2",2 3: Error in scan(file, what, nmax, sep,
2006 Aug 24
1
Using a 'for' loop : there should be a better way in R
I need to apply a yearly inflation factor to some wages and supply some simple sums by work category. I have gone at it with a brute force "for" loop approach which seems okay as it is a small dataset. It looks a bit inelegant and given all the warnings in the Intro to R, etc, about using loops I wondered if anyone could suggest something a bit simpler or more efficent? Example:
2013 Apr 12
2
model frame and formula mismatch in model.matrix()
Hello everyone, I am trying to fit the following model All X. variables are continuous, while the conditions are categoricals. model <- lm(X2