r

Error in fix.by(by.x, x) : 'by' must specify a uniquely valid columnmergedata <- merge (dataset1, dataset2, by.x=“personalid”) [closed]

我与影子孤独终老i 提交于 2021-02-10 17:59:05
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question mergedata <- merge (dataset1, dataset2, by.x="personalid") Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column 回答1: The OP had specified only the by.x . If the column names are the same, then by can be used merge(dataset1, dataset2, by="personalid

How to translate point size in cex into units of plot in R

烂漫一生 提交于 2021-02-10 17:57:53
问题 I try to figure out how big the radii of the points in my plot in x and y direction are going to be, with their size being set by cex . I want to create a plotting function which needs this information. It appears to me as if cex would be this magical parameter and nobody actually knows what exactly it is going to do. I am creating a plot with the png function. I set a graph width and height. I set par(mar) and par(oma) . I plot an empty plot with an xlim and ylim being set, and add an

How to create a new column in data frame which each row of new column is multiplication of all previous rows

南笙酒味 提交于 2021-02-10 17:56:45
问题 I have a data frame like the one shown below: ref_inf <- c(2,3,1,2.2,1.3,1.5,1.9,1.8,1.9,1.9) ref_year<- seq(2001,2010) inf_data <- data.frame(ref_year,ref_inf) ref_year ref_inf 1 2001 2.0 2 2002 3.0 3 2003 1.0 4 2004 2.2 5 2005 1.3 6 2006 1.5 7 2007 1.9 8 2008 1.8 9 2009 1.9 10 2010 1.9 What I want to do is to create a new column "Final Inflation" and each number in the new column should be calculated by multiplying all previous numbers in ref_inf column, so for example, if I want to

Graph bars only appear when lower limit of y axis set to 0 in ggplot

半腔热情 提交于 2021-02-10 17:55:55
问题 I am trying to create a bar graph. When I set the limits as (0,7), the bars appear. However, I would like the lower limit to be 1, not 0. When I set the lower limit to 1, the bars do not appear. I get the following error message: Removed 8 rows containing missing values (geom_bar). It doesn't matter how I set the limits. I have used both of the following options: ylim(1, 7) scale_y_continuous(limits = c(1, 7)) Does anyone know how I can fix this? I'd like a graph that looks like this, but

How to color the slider in shiny to the right of the value instead of to the left?

微笑、不失礼 提交于 2021-02-10 17:53:29
问题 I am building an app with shiny and use a slider pretty much as the one shown in Shiny gallery (http://shiny.rstudio.com/gallery/slider-bar-and-slider-range.html). By default it gets coloured blue to the left of the chosen value (in this example from 0 to 50). Is there a way to get it coloured to the right of the chosen value: e.i. from 50 to 100? The reason I would like to do it, is that the user should read it as "all values from the threshold to max", so colouring from the min to the

What exactly does complete in mice do?

拟墨画扇 提交于 2021-02-10 17:53:05
问题 I am researching how to use multiple imputation results. The following is my understanding, and please let me know if there're mistakes. Suppose you have a data set with missing values, and you want to conduct a regression analysis. You may perform multiple imputation for m = 5 times, and for each imputed data set (5 imputed data sets now) you run a regression analysis, then "pool" the coefficient estimates from these m = 5 models via Rubin's rules (or use R package "pool"). My question is

extract values from a data frame based on a vector of row numbers in R

喜夏-厌秋 提交于 2021-02-10 17:52:30
问题 I am trying to extract a vector of values from a data frame based on a vector of row numbers; df<-iris x<-c(1,5,15,8,7,2) I want the corresponding Species of the row numbers listed in the vector x. I have tried something like df$Species[x,] and df$Species[list(x),] to no avail. I am sure the answer is something really simple but I just can't see it! Thanks in advance 回答1: Try df[x,]$Species or df[,"Species"][x] or indeed df[x,"Species"] 来源: https://stackoverflow.com/questions/17439396/extract

What exactly does complete in mice do?

╄→尐↘猪︶ㄣ 提交于 2021-02-10 17:51:40
问题 I am researching how to use multiple imputation results. The following is my understanding, and please let me know if there're mistakes. Suppose you have a data set with missing values, and you want to conduct a regression analysis. You may perform multiple imputation for m = 5 times, and for each imputed data set (5 imputed data sets now) you run a regression analysis, then "pool" the coefficient estimates from these m = 5 models via Rubin's rules (or use R package "pool"). My question is

Error running weathercan package - fatal SSL/TLS alert (e.g. handshake failed))

萝らか妹 提交于 2021-02-10 17:49:25
问题 I am running the "weathercan" data package (https://cran.r-project.org/web/packages/weathercan/index.html; https://github.com/ropensci/weathercan) and keep getting an error when trying to retrieved data from the Environment and Climate Change historic weather data website. I've re-installed the package, I even reinstalled R and RStudio after deleting everything R from my system, but the error persists. The package works fine when I look up stations up, e.g., stations_search(coords = c(44

Using a custom R generator function with fit_generator (Keras, R)

北战南征 提交于 2021-02-10 17:48:13
问题 I'd like to train a convolutional network to solve a multi-class, multi-label problem on image data. Due to the nature of the data, and for reasons I'll spare you, it would be best if I could use a custom R generator function to feed to the fit_generator command, instead of its built-in image_data_generator and flow_images_from_directory commands (which I was successfully able to get working, just not for this particular problem). Here (https://www.rdocumentation.org/packages/keras/versions/2