similar to: how can I convert a long to wide matrix?

Displaying 20 results from an estimated 400 matches similar to: "how can I convert a long to wide matrix?"

2018 May 01
2
how can I convert a long to wide matrix?
Hi Jim, The data set is correct. I took two readings from the "SITE A" within a short time interval, therefore I want to take the first value if there are repeated within a same group of "timeGroup". Therefore I wanted following FinalData1 B1 B2 id_X "A" "B" id_Y "A" "B" thanks, On Tue, May 1, 2018 at 4:05 PM, Jim
2018 May 01
2
how can I convert a long to wide matrix?
Hi Jim, Thank you very much for your suggestions. I used it but it gave me three sites. But actually I do have only two sites "Id_X" and "Id_y" . In fact "A" is repeated two times for "Id_X". If it is repeated, I would like to take the first one among many repeated values. dat<-structure(list(ID = structure(c(1L, 1L, 1L, 2L, 2L), .Label =
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna, This is a condition that the function cannot handle. It would be possible to reformat the result based on the time intervals, but the stretch_df function doesn't try to interpret the values, just stretches them out to a wide format. Jim On Wed, May 2, 2018 at 9:16 AM, Marna Wagley <marna.wagley at gmail.com> wrote: > Hi Jim, > The data set is correct. I took two
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna, I think this is due to having three rows for id_X and only two for id_Y. The function creates a data frame with enough columns to hold the greatest number of values for each ID variable. Notice that the SITE_n columns contain three values for id_X (A, A, B) and two for id_Y (A, B, NA) as there was no third occasion of measurement for the latter. Even though there are only two _values_
2018 May 01
0
how can I convert a long to wide matrix?
Hi Marna, Try this: library(prettyR) stretch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE")) Jim On Wed, May 2, 2018 at 8:24 AM, Marna Wagley <marna.wagley at gmail.com> wrote: > Hi R user, > I was trying to convert a long matrix to wide? I have an example and would > like to get a table (FinalData1): > > > FinalData1 > B1
2018 Apr 12
2
repeating functions for different folders?
Hi R users, I need to run a analysis using a data for each folder. I do have several folders. Each folder contains several files but these files name are similar to the files that is saved into another folders. I need to repeat the analysis for every folder and would like to save the output in that particular folder. After completing the analysis in one folder, I want to move another folder.
2013 Mar 04
1
Mysterious issues with reading text files from R in ArcGIS and Excel
It seems within the last ~3 months Ive been having issues with writing text or csv files from a R data frame.  The problem is multifold and it is hard to filter  out what is going on and where the problem is.  So, Im hoping someone else has come across this and may provide insight.   My current settings for R: R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1]
2016 Apr 14
3
calculate sampel size?
Hi R user, Can we calculate sample size when only mean and SE are given? Let say one example, I have mean with SE is 0.54+-0.0517 (mean+-SE). Is there any way to find the samples (sample size n) in that condition in R? i think this question is not related to R, I hope you won't mind. Thanks [[alternative HTML version deleted]]
2018 Apr 13
0
repeating functions for different folders?
Hi Marna, Assuming that you are descending into different subdirectories from the same directory: directories<-c("dir1","dir2","dir3") for(directory in directories) { setwd(directory) # do whatever you want to do # then return to the directory above setwd("..") } This will allow you to start and finish in the same directory. Jim On Fri, Apr 13,
2018 Apr 18
3
How to replace numeric value in the column contains Text (Factor)?
Hi R user, Would you mind to help me on how I can change a value in a specific column and row in a big table? but the column of the table is a factor (not numeric). Here is an example. I want to change dat[4:5,3]<-"20" but it generated NA> do you have any suggestions for me? dat<-structure(list(Sites = structure(1:5, .Label = c("Site1", "Site2",
2009 Apr 01
2
Matrix multiplication - code problem
Hi listers, I am having some trouble in a matrix multiplication... I have already checked some posts, but I didn't find my problem... I have the following code... But I am not getting the right multiplication... I checked the dimension and they are fine... id_y <- array(1:10,dim=c(2,1,5)) id_yt<-aperm(id_y,c(2,1,3)) m_id<-array(dim=c(dim(id_y)[1],dim(id_y)[1],dim(id_y)[3])) for (i in
2013 Mar 05
1
R-help Digest, Vol 121, Issue 5
On R 2.15.2 and ArcGIS 9.3.1, it works for me in ArcCatalog but you have to follow the particulars here: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Accessing_delimited_text_file_data For example: write.table(test, '***.tab', sep = '\t', row.names = F) The extension .tab and sep = '\t' are required for text files. Didn't test row.names=T but I
2017 Nov 10
1
How to create separate legend for each plot in the function of facet_wrap in ggplot2?
Hi R users, I need to create more than 20 figures (one for each group) in one page. I have a common legend for 20 figures using the facet_wrap. However the range of the values among the groups are very wide. For example one group has the value of 0 to 3, but the values of some of the groups has ranged from 0 to 20 so that when I used a single common legend for all 20 figures, I could not display
2017 Oct 18
1
creating tables with replacement
Building on Petr's suggestion, you could modify his code to get all 10 samples at once in a compact format: > Samples <- lapply(lll, function(x) replicate(10, sample(x, rep=TRUE))) # Samples is a list containing 3 matrices, one for each group # Each column gives the index (row) numbers for a particular sample > str(Samples) List of 3 $ A: int [1:3, 1:10] 2 1 3 1 1 3 2 3 1 2 ... $
2017 Oct 18
2
creating tables with replacement
Hi R User, I am new in R and trying to create tables with selecting rows randomly (but with replacement) for each group but each group should have same number as original. Is it possible to create it using the following example data set? Your help is highly appreciated. dat1<-structure(list(RegionA = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L),
2017 Oct 18
0
creating tables with replacement
Hi maybe there is another more elegant solution but something like this > idx <- 1:nrow(dat1) > lll <- split(idx, dat1$group) > dat1[unlist(lapply(lll, sample, rep=TRUE)),] gives you selected rows. You could use for cycle or save those data frames manually Cheers Petr > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Marna
2017 Oct 20
1
create a loop
Hi R Users, I do have very big data sets and wanted to run some of the analyses many times with randomization (1000 times). I have done the analysis using an example data but it need to be done with randomized data (1000 times). I am doing manually for 10000 times but taking so much time, I wonder whether it is possible to perform the analysis with creating a loop for many replicated datasets?
2018 Apr 18
0
How to replace numeric value in the column contains Text (Factor)?
The simplest would be to convert precip to character and then back to a factor if you really want it to be a factor. This will also remove the levels that no longer exist. str(dat) # 'data.frame': 5 obs. of 3 variables: # $ Sites : Factor w/ 5 levels "Site1","Site2",..: 1 2 3 4 5 # $ temp : num 14 15 12 12.5 17 # $ precip: Factor w/ 5 levels
2008 May 12
1
help with calculating the differences between dates
Dear list, How can I calculate the difference in days between the eventdate and basedate in the below dataset? id basedate outcome.3 eventdate daydiff 1 1001 1999-09-28 2 1999-10-01 3 2 1002 1999-09-22 1 3 1003 2000-01-19 1 4 1004 2004-01-25 2 2004-02-03 9 5 1005 2005-08-11 1 6 1006 2000-07-04
2011 Jan 03
8
Heroku, needs constant AppController updates?
Dear All, Fairly new to rails and Heroku, so could be doing something wacky - do let me know if you think my code practice is off, even if unrelated to this error, I''d like to learn! I''m using Rails 3.0.0, ruby 1.8.7, and ''sqlite3-ruby'', ''1.2.5'', :require => ''sqlite3''. I''ve got an application that goes off and