rbind

ShinyR : Unexpected result when exporting inputs

微笑、不失礼 提交于 2019-12-13 04:28:27
问题 following this post: (ShinyR : Insert user inputs in a database for further use), I found a solution to my problem, strongly inspired by this shiny app (https://deanattali.com/2015/06/14/mimicking-google-form-shiny/). I managed to get the main result I wanted (a database combining my observations and the results of the user of the app). Nonetheless I now have two new questions: First, how is it possible when looking at my code (complete version at the end of the post). Here are the lines from

Binding dataframes in list after data cleaning on list

一笑奈何 提交于 2019-12-13 04:01:09
问题 This is a follow up on my last question (Rbinding large list of dataframes after I did some data cleaning on the list). I've gotten smarter and the former question got messy. I have 43 xlsx files which I loaded in to a list in R: file.list <- list.files(recursive=T,pattern='*.xlsx') dat = lapply(file.list, function(i){ x = read_xlsx(i, sheet=1, col_names = T) # Create column with file name x$file = i # Return data x }) I then added some column names: my_names <- c("ID", "UDLIGNNR","BILAGNR",

R: How do I list a family of datasets and then rbind them?

徘徊边缘 提交于 2019-12-12 04:36:27
问题 I'm working on a new function for the OEC package (https://cran.r-project.org/web/packages/oec/index.html) so I can batch download data. Here's my new function that I want to include in my package https://gist.github.com/pachamaltese/3b585dded0a80c031c65e98b268ebcc7 So, this is a MWE #install.packages("devtools") library(devtools) install_github("pachamaltese/oec/cran") library(oec) getdata_interval("chl","chn",2010,2014,6,2) Now I cannot find a general way to rbind the result of that

Rbinding large list of dataframes after I did some data cleaning on the list

﹥>﹥吖頭↗ 提交于 2019-12-12 01:12:30
问题 My problem is, that I can't merge a large list of dataframes before doing some data cleaning. But it seems like my data cleaning is missing from the list. I have 43 xlsx-files, which I've put in a list. Here's my code for that part: file.list <- list.files(recursive=T,pattern='*.xlsx') dat = lapply(file.list, function(i){ x = read.xlsx(i, sheet=1, startRow=2, colNames = T, skipEmptyCols = T, skipEmptyRows = T) # Create column with file name x$file = i # Return data x }) I then did some

combining many data frames with rbind and pages

谁说胖子不能爱 提交于 2019-12-11 17:28:17
问题 I am trying to rbind pages sequentially by combining the data frames using the pages. library(jsonlite) pages <- list() for(i in 1:3){ mydata<- data.frame(c(1,2), c(4,5)) pages[[i+1]] <- mydata$filings } filings <- rbind.pages(pages) When i view the filings dataset I see only 0 variables. I am expecting 6 rows and 2 columns. Can some one address how to tether and attach the data while looping. Thanks 来源: https://stackoverflow.com/questions/30539282/combining-many-data-frames-with-rbind-and

R: Unable to rbind more than one observation to a data frame

萝らか妹 提交于 2019-12-11 16:48:52
问题 I've used data.table to create an empty data frame but when I'm adding observations to it all the observations after the first one get coerced to NA. First I create an empty data frame using the "stringsAsFactors = FALSE" parameter: cards <- data.frame(Ending = character(), Owner = character(), stringsAsFactors = FALSE) str(cards) 'data.frame': 0 obs. of 2 variables: $ Ending: chr $ Owner : chr I get a data frame with 0 observations and two character variables as expected. Then I create

Appending multiple files into a data frame using R

不羁的心 提交于 2019-12-11 13:04:39
问题 I am trying to append more than 10 000 files into a data frame in R. The first step in this job was to scrape files from for(i in 1:10000) { assign(x = paste("data", i, sep = "_"), value = readHTMLTable((paste("webaddress_page=", i, sep = '')),which=1)) } This works just fine, and I have 10 000 files, data_1-data_10000. However, I would like to append these files into a data.frame, but not sure how to proceed? Do I add another "data step", or maybe it is possible to do within the existing

R - how to add cases of one variable to other variable (stack variables)

﹥>﹥吖頭↗ 提交于 2019-12-11 12:59:35
问题 var1 var2 var3 1 2 3 1 2 3 1 2 3 I want to stack var2 and var3 underneath var1 to get: var1 1 1 1 2 2 2 3 3 3 I tried: data$var <- append(data$var1,data$var2) Then I get an error that my replacement has more rows. How do I solve this? 回答1: df <- data.frame(var1=1:3,var2=4:6,var3=7:9) df2 <- stack(df) print(df2) values ind 1 1 var1 2 2 var1 3 3 var1 4 4 var2 5 5 var2 6 6 var2 7 7 var3 8 8 var3 9 9 var3 回答2: You may want to try unlist : dtf <- data.frame(a = 1:3, b = 1:3, c = 1:3) unlist(dtf)

How to rbind vectors into different columns, leaving NAs in remaining cells

霸气de小男生 提交于 2019-12-11 12:33:47
问题 Let's say I have an unspecified number of vectors of different lengths, and I want to effectively rbind them together, with the caveat that they must each occupy a different column in the resulting data.frame. You may assume that the vectors are contained in a list, but you cannot depend on any component names that may be defined within the list. Below I present a random sample input ( lv ) and a poor solution to generate the required output that manually builds the resulting data.frame by

How to read nested JSON structure in R?

≡放荡痞女 提交于 2019-12-11 12:23:00
问题 I have some JSON that looks like this: "total_rows":141,"offset":0,"rows":[ {"id":"1","key":"a","value":{"SP$Sale_Price":"240000","CONTRACTDATE$Contract_Date":"2006-10-26T05:00:00"}}, {"id":"2","key":"b","value":{"SP$Sale_Price":"2000000","CONTRACTDATE$Contract_Date":"2006-08-22T05:00:00"}}, {"id":"3","key":"c","value":{"SP$Sale_Price":"780000","CONTRACTDATE$Contract_Date":"2007-01-18T06:00:00"}}, ... In R, what would be the easiest way to produce a scatter-plot of SP$Sale_Price versus